Timer and other issues

Hey everyone, I have my project mostly complete but I am having a couple of issues. What I made is a laser safety switch. I do super detailed laser engravings but they take about 5-10 hours to run. The code is streamed (there are up to 5 million lines of code) if there are any hiccups, the laser stops and continues to burn at whatever power it was at when it locked. It has only happened a couple of times but that is too many. Even with a camera can’t watch it constantly. So I have designed this laser safety system.

The way this works is

I will start the engraving.

I will flip the power on to the Arduino safety system.

It looks for constant movement with a pir motion (laser inside of a 2’x3’ box with windows)

IF no movement for 6 secondsè Alarm Triggered

It will set off a buzzer

Turn on an alarm led

And will flash a pair of relays which will turn off the power to the entire laser system. Relays doing the equivalent of pressing the power button.

I have a reset pushbutton to start the monitoring again without having to power it down and back up.

Here are the issues I am having.

1st- Timer 2 once I hit the reset button it sits at 0.0 and won’t start counting again. Timer 2 resets the flip-in-times so the relays are able to be triggered again. Even on loop

2nd- When I turn the power on the relays fire. I know this is probably a wiring issue (saw something about adding a pull up or down resistor, I just don’t know which). I am using the Arduino dual relay shield.

Does this do what you want?

Flip-flop at the bottom defaults to off & we want on, so I negated output for relay. If alarm is triggered, it disables motion sensor so it doesn’t turn back on when you reach in to see what is going on. Reset button will return to power-on state.

Rather than set/check timers, I just start a delay that will fire after 6 seconds. If motion is detected, the delay will restart.

If you want relays to turn on before this is powered on, you could probably add a resistor to +V to the pin so it gets pulled high until arduino pulls it low when it alarms.

Sorry for the delay, I hurt my back and have been down. I will have to add my timer 2 before the relay in your diagram. My relay is off and when the alarm goes of it closes for only 0.7 seconds. Basically I opened a smart plug, soldered a pair of wires to the power button. Works perfect and I can turn it off with alexa. Relay is a dry contact. I will try it here today.

What does the defer do in the circuit?

Defer causes a slight pause, but it is needed whenever a loop is created to help XOD determine order of execution. Since EN bus loops back to the top of the program, a defer is needed.

Actually looking at the code, it won’t work. I am looking for no motion for 6 seconds. The motion detector may flip back and fourth between true and false. Once it is false for 6 continuous seconds it fires the alarm and can’t be reset except by reset button.

The way it is made it’s looking for true, even if it was false, it won’t work. It will trigger on first false, wait 6 seconds, then fire even if it was only false for less than a second. That’s why I had the timer.

My example resets the timer every time it detects motion. I guess this could be a problem if it stays positive for 6 seconds…we could use motion=true to open a gate to allow continuous pulse to keep resetting timer to resolve that issue.

I don’t really understand how it works but it does. The only issue is the relay. I just need the relay (normally false/off) to turn true (on) for just under a second, only 1 time once the alarm triggers. The only way I know how to do it is my original way with a flip-in-times. I was trying to come up with another way.

Use a delay node. pulse-on-true sends a pulse when input changes to true (alarm is triggered). delay-ACT is true for as long as timer is active, making the relay active for only that time.

image

So this will only run 1 time even though it continues to get positive pulses while the alarm is going off?

It will only run 1 time if the alarm turns on & stays on. If the “alarm” (button in this patch) is pulsing, then it will fire multiple times.