Switching relays sometimes returns to setup()

Hi everyone,

First time Arduino user here. Wrote the code for my project and hacked it together on a breadboard and it's working but with some inconsistencies.

General overview of the project:

Its an induction heater for small pieces of brass. The idea being that you put the brass in the induction coil and hit the "go" button. The Arduino fires a relay that starts up the induction heater. It holds for a couple of seconds, then turns the induction off while pretty much simultaneously (the next line of code) firing relay that triggers a solenoid, opening a trapdoor and drops the brass into water.

I have a pair of LEDs wired up, one that is on when the Arduino is waiting for the switch to be pressed, the other is on when the induction heater is on. During the setup(), I blink those LEDs back and forth a few times.

What I'm finding is that when it switches from the induction coil to the solenoid (switching one relay off and the other on), sometimes the Arduino "hiccups" and it goes back to the setup() line as indicated by the blinking LEDs.

So, basically the "correct" scenario is:

(wait for button to be pressed)

Run LED on
relay to turn on induction power supply
(hold for 2.5 seconds)
relay for induction supply off ****
relay for trapdoor solenoid on ****
(hold for 1 second)
relay for trapdoor solenoid off
(hold for 2 seconds
(go back to waiting for button to be pressed

The fault is happening between the lines with **** above. Sometimes the trapdoor solenoid works fine, sometimes it just twitches, and sometimes the whole thing locks up and then gets back to the setup() function.

The relay board is being driven from the Arduino (so, the coils on the relay depend on power from the Arduino board). The fault happens when the Arduino is on external power (9V walwart) and does NOT happen when it's powered through USB on the computer. So...that is making me think it's power supply related.

Any thoughts? I would like to avoid an external power supply for the relay board if I can. I was thinking of maybe adding a 50-100ms delay between the one relay turning off and the other turning on to give the power supply time to recuperate.

Thoughts?

Thanks in advance!

Dustin

Power Problems. Turning you relay on is causing a power glitch which Drops the Input voltage under specifications. In essence, the power glitch is turning the Arduino "off" and back on again.

Awesome, as expected.

Thoughts on a solution? Different power supply, separate power supply for relay boards, add a delay?

Thanks!

Made it home during lunch, added a 250ms delay between one relay off and the other on, and it's now 100% reliable. Didn't spend time to see how short of a delay can I get away with.

Thanks for the help jaBa!

Delta_G,

K, good to know. Any recommendations on a 5VDC power supply that plays nice with Arduino, or is pretty much anything OK?

And also, I assume I should tie the ground from that power supply to the ground on the Arduino Power section, correct?

Dustin

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks... Tom.. :slight_smile:

Tom,

Will do, really need to write it down anyways. I wired it all up using the schematic that's in my mind's eye, lol.

AFAIK the 5V supply through the USB port is not regulated on board, so it's basically a direct link from your computer to your relay and solenoid. So as long as your computer can handle the power supply, you're in business (do remember to put flyback diodes on your relay and solenoid or you may fry your Arduino).

The external 9V supply however goes through a regulator (that's why it has to be >6-7V) and that regulator may struggle to provide sufficient power and go in overload protection.

Solution: connect your relay and solenoid to a separate power supply (or a split from your power supply before the Arduino - e.g. a separate 5V regulator on your 9V supply that only supplies the relay/solenoid), not to the Arduino.

For your schematics, have a look at KiCAD. Awesome piece of software, and FOSS to boot. Also very helpful for designing PCBs including protoboards (just set your grid to 2.54mm).

thanks for the comments everyone. Quick update - just ordered a 5V power supply to run the relay board. Should work out pretty well I believe.

That was my theory behind why USB worked and the 9V regulated down to 5V on the Arduino didn't work.

Schematics - still making some changes to the circuit, I'll document when it's all done