I have been trying to learn about relays in conjunction with arduino.
I am starting to understand the premise behind using rectifier diodes to keep power from going back to the arduino.
Looking at this information....
they have a rectifier diode on the relay vcc in line..... should there ALSO be one on the signal in line?
I have seen several sketches like this and don't understand why they only put it on the vcc line and not the signal line
The diode there is to clamp the inductive kick when the relay is turned off, to keep it from generating a voltage spike. Note that some (many?) relay modules include this diode already.
The reason it's not used on the signal line is that on most relay modules, the signal line is connected to the base of a BJT transistor or the gate of a MOSFET, not directly to the relay coil, since most relay coils require too much current to be driven directly from a microcontroller anyway. Hence, the signal pin isn't exposed to the inductive load.
The diode provides a low impedance path for the inductor current to flow
along when the transistor switches off - the current through an inductor cannot
fall instantly, in fact the rate the current falls is proportional to the voltage the
inductor generates (inductors can generate 1000's of volts quite happily if you
switch them off really fast). The diode means the current falls quite slowly as
only a volt or so is involved, but without it the transistor would probably be
destroyed within microseconds.
Sorry, as with so many things published on the net, that "instructable" (well, it is in the same category) is thoroughly broken in a number of ways.
The series diode with the module is simply nonsense, it has nothing to do with "inductive kick-back" (the diode for which is already included in the relay module) and serves only to make the circuit less reliable than it already is.
The big concern is that the relay module is shown as being powered from the 5V line on the Arduino. This will probably work if the Arduino is powered by the USB line, but not if powered from Vin or the "barrel jack" as the on-board regulator is likely not to take too kindly to powering the relay as it switches on and off.
@ Paul__B , I know... for us newbs it is hard to figure out exactly which tutorials are legit and which are wrong. Since I had seen several examples along the same lines(generally) as that instructable, I assumed that was the proper approach.
Still learning.
Just wish I could find something geared towards my end result project.
I am going to have 4 solenoids(externally powered) hoping in the 12 volt range....might have to go up to 24.
Only 1 will ever be powered at a time(chosen randomly in code)...with a few seconds in between.
I have all the code working, now just trying to figure out the relay bit.
I have had a look at the circuit diagram. The diode is between the 5V out of Arduino and the relay gadget´s Vcc input. All it does is reducing the input (Vcc) voltage of your device by 0.7 volts (from 5V to 4.3V). I cannot see any reason for this if the device is specified for 5V or higher. Only if it was specified for 4.5 Volts this would make sense.
Usually the transistor, FET or in your case the Arduino output pin has to be protected by a freewheel or protection diode when connected directly to a relay. This is a diode in parallel (directly) with the relay. AS you have no acces to the relay here is nothing you can do. This product must have an internal protection diode.
The relay gadget requires just a HIGH or LOW signal and probably has a high impedance. Otherwise it would usually not work directly at an Arduino output pin.
The device would not have a separate IN pin if it was just a relay at the input side.. A relay requires only two pins.
And you better never connect a relay directly to an Arduino output pin.
In this circuit (your link) the diode does not make sense, because a relay will not give you a reverse voltage on the Vcc side, but on the other side. That is why it is called reverse voltage. And the other side of the relay in your gadget is connected to a transistor/FET internal to the device which must be protected internally. The relay that requires a protection diode is simply not visible to you.
And in this circuit the relay is not connected directly to your Arduino.
If you take the equation v = dI / dt, you can roughly calculate the voltage spike. For example, a relay that takes 50 mA that is switched off in 100uS would generate a 500v spike, way more than enough to fry a transistor, although this is probably more than you would get in real life, because of the resitance of the wire, capacitance, etc.