2-speed spindle configuration - help

More
11 Apr 2021 08:23 #205611 by foxington
Andy for first I want to thank you for contributing on solution of my problem... a lot of ways to solve that.

I too young and stupid to try to trust anybody, directly me absolutely not. there we have Murphy´s laws and that says, "Anything that can go wrong will go wrong". -- and for this purpose I want to double check safety and functionality of all my devices.

Most pretty way is still gearchange.comp which grab information from .hal, when you want to turn on spindle. I will create custom .hal pin of CSS status as you described here :

If you want the mode as a HAL pin, then you can probably use Gstat to create it, see the first example here:
linuxcnc.org/docs/2.8/html/gui/GStat.html
And the "css-mode"callback.

directly by the first examle what is right that what I will need. I will create somethink like this :
#!/usr/bin/env python

import hal
from hal_glib import GStat
import gobject
GSTAT = GStat()

# callback to change HAL pin state
def mode_changed(obj, data):
        h['g97'] = not data
        h['g96'] = data

# Make a component and pins
h = hal.component("css_status")
h.newpin("g97", hal.HAL_BIT, hal.HAL_OUT)
h.newpin("g96", hal.HAL_BIT, hal.HAL_OUT)
h.ready()

# connect a GSTAT message to a callback function
GSTAT.connect("css_changed",mode_changed)

# force GSTAT to initialize states
GSTAT.forced_update()

# loop till exit
try:
        gobject.MainLoop().run()
except KeyboardInterrupt:
        raise SystemExit

I will add them to .hal like custom python script as file like:
loadusr python -Wn css_status PATH-TO-FILE/my_custom_css_status.py
In this way it will be created after all other pins were created?

and "pins" from custom component "css_status" I will "net" with custom "pins" of gearchange component for reading actual status. I will have everything what need to change in one place with nice and clear overview.

next steps will be to create alarm messages for alert me or whoever will run machine: you have wrong gear, program will stop.

Please Log in or Create an account to join the conversation.

Time to create page: 0.140 seconds
Powered by Kunena Forum