Control output from multiple inputs?

More
24 Nov 2023 05:02 #286382 by spumco
I've got a number of outputs I want to control from physical buttons as well as g-code.  Collet closer(s), mist, part-loader cylinders, etc.

I thought this would be a relatively simple exercise with some or2's, toggles, and motion.digital-outs...  But as I try to work out the logic I find myself going down in flames.

One of the likely causes is self-inflicted... I have one momentary button for each function and need some sort of toggle feature.

Example:
  • Secondary mist located on lathe tool-slide (normal M7 mist is fixed at the headstock).
  • Mist on/off from both a button and with an M-code (perhaps M107-on, M108-off).
  • M-code would be a simple bin/bash triggering motion.digital-out-NN.
Good: mist can be turned on from either source
Bad: the two sources will compete

If I connect the button and a digital-out signal to an or2 and then a toggle, if I turn the mist on with a button while a program is running, an M107 later in the program will turn it off - not what I want.

Same problem if the mist is turned on by M107 and I turn it off with a button mid-program.  An M108 later on will trigger the toggle and turn it on when the desire is to leave it off.

And if I use an xor2 to interlock the two inputs... it means I can't use the button mid-program to turn off the mist if it's already on from the M-code.

Thought about a toggle2nist, but there's no obvious pin to connect to the 'toggle2nist.N.is-on pin, nor am I perfectly clear how to work it out even if there was an is-on available.

Or am I going about this wrong way, and should be using Ladder or some other scheme?
 

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

More
24 Nov 2023 07:35 #286387 by Aciera
I have momentary push buttons on my machine panels say to toggle G90/G91, MDI/HAND or coolant. So basically the push button will toggle the state to the opposite of what it was.
IIRC it's like toggle2nist but with 'enable' and debounce.

For coolant my hal section looks like this:
#**********
# COOLANTS
#**********

#  --- Toggle M7 on/off ---
net machine-is-on                                           => paneltoggle.m7.enable
net m7-panel                <= hm2_7i76e.0.7i73.0.1.input-02-not                     => paneltoggle.m7.input
net m7-is-on                <= halui.mist.is-on             => paneltoggle.m7.status => hm2_7i76e.0.7i73.0.1.output-09
net m7-is-on                                                                         => hm2_7i76e.0.7i76.0.0.output-11
net m7-set                  <= paneltoggle.m7.set           => halui.mist.on
net m7-reset                <= paneltoggle.m7.reset         => halui.mist.off

#  --- Toggle M8 on/off ---
net machine-is-on                                           => paneltoggle.m8.enable
net m8-panel                <= hm2_7i76e.0.7i73.0.1.input-03-not                     => paneltoggle.m8.input
net m8-is-on                <= halui.flood.is-on            => paneltoggle.m8.status => hm2_7i76e.0.7i73.0.1.output-08
net m8-is-on                                                                         => hm2_7i76e.0.7i76.0.0.output-08
net m8-set                  <= paneltoggle.m8.set           => halui.flood.on
net m8-reset                <= paneltoggle.m8.reset         => halui.flood.off

Component is here:
 

File Attachment:

File Name: paneltoggle.comp
File Size:2 KB


Note that for this to work you need a source that tells the component what the current status of the function in question is which is sometimes, like for coolants, easily available as a hal pin. If it is not then you may have to use a helper component like this one I use to expose the state of G90/G91 as a hal pin:

Warning: Spoiler!


The relevant hal section:
#**************************************************************************************
# ----- Handle panel toggle buttons using Custom Python Component 'linuxcnc_status.py'
#**************************************************************************************

#  --- Toggle G90/G91 ---
net machine-is-on                                       => paneltoggle.g91.enable
net g91-panel               <= hm2_7i76e.0.7i76.0.0.input-23-not                       => paneltoggle.g91.input
net g91-led                 <= linuxcnc_status.g91      => paneltoggle.g91.status      => hm2_7i76e.0.7i73.0.1.output-14
net g91-set                 <= paneltoggle.g91.set      => halui.mdi-command-04
net g91-reset               <= paneltoggle.g91.reset    => halui.mdi-command-05


I've been using this for many years now but maybe there are better ways to do it.
Attachments:
The following user(s) said Thank You: spumco, Unlogic

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

More
24 Nov 2023 12:43 - 24 Nov 2023 12:44 #286395 by timo
Just because I started playing with it recently and I find nice to see what is going on. I suggest you look into Classic Ladder it is perfect for this type of input output things.

I like, that I can change it and see what happens very easy.
If I had understood earlier that it is relatively easy to setup, I would have given it more attention.


I found the video to be very efficient, explaining the first steps (the auto translation to English does a good enough job for the video to be usable)



Have fun, with the buttons!
Last edit: 24 Nov 2023 12:44 by timo.
The following user(s) said Thank You: spumco

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

More
24 Nov 2023 16:55 #286414 by spumco
Thanks to both of you.

I started re-watching Feral Engineer's Ladder series again before I noticed your replies.

I think I'll wind up with a combination of Ladder for some inputs, and @Aciera's comp for others.  Some functions need a simple flip-flop with some interlocks (collet closer), while others are a bit more complicated since I want to be able to trigger them while a program is running.
 

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

More
24 Nov 2023 19:49 - 24 Nov 2023 19:53 #286425 by beefy
I made myself a custom hal component with 3 inputs (0, 1, and 2) for something similar.
It ended up a combination of an OR gate and a toggle component.

Input 0 was a typical on/off input (for a typical on/off switch for example) so if say a switch/signal is on the output is always on, i.e. the other 2 inputs cannot turn off the output.
However, it input 0 is off, then inputs 1 and 2 can control the output.

Inputs 1 and 2 came from momentary inputs or pulses, just like what you get from a momentary push button.

Input 1 could turn the output on then input 2 could turn it off.
And visa versa, input 2 could turn the output on and input 1 could turn it off.
Or just basic operation, input 1 can turn the output on and off.
Or output 2 can turn the output on and off

I've attached the component if you can make use of it. 

 

File Attachment:

File Name: OR3toggle.comp
File Size:2 KB
Attachments:
Last edit: 24 Nov 2023 19:53 by beefy.
The following user(s) said Thank You: spumco

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

Time to create page: 0.081 seconds
Powered by Kunena Forum