moryoav:
- The relay board requires both external power to the JD-VCC and 5V power from the Arduino because the pumps require more amperage than the Arduino can supply, is this correct? If so, is it not enough to connect external power to the relay board? I don't quite understand why power also needs to come from the Arduino itself. I would think that the digital pins can just send HIGH/LOW to the relay and drive it with that.
- Is there any major difference between the two relay boards? I see the two types, the blue and the red, not sure what the difference is. For my project, should there be a preference?
a RELAY module, that is the board you buy with 1 or multiple relays and has an Opto-isolator chip or FET or some such.
the relay is most often the blue Songle cube.
a relay is made of a coil and contacts.
the coil is isolated from the contacts. so you can have 230v on the contacts and 5v on the coil
the coil needs power. allow about 100mA per relay.
to energize the coil, you need to have some sort of device, transistor or FET to use the low current output from the Arduino.
An optoisolator has a transistor as part of the output side, 100mA rating is common.
The input to the Opto is often exactly the same as an LED. something between 10 and 20mA. because the opto uses an LED inside and the light is the signal and how it isolates the input from the output.
When you signal the opto, the transistor changes state. The coil is then energized and the coil sucks in that 100mA in a rush. causing load on the power supply. This can often cause a dip in the voltage.
When the Arduino signals the relay to shut off, the coil then is de-energized, the magnetic field collapses and the energy is dumped back into the coil wiring causing a spike, as little as 20% over input voltage but possibly 3 times input voltage.
As you can see, there are two really bad things going on with the power that drives the coils. Things we never want to the Arudino to see.
To address the back EMF spike, we use a diode, so that high voltage is effectively eliminated.
We can use large caps on the input to handle the inrush, so that too can be eliminated.
We could add another cap on the Arduino input to allow for the transient dip in voltage when the coil is energized.
Most power supplies have large caps so the running of the pumps and the driving of the coils will not interfere with each other and one power supply could be used for both.
Remember, the motors are also coils. so will add more of the above.
Now, if you can create a power conditioner to handle both the dip and the spikes, the noise on the power supply, you may be able to use one power supply for everything.
if you used 12V motors and coils and a 12V to 5V power module, that module might be able to deliver 5v to the Arduino without all the noise.
It is for the reasons above that it is highly suggested that you use a different power supply for the Arduino than the one driving the coil and motors.
As for the power supply for the relay coils and motors, the need for separate power supplies not nearly as important.
Often we see 120 volt AC motors on the contacts
12 volt DC on the relays
5V on the Arduino
So each of the circuits would naturally have it's own power supply.
=====================
part 2
each Opto-isolator is like an LED, about 20mA.
8 channels x 20mA = 160mA total output power from the Arduino allowance is required.
If you power the Opto's with the relay board, and only bring the Opto signal line to ground with your Arduino, then you are not delivering power to the opto's, but sinking. The Arduino board can sink a bit more than it can source.
You need to do your due diligence in calculating loads on your board.
You can source on some pins and sink on others and stay on the safe side of power through your Arduino.