Syncing hardware and software switches
21 Nov 2016 06:12 #83053
by an92626
Syncing hardware and software switches was created by an92626
I am trying to sync the machine power toggle (F2) with a momentary switch on my pendant. The momentary switch energizes a self locking relay circuit and can not stay on. I can sync the momentary switch to the software button, but can not sync the software button to the mechanical switch.
I can use the hal commands
net power-on hm2_5i25.0.7i77.0.0.input-20 hm2_5i25.0.7i77.0.0.output-05 hm2_5i25.0.7i77.0.0.output-10
net power-on halui.machine.on
so that when the mechanical momentary switch is pushed (input-20), halui.machine.on goes true momentarily and machine power (halui.machine.is.on) is turned on. The problem I have is that I can not find a signal or pin that momentarily activates when the software button is pressed. I assume that "halui.machine.on" must go true to turn the machine on, but I cannot seem to read this signal to use it as my momentary switch. "Halui.machine.is.on" will change from false to true when the software key is pressed, but it stays true until the software key is pressed again and it turns false. I need something that will indicate only when the software key is pressed and not stay on; essentially a software equivalent of a momentary switch. There must be something down within the gui coding which triggers when the software button is clicked, but I have no idea how to get to it.
The only approach I can think of is writing a hal component that will test for "halui.machine.is.on" changing from true to false, and false to true, and then somehow turning on a signal for a specific time period only when a change in "halui.machine.is.on" is detected, like a momentary switch would function. Is this the correct approach, or is there a better method? The key requirement is that I only want a momentary signal, not one that stays true or false.
I am more interested an explanation of how to do this than in just cutting and pasting someone else's code. Eventually I will be doing something similar with the estop and other software keys so understanding the approach and theory is important so I can solve my next problem on my own.
Thanks.
I can use the hal commands
net power-on hm2_5i25.0.7i77.0.0.input-20 hm2_5i25.0.7i77.0.0.output-05 hm2_5i25.0.7i77.0.0.output-10
net power-on halui.machine.on
so that when the mechanical momentary switch is pushed (input-20), halui.machine.on goes true momentarily and machine power (halui.machine.is.on) is turned on. The problem I have is that I can not find a signal or pin that momentarily activates when the software button is pressed. I assume that "halui.machine.on" must go true to turn the machine on, but I cannot seem to read this signal to use it as my momentary switch. "Halui.machine.is.on" will change from false to true when the software key is pressed, but it stays true until the software key is pressed again and it turns false. I need something that will indicate only when the software key is pressed and not stay on; essentially a software equivalent of a momentary switch. There must be something down within the gui coding which triggers when the software button is clicked, but I have no idea how to get to it.
The only approach I can think of is writing a hal component that will test for "halui.machine.is.on" changing from true to false, and false to true, and then somehow turning on a signal for a specific time period only when a change in "halui.machine.is.on" is detected, like a momentary switch would function. Is this the correct approach, or is there a better method? The key requirement is that I only want a momentary signal, not one that stays true or false.
I am more interested an explanation of how to do this than in just cutting and pasting someone else's code. Eventually I will be doing something similar with the estop and other software keys so understanding the approach and theory is important so I can solve my next problem on my own.
Thanks.
Please Log in or Create an account to join the conversation.
21 Nov 2016 12:36 #83063
by andypugh
Replied by andypugh on topic Syncing hardware and software switches
Is this any help?
linuxcnc.org/docs/2.7/html/man/man9/toggle2nist.9.html
linuxcnc.org/docs/2.7/html/man/man9/toggle2nist.9.html
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Offline
- Platinum Member
-
Less
More
- Posts: 4976
- Thank you received: 1373
21 Nov 2016 12:39 #83064
by Todd Zuercher
Replied by Todd Zuercher on topic Syncing hardware and software switches
There already are components for doing this.
linuxcnc.org/docs/ja/html/man/man9/oneshot.9.html
and
linuxcnc.org/docs/html/man/man9/edge.9.html
linuxcnc.org/docs/ja/html/man/man9/oneshot.9.html
and
linuxcnc.org/docs/html/man/man9/edge.9.html
Please Log in or Create an account to join the conversation.
22 Nov 2016 17:24 #83135
by an92626
Replied by an92626 on topic Syncing hardware and software switches
Thanks for the help. I implemented the oneshot function using the following code and it worked. I was able to detect when halui.machine-is-on went from false to true and power-on-soft would cycle to true for .25 seconds which enabled the machine. Now that the software and hardware buttons enable the machine, I want the software button to disable it when halui.machine-is-on goes from true to false.
How would I generate a momentary signal (power-off-soft) that goes true when halui.machine-is-on goes from true to false?
I tried using the oneshot.0.out-not but that did not seem to work. I also tried several combinations of using not.0 but here again I was missing something. I still want power-off-soft to normally be false, and only go true for 0.25 seconds when halui.machine-is-on goes from false to true. should I use a copy of my existing code and apply the not to halui.machine-is-on? If oneshot.0.out-not is not the correct approach, then I probably need to negate something somewhere.
Thanks.
One more question: I go to the description for oneshot using the posted link, but where in the documentation is this buried so I can see similar documentation for other functions?
#
Toggle Machine Power On (Yellow)
# Defines the actions when the machine is powered on from the software key, F2, or yellow
# hardware panel button
# if yellow hardware panel switch is pressed (input-20), enable a signal and
# toggle power on software button
net power-on-hard hm2_5i25.0.7i77.0.0.input-20
net power-on-hard halui.machine.on
# create a signal that if Machine Power Software Button is toggled on
net machine-is-on => oneshot.0.in
setp oneshot.0.width 0.25
net power-on-soft oneshot.0.out
# use OR logic to cycle reset relay (output-05) and mechanical reset button's LED (output-10)
# if either a hardware or software "power on" event occurs
net power-on-hard or2.0.in0
net power-on-soft or2.0.in1
net power-on or2.0.out => hm2_5i25.0.7i77.0.0.output-05 hm2_5i25.0.7i77.0.0.output-10
#
done
Toggle Machine Power On
How would I generate a momentary signal (power-off-soft) that goes true when halui.machine-is-on goes from true to false?
I tried using the oneshot.0.out-not but that did not seem to work. I also tried several combinations of using not.0 but here again I was missing something. I still want power-off-soft to normally be false, and only go true for 0.25 seconds when halui.machine-is-on goes from false to true. should I use a copy of my existing code and apply the not to halui.machine-is-on? If oneshot.0.out-not is not the correct approach, then I probably need to negate something somewhere.
Thanks.
One more question: I go to the description for oneshot using the posted link, but where in the documentation is this buried so I can see similar documentation for other functions?
#
Toggle Machine Power On (Yellow)
# Defines the actions when the machine is powered on from the software key, F2, or yellow
# hardware panel button
# if yellow hardware panel switch is pressed (input-20), enable a signal and
# toggle power on software button
net power-on-hard hm2_5i25.0.7i77.0.0.input-20
net power-on-hard halui.machine.on
# create a signal that if Machine Power Software Button is toggled on
net machine-is-on => oneshot.0.in
setp oneshot.0.width 0.25
net power-on-soft oneshot.0.out
# use OR logic to cycle reset relay (output-05) and mechanical reset button's LED (output-10)
# if either a hardware or software "power on" event occurs
net power-on-hard or2.0.in0
net power-on-soft or2.0.in1
net power-on or2.0.out => hm2_5i25.0.7i77.0.0.output-05 hm2_5i25.0.7i77.0.0.output-10
#
done
Toggle Machine Power On
Please Log in or Create an account to join the conversation.
22 Nov 2016 17:40 #83138
by andypugh
Replied by andypugh on topic Syncing hardware and software switches
All the HAL components are listed on this page:
linuxcnc.org/docs/2.7/html/
In the "Man Pages" section.
I still have a feeling that toggle2nist is what you want.
linuxcnc.org/docs/2.7/html/
In the "Man Pages" section.
I still have a feeling that toggle2nist is what you want.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Offline
- Platinum Member
-
Less
More
- Posts: 4976
- Thank you received: 1373
22 Nov 2016 17:43 - 22 Nov 2016 17:45 #83139
by Todd Zuercher
Replied by Todd Zuercher on topic Syncing hardware and software switches
On a system with Linuxcnc with documentation installed, from the command line type man edge (or oneshot). Generally though I just google what ever I want to look up.
The Edge component I linked to above can send a pulse when a signal changes from true to false (or false to true your choice).
The Edge component I linked to above can send a pulse when a signal changes from true to false (or false to true your choice).
Last edit: 22 Nov 2016 17:45 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
Time to create page: 0.146 seconds