External Power On/Off + Estop

More
12 Mar 2022 01:14 #236971 by re_relentlessly
Hello,

I am trying to get an external on/off button to work, and via this forum found enough information to get the basics working. But there is a small bug/glitch. I release the e-stop, and then press the power on/off button and power turns on, everything fine. I can then press the on/off button and everything turns off. But if I turn on the machine (via the power on/off physical button), estop the machine and then press the on/off button, there is a flicker of the machine turning on, before it goes back off. So somehow the estop triggering the off state if not being passed to the toggle that controls the button.

Any ideas how to get the estop signal to correctly set the toggle?

Linuxcnc 2.8.1 with mesa 7i76e (raspberry pi 4)

Main Hal snippets (this is only the relevant bits)
loadrt toggle count=1
loadrt toggle2nist count=1
addf toggle.0                 servo-thread
addf toggle2nist.0            servo-thread


# --- ESTOP-OUT ---
setp hm2_7i76e.0.gpio.008.is_output true
net machine-is-enabled  =>     hm2_7i76e.0.gpio.008.out
setp hm2_7i76e.0.gpio.008.invert_output true

# --- ESTOP-OUT ---
setp hm2_7i76e.0.gpio.009.is_output true
net machine-is-enabled  =>     hm2_7i76e.0.gpio.009.out
setp hm2_7i76e.0.gpio.009.invert_output true

# --- ESTOP-EXT ---
net estop-ext     <=  hm2_7i76e.0.7i76.0.0.input-04
# --- MACHINE-IS-ENABLED ---
net machine-is-enabled  =>     hm2_7i76e.0.7i76.0.0.output-07

# --- ONOFF ---
net external-machine-on toggle.0.in <= hm2_7i76e.0.7i76.0.0.input-21
net pwr-btn toggle2nist.0.in <= toggle.0.out
net tog-on toggle2nist.0.is-on <= halui.machine.is-on
net pwr-on halui.machine.on <= toggle2nist.0.on
net pwr-off halui.machine.off <= toggle2nist.0.off

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

More
12 Mar 2022 11:14 #236985 by chris@cnc
You don't need the toggle function.
# --- MACHINE-IS-ENABLED ---
net machine-is-enabled        <=  motion.motion-enabled
net machine-is-enabled   =>     hm2_7i76e.0.7i76.0.0.output-07     #power on safety relay for servo driver

# --- ESTOP-EXT ---
net estop-ext     <=  hm2_7i76e.0.7i76.0.0.input-04-not

#  ---estop signals---
net estop-out     <=  iocontrol.0.user-enable-out
net estop-ext     =>  iocontrol.0.emc-enable-in
should be enough. I attached my ini.hal for estop latch function example. 
Attachments:

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

More
12 Mar 2022 13:55 #236999 by tommylight
Not to burst any bubbles, but power should not be controlled by machine enable pin, it can be done by e-stop.
Enable is just for enabling the drives and other stuff.

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

More
12 Mar 2022 14:57 #237003 by re_relentlessly
Maybe I was not clear enough about my setup.

I have a physical latching estop and a physical momentary button (power on/off).
And by power on/off I mean this button "halui.machine.on" in the ui, that turns linux cnc on and off. I do not mean turning the power supply on and off.

So since my power on/off button is momentary, I don't see how I can make it work without a toggle.
The toggle works fine as configured in my post, but when I hit the estop the toggle state does not get updated. So you can then press the power on/off momentary button and for a brief second the machine tries to turn on before it notices that the estop is pressed and then it turns off as it should. This then causes the toggle's state to be messed up, because at this point if i release the estop the power on/off does not work until I press it in the linuxcnc ui and sync the states back up.

if feel like the following line is missing some companion line that reads the estop state
net tog-on toggle2nist.0.is-on <= halui.machine.is-on
something like
net tog-on toggle2nist.0.is-on <= estop-ext

I am attaching my full .hal just in case in helps
Attachments:

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

