Thursday, March 13, 2014

Transistor Controlled Relay

Today I was having some problems with the temperature controller not sending information out to the serial port for viewing on the serial monitor in the Arduino IDE.  I don't know if I solved the problem but in the midst of trouble-shooting I decided to upgrade the system to using a transistor to control the switching of the relay.

Previously I was using a single digital IO pin to drive the relay coil directly.  By using a high enough series resistance I was able to get the coil current down to 36mA and despite the fact that the datasheet would not guarantee my relay would work under such a situation, it did. (The Arduino site says I should have been safe at 36mA, just below the 40mA absolute rating. Still, not a good place to be.)  The serial communication problems seemed to go away when I didn't plug the relay in and draw so much current so it seemed like a good idea to bite the bullet and use a transistor to drive the relay coil.  This would reduce the load on the digital IO pin and allow me to drive the relay coil with enough current to operate within the datasheet specifications.  Two birds, one stone.

The circuit I used is simple (and readily available):



And here's what it looks like all built up:


The blue connector on the bottom right is switched in and out by the relay directly above it.  In the picture it is wired into an outlet that the heating pad is plugged into. The header in the center bottom provides 5V and ground to the temperature sensor as well as running the output from that sensor back into an Arduino analog input. In the top center is the transistor used to drive the relay coil.  I used a header here as a socket so I could easily replace the transistor. This is was a good idea as the first transistor I tried was dead.

(I didn't bother trying to connect to that off-pitch header.  They seriously need to fix that.)

Building this "shield" seems to have helped with the serial communication bug but now I've got another problem.  Every time the relay closes or opens the temperature sensor output shifts.  I think I know what's going on here and I have an interesting solution.  Stay tuned for more details.

No comments:

Post a Comment