[EXAMPLE] Latching Pushbutton Selector - Classic Ladder

More
17 Jan 2023 00:47 #262201 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?

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

More
17 Jan 2023 14:36 - 17 Jan 2023 14:40 #262237 by andypugh
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.

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.

More
17 Jan 2023 16:45 #262252 by spumco
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.
 
Attachments:

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

More
17 Jan 2023 17:04 #262254 by spumco
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.

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

More
18 Jan 2023 02:13 #262309 by spumco
Got it working in classic ladder, and I'll leave this as an example (hence the re-named thread title)
  • 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.
There's probably a more elegant way to accomplish this, as Andy indicated earlier, but I kinda needed to brush up on CL anyway.

HAL snippet
Warning: Spoiler!


MUX4 section
Warning: Spoiler!


Hope it helps someone.
(Moderators feel free to move this to CL or somewhere else if you think it's appropriate.)
 
Attachments:

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

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
18 Jan 2023 02:43 #262314 by tommylight
Changed the tittle for all posts.
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
Powered by Kunena Forum