ARDUINO MAIN PAGE     Delicious Bookmark this on Delicious   Recommend to StumbleUpon

Relays... using them with microcontrollers

Beware The Diode

The following isn't too crude to follow, I hope?

It tries to show a relay (in green box), powered from a voltage source called "Vr". Current would flow from Vr, though the relay's coil (not, at this stage through the diode), down through the transistor, and finally to ground.

I said "would" flow.... it depends on the voltage coming from "Out", which is supposed to be a connection to the output of some other circuit. That could, for instance, be an output from an Arduino or other microprocessor.

Relay circuit for microprocessors

I'll try to get back to this, tell you more about choosing the transistor another time. For some small relays, you could just connect the "bottom" connector from the relay coil to the microprocessor output, and be done with the rest... IF "Vr" was being drawn from the Vcc of the processor, and if the relay was small enough that the current would be minimal.

Whatever you do, don't leave the diode out!

It's like this....

There's no problem when current first begins to flow through the coil. There's no problem as long as it continues to flow through the coil.

However: When the relay is "turned off", when the path to ground is "disconnected", a very brief, but very nasty event occurs.

There is, while current flows, an "electro-magnetic field" (EMF) around the coil. When the current ceases to flow, that field "collapses" into the coil....

... creating a burst of voltage in the coil, which can be quite high...

... and is in the opposite direction to the voltage which was present previously!!!

I've given that the dreadful typography in an attempt to get your attention. Without the diode, which we'll come to in a moment, it is as if you have connected some source of voltage to the output backwards. This is a Very Bad Idea.

Happily, all you need to do is connect a diode, as shown. It will short circuit the reverse EMF when it occurs. While the voltage is high, the charge behind it is not large, and the diode will "soak up" the brief attempt to damage your output.

I won't promise that all of that is exactly, technically right... but I will promise you that putting the diode in is a good idea! Put the diode as close to the coil as you can without unreasonable struggles.

Reverse EMF protection with small motors

The coil in a simple DC motor will do the same thing. If you are going to reverse the direction of the current through the motor to make it "go" "forwards" and "backwards", you will need to put the diode just "upstream" of the place where you reverse the connections to the motor from time to time.

Stepper motors will also need care taken, but these are often driven by dedicated circuits, which will contain the necessary diodes... but be sure your's does! Include diodes if you are driving servo coils directly.

So... Did you read this in time?

I hope this reached you before reverse EMFs damaged any of your microprocessors? Do please write in and tell me if bits were unclear, or you would like more help with optoisolators

   Search this site                 powered by FreeFind
Site Map    What's New    Search

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, Sheepdog Software (tm), download something, and circulate it for me? At least (please) send an 'I liked the parallel port use page, and I'm from (country/ state)' email? (No... I don't do spam.) Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Don't forget to check out the programs for controlling the state of the parallel port at my shareware site. There are two free programs there... one for toggling bits, the other for using the computer as a timer via the parallel port.

Here is how you can contact this page's editor.
Click here to go up to general page about electronics by editor of this page.
Click here to go up to general page about electronic projects by editor of this page.
Why does this page have a script that loads a tiny graphic? I have my web traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try it, check out eXTReMe's site. The Google panels and the search panel are also script based.

Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org

....... P a g e . . . E n d s .....