Read the S-Command in the HAL

More
1 year 7 months ago #325187 by Wiesi-94
Hello,
I'm currently implementing a retrofit for our SHW UF31. So far, progress is pretty good. But I have a small problem with the gear selection.
I'm using Classic Ladder to shift the three gears. It works quite well so far. I have a float input for the spindle speed, which is used to select and engage the correct gear.

The plan is to use the S command to set the gear. But I don't know which HAL pin I can use to query the set speed without the spindle running.

So what I need is a way to read this system parameter in the HAL / Classic Ladder:
#<_rpm> - Return the current value of S, not the actual spindle speed.

Best regards, Stefan

Please Log in to join the conversation.

More
1 year 7 months ago #325225 by cmorley
you could try something this:
linuxcnc.org/docs/devel/html/gui/gstat.h...mponent_code_pattern

but use the message 's-code-changed'

Please Log in to join the conversation.

More
1 year 6 months ago #325411 by Wiesi-94
That works, thanks!!

Please Log in to join the conversation.

More
1 year 5 months ago #328879 by Doc_emmet
Hello, can you show me how to read the S command and what you changed.   

Please Log in to join the conversation.

More
1 year 5 months ago #328906 by Todd Zuercher
To do the above suggestion to get a hal pin that shows the commanded S speed even when the spindle is stopped. The link gives instructions for creating a python script that reads what the commanded S speed settinging is from the Gstat python module and then creates a hal pin and writes the value to it.

You will need to create at python script with the following, and save it as a file in your config directory named "spindle.py" and make that file executable.
Code:
#!/usr/bin/env python3 import gi gi.require_version('Gtk', '3.0') from gi.repository import GObject from gi.repository import GLib import hal from hal_glib import GStat GSTAT = GStat() # callback to change HAL pin state def mode_changed(obj, data): h['speed'] = data # Make a component and pins h = hal.component("spindle_setting") h.newpin("speed", hal.HAL_FLOAT, hal.HAL_OUT) h.ready() # connect a GSTAT message to a callback function GSTAT.connect("s-code-changed",mode_changed) # force GSTAT to initialize states GSTAT.forced_update() # loop till exit try: GLib.MainLoop().run() except KeyboardInterrupt: raise SystemExit

Then load/run that python script when you start Linuxcnc by adding this line to your hal file for your config. (Replacing YOUR_CONFIG with the name of your config dir.)
Code:
loadusr python3 ~/linuxcnc/configs/YOUR_CONFIG/spindle.py

You can even test this before adding it to your hal file by simply running the python script from command line while Linuxcnc is running. Just type "python3 ~/linuxcnc/configs/YOUR_CONFIG/spindle.py" and hit enter. (After first creating the spindle.py file, saving it to your config dir.)

Please Log in to join the conversation.

More
1 year 5 months ago #328946 by Doc_emmet
Thanks, it works

Please Log in to join the conversation.

Time to create page: 0.121 seconds
Powered by Kunena Forum