[EXAMPLE] Latching Pushbutton Selector - Classic Ladder
- spumco
- Offline
- Platinum Member
Less
More
- Posts: 1813
- Thank you received: 733
17 Jan 2023 00:47 #262201
by spumco
[EXAMPLE] Latching Pushbutton Selector - Classic Ladder was created by spumco
So I'm trying to set up rapid override physical buttons and getting a little lost. Want one for 5%, one for 25%, and one to reset to 100%.
Buttons are momentary and my first attempts using a mux4 didn't work because as soon as I release a button the whole thing reverts to whatever value is in mux.N.in0
Can't set them up as basic toggles... I want each value persistant until one of the other buttons is pressed.
Do I need to set up something like a three-way toggle2nist chain where any two buttons will 'turn off' the third?
Or is this something better done in CL? I sort of think of each button as a holding relay and either of the other two can de-energize the relay coil. Those outputs could then go to a hal mux selector to set the RRO value (I think).
Thoughts?
Buttons are momentary and my first attempts using a mux4 didn't work because as soon as I release a button the whole thing reverts to whatever value is in mux.N.in0
Can't set them up as basic toggles... I want each value persistant until one of the other buttons is pressed.
Do I need to set up something like a three-way toggle2nist chain where any two buttons will 'turn off' the third?
Or is this something better done in CL? I sort of think of each button as a holding relay and either of the other two can de-energize the relay coil. Those outputs could then go to a hal mux selector to set the RRO value (I think).
Thoughts?
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23559
- Thank you received: 4858
17 Jan 2023 14:36 - 17 Jan 2023 14:40 #262237
by andypugh
Replied by andypugh on topic [EXAMPLE] Latching Pushbutton Selector - Classic Ladder
It might be possible to do it with a cunning arrangement of
linuxcnc.org/docs/stable/html/man/man9/flipflop.9.html
(With them resetting each other) but I can't quite figure out how.
I think it's a job for a simple custom comp.
See linuxcnc.org/docs/stable/html/hal/comp.html for more info on how to compile and install.[1]
[1] For future readers
linuxcnc.org/docs/stable/html/man/man9/flipflop.9.html
(With them resetting each other) but I can't quite figure out how.
I think it's a job for a simple custom comp.
component multilatch;
pin in bit button-##[32:personality];
pin in float value-##[32:personality];
pin out float output = 100; // Put the starting default value here
license GPL2+;
author andypugh;
;;
int i;
for (i=0; i < personality; i++){
if (button(i)) output = value(i);
}
See linuxcnc.org/docs/stable/html/hal/comp.html for more info on how to compile and install.[1]
[1] For future readers
Last edit: 17 Jan 2023 14:40 by andypugh.
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
Less
More
- Posts: 1813
- Thank you received: 733
17 Jan 2023 16:45 #262252
by spumco
Replied by spumco on topic [EXAMPLE] Latching Pushbutton Selector - Classic Ladder
Thanks Andy.
I had a think about it and realized a three-way latching circuit in Ladder should work nicely.
Rough diagram:
The values are managed by a mux4. sel0 & sel1 are netted to the ladder outputs. If neither the 20% or 5% are on/true, it defaults to mux4.in0 = 100
I'll have go at it tonight and see how it works.
I had a think about it and realized a three-way latching circuit in Ladder should work nicely.
Rough diagram:
The values are managed by a mux4. sel0 & sel1 are netted to the ladder outputs. If neither the 20% or 5% are on/true, it defaults to mux4.in0 = 100
I'll have go at it tonight and see how it works.
Attachments:
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
Less
More
- Posts: 1813
- Thank you received: 733
17 Jan 2023 17:04 #262254
by spumco
Replied by spumco on topic [EXAMPLE] Latching Pushbutton Selector - Classic Ladder
Brain wave...The override should default to 100% with no inputs, but the 100% LED won't light up until the button is pressed.
I think I might need to net the 100% ladder input to the button or a one-shot at machine-on to set the initial state.
I think I might need to net the 100% ladder input to the button or a one-shot at machine-on to set the initial state.
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
Less
More
- Posts: 1813
- Thank you received: 733
18 Jan 2023 02:13 #262309
by spumco
Replied by spumco on topic [EXAMPLE] Latching Pushbutton Selector - Classic Ladder
Got it working in classic ladder, and I'll leave this as an example (hence the re-named thread title)
HAL snippet
#RAPID OVERRIDE BUTTONS
net BTN-RRO-RESET => classicladder.0.in-10
net BTN-RRO-20 => classicladder.0.in-11
net BTN-RRO-5 => classicladder.0.in-12
net MACHINE-IS-ON => classicladder.0.in-13
net LED-RAPID-RESET <= classicladder.0.out-07
net RRO-OUT-20 <= classicladder.0.out-08
net LED-RAPID-20 <= classicladder.0.out-09
net RRO-OUT-5 <= classicladder.0.out-10
net LED-RAPID-5 <= classicladder.0.out-11
MUX4 section
#RAPID OVERRIDE BUTTONS
setp halui.rapid-override.direct-value true
setp mux4.rro.in0 100
setp mux4.rro.in1 20
setp mux4.rro.in2 5
setp halui.rapid-override.scale 1
net BTN-RRO-RESET => halui.rapid-override.reset
net RRO-OUT-20 => mux4.rro.sel0 #SIGNAL FROM CLASSIC LADDER
net RRO-OUT-5 => mux4.rro.sel1 #SIGNAL FROM CLASSIC LADDER
net RRO-S32-CONV <= mux4.rro.out
net RRO-S32-CONV => conv-float-s32.1.in
net RRO-VALUE <= conv-float-s32.1.out
net RRO-VALUE => halui.rapid-override.counts
net RRO-VALUE-OUT <= halui.rapid-override.value
Hope it helps someone.
(Moderators feel free to move this to CL or somewhere else if you think it's appropriate.)
- Explanation
- Momentary pushbutton array acting like a selector switch
- Result is an xor button array (exclusive-or)
- Combine with HAL mux component (mux2, mux4, etc) to output a set value to something for each button
- Function
- Push a button and the button's output latches high
- Push any other button and that button's output latches high, and all other outputs go low
- Usage
- The example is used in my case for a physical button rapid-override control. I wanted a 'Haas' type control, where there were dedicated buttons with specific RRO values (100%, 20%, and 5% in my case)
- The outputs are connected to a mux4 component, and the 20% and 5% outputs control the mux4.N.sel0 and mux4.N.sel1 selection.
- Values are set with the mux4 'in' pins. Because of the xor ladder output function, mux4.N.in3 can be left without a value as sel0 & sel1 can't be output at the same time.
- The float_s32_conv component is necessary in my case as RRO counts is s32, and the mux4 output is a float.
- Modification
- Example is for three buttons, but can be extended as far as you've got ladder inputs/outputs available
- Additional outputs can be tied to each output
- In the example, there are two HAL outputs per line - one controls the rapid-override value, and one illuminates an LED on the physical momentary button
- Optional
- Timer is a one-shot and is used to set the initial state of the first rung
- Triggered by halui.machine-is-on
- Without the timer the initial state won't be set until one of the buttons is pressed.
- Timer is a one-shot and is used to set the initial state of the first rung
HAL snippet
Warning: Spoiler!
#RAPID OVERRIDE BUTTONS
net BTN-RRO-RESET => classicladder.0.in-10
net BTN-RRO-20 => classicladder.0.in-11
net BTN-RRO-5 => classicladder.0.in-12
net MACHINE-IS-ON => classicladder.0.in-13
net LED-RAPID-RESET <= classicladder.0.out-07
net RRO-OUT-20 <= classicladder.0.out-08
net LED-RAPID-20 <= classicladder.0.out-09
net RRO-OUT-5 <= classicladder.0.out-10
net LED-RAPID-5 <= classicladder.0.out-11
MUX4 section
Warning: Spoiler!
#RAPID OVERRIDE BUTTONS
setp halui.rapid-override.direct-value true
setp mux4.rro.in0 100
setp mux4.rro.in1 20
setp mux4.rro.in2 5
setp halui.rapid-override.scale 1
net BTN-RRO-RESET => halui.rapid-override.reset
net RRO-OUT-20 => mux4.rro.sel0 #SIGNAL FROM CLASSIC LADDER
net RRO-OUT-5 => mux4.rro.sel1 #SIGNAL FROM CLASSIC LADDER
net RRO-S32-CONV <= mux4.rro.out
net RRO-S32-CONV => conv-float-s32.1.in
net RRO-VALUE <= conv-float-s32.1.out
net RRO-VALUE => halui.rapid-override.counts
net RRO-VALUE-OUT <= halui.rapid-override.value
Hope it helps someone.
(Moderators feel free to move this to CL or somewhere else if you think it's appropriate.)
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19409
- Thank you received: 6507
18 Jan 2023 02:43 #262314
by tommylight
Replied by tommylight on topic [EXAMPLE] Latching Pushbutton Selector - Classic Ladder
Changed the tittle for all posts.
Thank you.
Thank you.
The following user(s) said Thank You: spumco
Please Log in or Create an account to join the conversation.
Time to create page: 0.101 seconds