I am working on a project where there is a 12 V relay. I am powering the arduino and the relay with a 12V SMPS based wall adapter.
The issue is whenever I switch on or turn off an electrical device or even a switch from the same board the arduino freezes up or restarts.
I have tried shielding the entire circuit. Tried powering it with a voltage regulator close to the arduino. Tried a transformer based power supply(which makes things worse). And just about anything I could think of, and now I am at wits end.
Powering the device with a battery is not an option as this circuit is supposed to be ON all the time.
What else can I do? Has anyone else faced a similar issue?
nilton61:
Do you have a free wheeling diode across the coil? If not that is probanly the reason
Yes, that's in place. IN4007. Moreover the device dosen't freeze up while operating relay. Only happens when an electrical device connected to the same power board is either switched ON or OFF.
A 4007 works fine. No reason to change that. Im starting to suspect that the relay coil is picking up some emi. Can you post a schematic?
Does this happen when the relay is on or off or both?
Use separate ground wires for everything, all terminating to a common point.
If the freeze-up still occurs,
Disconnect the AC?? load from the relay contacts and re-test your circuit.
If the problem goes away,
then it's EMI/RFI from the load at the relay contacts.
If the freeze-up still occurs,
Disconnect the base resistor?? from the transistor?? driving the relay coil. Use it as a load connected from the same Arduino output to ground.
If the problem goes away,
then it could be groung noise from the supply (perhaps a 470uF cap at the supply would help), it could be your relay driver circuit (where is it??), it could be proximity of the relay coil to the electronics.
If the freeze-up still occurs,
Disconnect the resistor.
...
Hmmm... if "ifs and buts" were candies and nuts... I think I should just ask if you could give us a connection diagram or schematic (as asked for while I was "slooowly" typing this)...
dlloyd:
Use separate ground wires for everything, all terminating to a common point.
If the freeze-up still occurs,
Disconnect the AC?? load from the relay contacts and re-test your circuit.
If the problem goes away,
then it's EMI/RFI from the load at the relay contacts.
If the freeze-up still occurs,
Disconnect the base resistor?? from the transistor?? driving the relay coil. Use it as a load connected from the same Arduino output to ground.
If the problem goes away,
then it could be groung noise from the supply (perhaps a 470uF cap at the supply would help), it could be your relay driver circuit (where is it??), it could be proximity of the relay coil to the electronics.
If the freeze-up still occurs,
Disconnect the resistor.
I am using the Vin from arduino to power the relay. Tried disconnecting the AC load from the relay but it does not help. Yet to disconnect the resistor from the transistor but a 4700uF cap is already in place. Know its an overkill but had it handy so used it.
Update: powering the circuit with a 9 V battery solves the issue but is not a solution for me as I need to power it from a wall outlet
There are quite a few things wrong with that circuit.
One of the worst, is the absurd suggestion that you connect the Arduino 5V line to an electrode in a tank of water. Whether or not you have a connection to mains ground, that is absolutely asking for trouble. The reference electrode - and the tank itself - should be deliberately grounded. That said, this is an excellent case for using the internal pull-ups in the Arduino not just because it saves resistors, but because you can switch them off at all times other than when the inputs are polled, to reduce electrolytic action on the electrodes. Even so, you probably should have 1k isolating resistors in series with the electrodes, and external protective diodes to ground and 5V on the chip inputs themselves.
The 100 ohm resistors R3 and R5 to the transistors are wrong - would overload the Arduino outputs - should be 470 (or more). R4 on the power indicator LED may a bit generous too - I find the power LED on the Arduino excessively bright (especially when there are more important LEDs to be observed).
The 5V buzzer should possibly have a diode across it as well.
R1 - 560 ohms dims the LED in the LCD display - it is not needed at all for full brightness as long as R8 or R9 on the LCD board is "101" - 100 ohms.
Now, as to the wiring (the original problem), check out this comment.
Update: powering the circuit with a 9 V battery solves the issue but is not a solution for me as I need to power it from a wall outlet
Powering the Arduino with 12V only leaves only 100-150mA available before thermal overload kicks in.
Powering the Arduino with 9V leaves much more current available.
Powering the Arduino with 7.5V leaves maximum current available.
This is the circuit I have now. No issues with the circuit when connected to a 9V battery. Works as its supposed to and perfectly stable.
If I power the same circuit with a 12V 1A smps power adapter it works as long as I don't operate any electrical device connected to the same electrical board. Have also checked for loose contacts in the board.
I am new to all these things. But what my common sense tells me is that the issue could be with the power adapter since it works fine with a battery. Could it be because the ac adapter is letting some kind of noise flow through the adapter as this only happens when a switch is turned on or off next to the power outlet. If my theory is correct how do i fix it? I have tried connecting a 4700uF cap to the power supply.
Paul__B:
R1 - 560 ohms dims the LED in the LCD display - it is not needed at all for full brightness as long as R8 or R9 on the LCD board is "101" - 100 ohms.
Care is needed here. Not all LCD board have current limiting resistors for the LED backlight. Some are just direct connections to the LED. If this is one of those boards, then some sort of current limit resistor is indeed needed. Eliminating it as suggested could burn out the backlight on any board that does not have a built in current limit resistor.
I think Paul__B hit the nail on the head when he said:
One of the worst, is the absurd suggestion that you connect the Arduino 5V line to an electrode in a tank of water. Whether or not you have a connection to mains ground, that is absolutely asking for trouble. The reference electrode - and the tank itself - should be deliberately grounded.
The 12V SMPS power supply is not truly fully isolated. There is some capacitance to the Neutral and Hot lines of your AC power.
Find a different way to measure liquid level. As Paul said, start with grounding the tank.
I prefer using capacitance to measure liquid levels. No galvanic corrosion or electrolytic corrosion, as no bare metal touches water.
polymorph:
Find a different way to measure liquid level. As Paul said, start with grounding the tank.
Precisely. The tank is likely already grounded. By connecting the 5V supply to the tank's contents, you are probably setting up a current loop through the ground. Things work on the battery because the battery is isolated from earth ground. But once you use the power supply, now you have a direct or capacitive connection to ground, and the 5V connection causes problems.
Simple test: simply disconnect any 5V supply leading to any tank probes, and see how it runs. Of course, the tank level measurement won't work, but does it still exhibit the reset/freeze issues?
I used to manage an arcade. I discovered that a few games had broken ground prongs when I touched two games at once. Even though the SMPS in them was isolated, there is enough capacitance to incoming AC power that the chassis then floated at about 60Vac (half of the incoming 120Vac) due to that parasitic capacitance in the transformer.
It loaded down to a lower voltage when I was touching it, but it was still enough current to tingle.
ShapeShifter:
Precisely. The tank is likely already grounded. By connecting the 5V supply to the tank's contents, you are probably setting up a current loop through the ground. Things work on the battery because the battery is isolated from earth ground. But once you use the power supply, now you have a direct or capacitive connection to ground, and the 5V connection causes problems.
Simple test: simply disconnect any 5V supply leading to any tank probes, and see how it runs. Of course, the tank level measurement won't work, but does it still exhibit the reset/freeze issues?
Tried disconnecting the 5V supply to tank. And the circuit still freezes up. So seems the way i am measuring the water level isn't the issue.
dlloyd:
Sankalp, See my very first comment in reply#4. Did you try this?
Yes tried this as well....
There is one more thing that I tried. tried running the arduino with everything else disconnected except the lcd. And guess what it still freezes up.