Button Toggle
- Project_Hopeless
- Topic Author
- Offline
- Elite Member
- Posts: 200
- Thank you received: 10
Is there a simple button toggle for a Mesa output using one or the other?
Please Log in or Create an account to join the conversation.
#
# Load realtime Components and their counts
loadrt and2 count= 4
loadrt not count= 4
loadrt or2 count= 2
loadrt toggle count= 1
#
# Add functions to threads
addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf not.0 servo-thread
addf not.1 servo-thread
addf not.2 servo-thread
addf not.3 servo-thread
addf or2.0 servo-thread
addf or2.1 servo-thread
addf toggle.0 servo-thread
#
# Set parameters
setp toggle.0.debounce 5
#
# Connect hal signals to hal component Pins
net gui.pb or2.1.in1
net halui.mc.is-on halui.machine.is-on not.2.in
net halui.mc.off and2.3.out halui.machine.off
net halui.mc.on and2.1.out halui.machine.on
net mc.pnl.pb or2.0.in0
net n.1 or2.0.out or2.1.in0
net n.2 toggle.0.in and2.0.in0 and2.3.in1 or2.1.out
net n.4 toggle.0.out not.0.in
net n.5 and2.2.in0 not.1.in not.0.out
net n.6 not.3.in not.2.out and2.1.in1
net n.7 and2.0.in1 not.1.out
net n.8 not.3.out and2.2.in1
net n.9 and2.0.out and2.1.in0
net n.10 and2.2.out and2.3.in0
net pendant.pb or2.0.in1
Attachments:
Please Log in or Create an account to join the conversation.
loadrt toggle count= 1
addf toggle.0 servo-thread
setp toggle.0.debounce 5.0
net input-togl toggle.0.in
net output-togld toggle.0.out
Please Log in or Create an account to join the conversation.
- Project_Hopeless
- Topic Author
- Offline
- Elite Member
- Posts: 200
- Thank you received: 10
I followed this guide.
Big John T. Toggle
So my version that works
loadrt toggle count=1
addf toggle.0 servo-thread
net flood-toggle toggle.0.in <= pyvcp.drive-disable
net flood-control toggle.0.out => hm2_7i96s.0.ssr.00.out-01
I don't understand how flood-toggle and flood-control are linked. Is there a simpler way to get button "drive-disable" to toggle ouput hm2_7i96s.0.ssr.00.out-01 ?
Please Log in or Create an account to join the conversation.
So, initially the flood is OFF when you press the pyvcp widget the flood will turn ON if you press the same pyvcp widget button the flood will turn OFF and so forth.
In nut shell one push button is used to turn on and off the flood valve.
This is probably the simplest way to turn an output ON/OFF with only one push button (ui or hardwired). If you use hardwired push button add 20 ms debounce.
Please Log in or Create an account to join the conversation.
- Project_Hopeless
- Topic Author
- Offline
- Elite Member
- Posts: 200
- Thank you received: 10
I re-wrote the HAL below and changed to "generic-1" and "generic-2" and it still works.
loadrt toggle count=1
addf toggle.0 servo-thread
net generic-1 toggle.0.in <= pyvcp.drive-disable
net generic-2 toggle.0.out => hm2_7i96s.0.ssr.00.out-01
I thought I could write it in one line like so.
pyvcp.drive-disable => toggle.0.out => hm2_7i96s.0.ssr.00.out-01
Trying to understand why "generic-1" and "generic-2" are necessary.
Please Log in or Create an account to join the conversation.
- tommylight
- Online
- Moderator
- Posts: 19188
- Thank you received: 6429
Those can be "mom" and "dad", it does not matter, they are signal names that you freely assign to connections between hal pinsTrying to understand why "generic-1" and "generic-2" are necessary.
net generic-1 toggle.0.in <= pyvcp.drive-disable
net generic-1 toggle.0.in
net generic-1 pyvcp.drive-disable
net generic-2 toggle.0.out => hm2_7i96s.0.ssr.00.out-01
net generic-2 toggle.0.out
net generic-2 hm2_7i96s.0.ssr.00.out-01
Think of generic-1 (or mom or dad or) as a bus bar, toggle.0.in is one of the wires and pyvcp.drive-disable is the other wire tied together at the bus bar.
Please Log in or Create an account to join the conversation.
Attachments:
Please Log in or Create an account to join the conversation.
- Project_Hopeless
- Topic Author
- Offline
- Elite Member
- Posts: 200
- Thank you received: 10
Thank-you for taking the time to draw it out. Its' more clear now!Benb post=311153 userid=20877It looks like you having problem distinguishing hal pin names from hal signal names. It's a common mistake by new linuxcnc hal users. further to Tom's explanation, I draw a block diagram, The dashed lines are your signal names generic-1 on the left and generic-2 on the right. If you connect them together you short circuit the input and output of the toggle component.
I'm a jack (novice) of all code master of none. HAL for some reason just ties me in knots!
Please Log in or Create an account to join the conversation.
If you look at the first block diagram to control halui machine on and off with one pushbutton. The reason the block diagram is complex because Hal which is real time program is communication with halui a user land non realtime program. The non realtime component timing is unpredictable and make RT comp communication with non realtime comp difficult It requires trial and error intuition and luck to get to two to talk consistently no matter the jitter of the controllers.
I which someone could convert Halui to run in real time memory.
Attachments:
Please Log in or Create an account to join the conversation.