More
12 Mar 2022 16:49 #237006 by tommylight
Nice.
Have a look here, there are some examples there and in some of the included links that might help.
forum.linuxcnc.org/24-hal-components/321...ghts-red-amber-green
I am sure i did the same thing on a retrofit a while back that just worked, but can not recall exactly what i used as there were so many flip-flops and toggle and "and"/"or"/"xor"/"nand" etc components there that my head is spinning just from thinking about it.
Unfortunately the USB with that and all the other configs of retrofits i did decided to give up the ghosts.

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

More
12 Mar 2022 17:41 #237008 by BigJohnT
In the HAL Examples section
forum.linuxcnc.org/47-hal-examples/25861-external-e-stop
as well as one button toggles for run/pause etc.

Or you could use my 7i76e Configuration Tool .

JT

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

More
12 Mar 2022 17:59 #237012 by spumco
OP - Are you using the physical momentary power button to activate a holding contactor or relay coil? i.e. like an industrial 'reset' button for a two-step process to come out of e-stop?  (unlatch estop, then must press momentary reset to power on)

If so, I've got a working .hal set up for that and wiring diagram if you're interested.

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

More
12 Mar 2022 22:49 #237041 by rodw
Replied by rodw on topic External Power On/Off + Estop
My config is similar as I use an external safety relay to manage my estop
I have used estop-latch to reset the safety relay (turn it on)  in the past.
This time I used an external momentary switch as you describe.
The safety relay enables two relays in series (to give redundancy) and if they both enable, they send 24 volts to a Linuxcnc input to turn it on.
My drives have a physical estop input which should go true to disable them on an estop.
So I use a not component to invert the power on signal.

So here is what I ended up with. This is an ethercat setup so the pin names look a bit different.
loadrt not names=slave-off0,slave-off1,slave-off2
addf slave-off0 servo-thread
addf slave-off1 servo-thread
addf slave-off2 servo-thread

#Turn on machine
net emc-enable <= lcec.0.3.in-01
net emc-enable => iocontrol.0.emc-enable-in

#turn drives off on an estop, but our signal must be inverted with not
net emc-enable => slave-off0.in  
net emc-enable => slave-off1.in 
net emc-enable => slave-off2.in 
net slave-disable0 slave-off0.out => lcec.0.0.in-6 
net slave-disable1 slave-off1.out => lcec.0.1.in-6 
net slave-disable2 slave-off2.out => lcec.0.2.in-6 
 

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

More
13 Mar 2022 23:28 #237163 by re_relentlessly
Thank you everyone for your replies so far. They have been quite helpfull, even if i still have not fixed the problem.
@spumco : Physical momentary, but no coil or contactor

With my original posted snippet both the e-stop and the power on/off button work. But as I said, when I press the physical latching estop it does nothing to the momentary buttons toggle. When you press estop the toggle should get flipped to off. instead the momentaries toggle happily flips back and forth regardless of the estops position. This confuses things when you release the estop.

How do I force the momentary's toggle to off, when the estop is pressed?

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

More
14 Mar 2022 00:59 #237176 by spumco
This sounds like a problem with synchronizing the power button to the system, something I don't have an issue with on my machine but I've seen it mentioned in other threads.

i.e. you've got a toggle input to a function, and that function can be activated by another input.  When the second input (estop in your case) activates the function, the first input (momentary power) toggle gets out of sync.

I'm not an expert in HAL (or Lcnc for that matter), but it may be possible in Classic Ladder.  Perhaps creating a holding relay circuit in Ladder and getting rid of the toggle in HAL would do it without resorting to a physical re-wiring job.

The basic idea is that the momentary button will activate the "relay" coil, and the coil is held active (contacts closed) by the estop signal. When the estop signal is broken (pushed in), the relay coil deavtivates and the contacts open.  If you unlatch the estop coil nothing happens until you press the momentary.  Which is safer, by the way.

This should result in a virtual reset button like I described earlier.  Are you familiar with relay holding/latching circuits?
 

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

Time to create page: 0.094 seconds
Powered by Kunena Forum