Arduino Uno Freezes Intermittently

Hi,

Overview:

I have an Uno running a control box with a few simple inputs and outputs for a Rube Goldberg machine. It doesn’t sound important, but the machine is for a theater production and will be running 8 times a week for at least the next year. In a nutshell, the code receives a mechanical relay input signal (connecting ground to an input pullup pin) which signals the machine to start. There are 7 outputs to relays on a sain smart 8 channel opto-isolated relay module (all low signals) (link to relay module below). The arduino only powers the signal to the opto-isolator, not the actual relays. The relays themselves are powered from a regulated 5V, 3A power supply (the same that supplies power to the arduino). The relays control various components such as VFDs, pneumatic solenoids, and electronic latches. Everything is connected to the arduino with a screw terminal shield.

There is also one other input signal (a micro switch connecting ground to an input pullup pin) which lets the machine know once a specific operation within the machine has occurred. All the outputs are timed off of these 2 input signals (including a backup timer if the second signal isn’t received). They shut off after about 20 seconds until the machine is triggered again.

Problem:

Once during testing and now once after being installed (so probably less than 5% of the time), the code seems to freeze and not respond to any inputs or the timers inside the code. It’s very difficult to replicate the problem given it’s inconsistency and because the machine is now installed in another city. I’ve set up a breadboard emulating the inputs and outputs, but I can’t seem to be able to get the error to happen for me.

The one time it did happen during testing, I was unable to get anything to respond and had to end up disconnecting power. Once powered back on, everything worked normally. There are no while loops (only if statements) inside the code, so I can’t imagine how it could be getting stuck. It also only uses about 11% of the program storage space and 6% of the dynamic memory, so I wouldn’t think memory is an issue either. But it’s very possible that I’m missing something in the code that could be causing the problem. The code is attached. It’s pretty long, but any hints as to something that looks off would be helpful.

Potential Issue:

About my only guess is that maybe the problem is caused by the power supply being shared with the relay board. Since the arduino is powered right to the 5V pin (not through the internal regulator) could a spike or dip in the voltage from relays turning on an off cause an issue like this? The power supply is a Omron S8VK-G01505 switching 5V power supply (link below). It should be more than capable of powering everything, but maybe the relay’s impedance could affect the supply voltage. I just don’t know enough about it to know if this is reasonable. If so, I can put a separate power supply in for the arduino.

Thanks in advance for any help, and let me know if there’s more information I can provide.

8 Channel Relay Module
5V Power Supply

HL11-19-17.ino (11.4 KB)

Here are a couple pictures that didn’t attach the first time.

How old is the Uno? Is it really from Arduino.org (vs Arduino.cc?)

You might be getting noise on the Reset signal that makes the '328P think it is going into High Voltage programming mode, and then acting hung waiting for more programming inputs.
Later Arduino's added a diode from Reset (anode) to +5 (cathode) so that any spikes just absorbed on the 5V line. You may be seeing similar with high current switching in the control box.

I'm not 100% sure, but I believe they were ordered around March of 2016 from Sparkfun. I can't say if they've changed suppliers since then, but on one of the current data sheets, it does mention Arduino.cc. Here's a Link to the schematic Sparkfun has listed. Again, this is the current one they stock, so perhaps it changed since I bought it. I'm not sure what to look for to see if it has the diode you're talking about.

It is almost certainly an R3 as far as I can tell if that makes any difference.

If it would help, I could stagger how the VFDs turn on to try to decrease the high current switching. Right now 2 of them start at the same time. But it sounds like the easier solution would be to swap in a fresh Uno.

Thanks for you help.

I was looking at some pictures of the board a little closer, and it does have Arduino.org printed on it.