Relays interrupting program

So I have this relay board,, hooked up to my arduino mega. When I run the program without a load going through the relay everything works just as it should, but when I connect a load to the relay it runs fine for a few cycles and then things freeze when the relay actuates. I'm using the relay to actuate another coil that's on an air solenoid that operates on 120VAC and according to the multimeter it pulls about 1.12 amps.

Here's how it runs without anything connected to the relay:

When I connect the other coil to the relay the readouts display gibberish and the loop freezes

Any thoughts?

This is probably due to an inadequate power supply and/or poor circuit shielding, allowing transients from the AC circuit to get into the Arduino. How are you powering and switching the relay coil connected directly to the Arduino? A circuit diagram would help.

ah such a simple problem,

with so many potentials to go wrong.

as the previous contribute said, a circuit diagram would be good.

whats happening is the relay switching is giving a great kick to the power supplys, which is getting into the arduino,

are these relays opto isolated, if they were that would help.

Do the problems occur when the solenoid turns on, or when it turns off, or both?

The problem only occurs when the relay with a load on it is switched on, if I run the program without anything connected to the relays they switch on and off exactly as planned. I also discovered that if I run dc current through the relay it does just fine and that it’s only 120vac that disrupts the process. I’m working up a diagram for you guys but in the mean time here’s an explanation of what I have going on… The device is a simple stepper motor control for automating a rotary table for a small cnc mill (a true 4th axis is prohibitively expensive for what I’m using it on, I just need it to index a coupling for drilling holes) the program moves a stepper motor a specified number of turns when cued by a M code which also tells it to release a pneumatic brake via the first relay, it then sends a “finish” signal via the second relay which tells the machine to drill the next hole. Everything runs off a 24vdc switching power supply capable of 15 amps, I have a step down transformer which takes the 24 down to 9 for the arduino and the brake solenoid draws from the 120vac input going to the power supply. I have the power supply and the solenoid grounded to the enclosure which is also grounded through the outlet.

I forgot to mention that the relay board connected to the arduino is optically isolated and it has it's own power supply independent of the arduino.

dont know the answer, but a suggestion,

use a bettery to temporarily power the arduino and the inouts to the optos,

that way the arduino is totaly floating from therest of the circuit.

check that by with no power connected , checking the resistance from the arduimo earth to the real earth, their should be no contact.

then with a floating arduino see if the problme still happens.

if it dosn't, which is my guess, then its the power to the arduino that is glitching,

if it does still happen, than you either have one heck of a emp from the controls, or the optos are not working,