Relay trigger help

First timer here so be gentle.

Ill try to make this as quick as possible, but heres what i got....

We installed a goal horn at a local ice arena and wanted an automatic button to play the horn, i thought hey this is a great time to dip my toes into the arduino world! Long story short, its working but not exactly how i want it to... Im an electrician by trade, so wiring relays and the such are completely within my grasp.

Heres how i have it setup. The horn itself is run off of compressed air, so there is an air solenoid to sound the horn. Due to distance i used a 120v AC solenoid. Im using a very simple code that when a momentary button is pressed it sounds the horn 3 times using a opto isolated relay to switch the 120v.

Heres the problem;
When the momentary button is depressed, it triggers the relay and it sounds the horn three times as it should. But sometimes when the relay finishes its cycle it triggers the solenoid to start its cycle again. im certain this is some kind of interference with the 120v circuit as the relay performs flawlessly when the 120v is not connected to the relay.

My question would be where to start?

Heres the code... and attached is the wiring diagram.

void setup()
{
pinMode(2, INPUT_PULLUP);
pinMode(10, OUTPUT);
}

void loop()
{
int pushed = digitalRead(2);

if (pushed == LOW) {
digitalWrite(10, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(10, LOW);
delay(500); // Wait for 500 millisecond(s)
digitalWrite(10, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(10, LOW);
delay(500); // Wait for 500 millisecond(s)
digitalWrite(10, HIGH);
delay(1300); // Wait for 1000 millisecond(s)
digitalWrite(10, LOW);
} else {
}
}

Thank you in advance!

  • We never recommend the Arduino 5V pin to power inductive loads; use a separate external 5V supply.

  • You might want to try a stronger pull-up resistor on the switch, try 1k.

  • You can add a piece of lockout code to prevent re-triggering, maybe 6 seconds.

  • We also advise people avoid using delay() and ask them to use a TIMER based on millis().

  • Also, you might look up how to use the State Machine technique in these kinds of situations.

Thank you for the reply, I will look into all of the suggestions!

Also in doing some research I found maybe adding a metal oxide varistor at the solenoid coil could help with the back emf? Sound fair?

Thanks!

Worth a try.

But for AC, a capacitor and resistor combination might be better.


This can also add some switch input filtering.

image

Ferrite beads are another solution.

image

Look into using a solid state relay. They even come with screw terminals!!!! 5Volts will turn is on, 0 volts will turn it off, a LED inside the box.

No load at all on the Arduino pin.

So tonight while I was at the rink I put a 1k resistor on the switch. It seemed to help but did not cure the problem. The self triggering was less frequent.

Question. How big/small can I go with the resistors? Maybe try a 470ohm next?

I ordered ferrite rings and a solid state relay to try tomorrow. The relay might not be large enough, rated at 2a for 120v. I have to check the coil and see what the amp draw is.

Thank you for the helpful suggestions.

Solid state relays DO NOT have coils. That is what solid state means in relation to relays. Oh, Are you referring to the solenoid valve?
If the solenoid is on for just a short time and that seems to be the case, the SSR will not heat enough with more than 2 A to be a problem. Heat kills, but your SSR may also have a heat sink. Some do, some don't.

I would try installing a larger relay with say a 24vac coil, mount this very close to the solenoid.
This should move the high volts away, use your current relay to drive the larger.

I meant the coil on the solenoid valve. The valve it self says 2w @110v, so the ssr should be fine.

In all honesty I’m thinking the problem is something unrelated to my system. I built a second setup at home and cannot replicate the problem. I intentionally inter tangled the 120v with the arduino circuits and cannot get it to not work lol it works perfect every time.

Where the button and arduino board is located is in the score box for the arena. There is equipment in there for the score board and audio system. Maybe the ferrite rings will help tomorrow? Also going to check the ground on the arenas 120v power :person_shrugging:t3:

… and I added a separate 5v power supply strictly for the relay.

could be a bad button.
curious, how long is the wire?

im in the bowling industry, lol, seen my share of rats nests of wires.

i pull allot of 220vac solenoids, every minute, every day.

but i dont pull 220 i pull 24, keep equipment at least a few feet away from machines.
no issues, but yes, reset buttons fail, wires can give bad connections and gremlins can easily be induced.

Swapped the button out already. My intial thought as well.

The 2 conductor wire from the button to the arduino is roughly 3-4 feet.

The 120v wiring from the relay to the solenoid is around 275'.

whenever I'm bowling it seems as though i get that lane that something continuously fails :slight_smile:

The 2 conductor wire for the button, should be shielded and definitely keep away from HV lines.
275' of 120v, driving allot of copper crazy.

switch this control line to be low volts, 24vac would reach and yes, industrial grade relay to control solenoid.

oh and no worries, bowling lanes break on people they know can fix them, you should be honored. :slight_smile:

one more thing, just thinking, if you don't need to play one directly after another add another delay to your sketch at the end so it sits there for say like 5 secs or so.
you got allot of electrons, take a bit to dissipate, if they have a way to go and hopefully not into your board.

good luck, have fun!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.