I have a following configuration: Arduino Mega2560, DHT22 digital temp sensor, ENC28J60 ethernet module (not shield), a 8 channel relay board, and two 12VDC car central locking servos controlled by the relays. The power source I decided to use, is a computer ATX power supply. At the first development I connected every hardware to the ATX PS: Arduino to 12V (yellow), DHT and relay board to the 5V of PS (red), the ENC28J60 was connected to the 3.3V of PS (orange), and the servo motors used the PS 12V as well.
Everything went fine until I started to move the servos (not just clicking the "empty" relays). Each servo motor eats 5.5 - 6 Amps of current, so I had to connect them to separate relays (One relay is for max 10A). When I tested it, suddenly the ethernet module stopped to communicate, I had to reset the Arduino to get it work again. I measured a 12V connector of the PS with a multimeter, and found when the servo motors are powered, the ~12V output is raised up near to ~13V. (I don't have scope to measure peaks)
So I decided to connect the Ethernet module to the 3.3V and GND of the Arduino. (I am not sure it can produce enough current to drive it properly) I connected the DHT to 5V and GND of the arduino as well. Now it is almost OK, but sometimes after servo movement, DHT tells the current temp is nan and remains in this state. I have to reset the Arduino to get the correct temp value again.
I am pretty sure the problem is the voltage change in the input voltages when a larger load is connected or disconnected to PS. How can I prevent this kind of changes and peaks? I think I could connect some capacitors to the input of every device, especially for DHT and Ethernet module. But what kind of those? Or any other Idea to protect?
Waiting for your help.
DeXTeR
p.s.: Sorry for the longer post, I tried to be as detailed as possible.
Sorry, but not detailed enough. Can you give a link to the servo motors ?
If a servo motor uses normally 5A, the start peak current might be a lot higher.
The problem is not only the voltage but also the electrical/inductive peak that causes a pulse in high impedance wires, like in the signal wire of the DHT22.
The Arduino Mega 2560 is capable to power the ENC28J60 more or less. It's not ideal, but it is possible.
Using 12V to power the Arduino board is also not ideal. The voltage regulator might get hot.
But using 12V as supply input and also powering the ENC28J60 is too much. Can you use a voltage regulator to make it 7V or so ?
All sensors should be powered by the Arduino board. The ground wires from the sensors should return to the GND of the Arduino board.
You could use a diode from the 12V into a capacitor and that to the Arduino. The capacitor can be 1000uF or more, that will power the Arduino during a voltage drop.
The current to the servo motors is also going to the ground wire. You have to know about ground currents and how to wire everything. It's not an easy subject.
To avoid an electric/inductive pulse, you could also use two power supplies. One for the Arduino and one for the Relays and servo motors. With an opto-coupler to the relais, they are no longer connected.
I assume that the DHT22 returns an invalid value if such a pulse occurs during communication. But it should be ready to be used again after some time (I remember something of about 2 seconds).
Caltoa: Well, the servo word maybe not correct, it is a DC motor what pulls or pushes a rod. I have these (the two wire ones).
So you recommend me to separate the DC input of the motors from all the other parts of the configuration? In this case I would power the relays from the same source as the Arduino and other parts. Then I don't need opto-coupler between Arduino and controlled relays. (I don't think the controlled end of a relay can affect the controlling voltage and current)
Yes, the sampling period of DHT22 is 2000ms, but if it goes into "faulted state", it won't return any more. I query the temperature in every 2 seconds, and it always returns with 0.0 or NaN (I am not sure). Reset the only thing what makes it work properly again. (I think the dht.setup(dhtPin) line in setup function restarts it) The same occurs when I power up the system. After power up, I always have to reset the Arduino to get the correct temp value.
About the input power of Arduino: can I use a voltage divider do divide the 12V down to 7V? In this case, only two resistors needed. (And a capacitor for stabilizing, but the diode is for what reason?)
Helium328PU: Yes, I'd like to use the ATX PSU to power as many devices as possible, it has many power lines. Anyway it is a Platinum MS 400ATX P4, I think it is a cheaper one. Caltoa mentioned sensors should powered by Arduino, but I want the others (relay, ENC28J60, and later an LCD keypad shield) powered directly from the PSU. It seems only I have to separate the motors.
You should not use voltage divider for providin 7V to arduino. You will need 0,5W resistors, or better 1W ones. They will dissipate a lot of heat, not so much effective way in this case.
Since you are using a ATX supply, you have nice clear 5V line. Use it to power Ethernet module and sensors. Arduino itself could be connected to 12V to Vin pin. Arduino itself without powering external peripherials could handle 12V through onboard regulator without problem.
BTW.: I am still thinking if you arent drawing too much current with DC motors while they start to move. The first implulse could load over 10 or more Amps per motor. I would be very helpfull to measure it via memory oscilloscope. Maybe try to add a bigger capacitors for output lines to prevent pulse voltage drop.
Computer power supplies aren't designed for large rapid load-variations like this (you may
be getting over-voltage pulses on the other rails, since they normally are derived from
the same transformer), best to get a separate supply for the motors and servos, best
to get one designed for motors or general loads.
In general issues with motors and servos are often cured by getting a separate supply...
Hi, in most computer power supplies, because as stated, they are not designed for large load changes, the 5V output is the only output that is properly regulated.
By this I mean 5V is maintained by using feedback in the switch mode power supply, the other outputs are just supplied off extra windings sharing the same transformer, and usually a simple linear regulator to get + or - 12V.
Some I have seen do not even have a regulator but are setup so that approx 12V is supplied at near the 5V max load. So as the 5V load goes up and down, so does the 12V outputs.
In a computer each device that uses the 12V supplies either regulates it or is tolerant to the fluctuations.
[soapbox] I have only found computer power supplies "realiable" when used in computers
When you look at how they are constructed quality wise, I shudder that they last as long as they do, built for a price and not too long a life. [/soapbox]
Thank you all the responses! So here is what I have learnt:
I need to use separate power supply for motor or servo movement. (It seems for any application what can generate "noise" in the input voltage).
Using some capacitors on the power input of devices is always a good idea to gain some protection against sudden voltage drops or peaks.
It is a good idea to feed the arduino connected devices with separate power supply becasue it cannot give larger currents, but in this case grounds needs to be connected. Except sensors. Sensors usually does not need large currents, so they can be connected to arduino power output.s (The Mega has 3 of 5V output, pins, they must have purpose)
For longer and safer usage, 7-9V for arduino input is better than 12V (or higher).
ATX PS is cheap, but far not the best. I think for develpoing purposes is good enogh for me, but If I finish a project, then I will purchase a separate PS.