Microprocessor-driven relay

Posted by on Jul 16, 2011 in Blog, Etc | No Comments

Problem: I have a 12VDC fan that needs to be switched on and off. It’s a pretty windy fan with an Endless Breeze label on it, claims to be 900CFM and uses 36Watts.

Problem: I’m using a microprocessor (PIC16F877A if you must know) to switch the fan on and off.

The fan needs about 3A to switch. The microprocessor isn’t capable of sourcing or sinking very much current, only about 25mA, which is not even close to what the fan needs.

Here’s a quick sketch of what the pin of the microprocessor connects to. Since the relay coil needs 400mW to energize, at 5V, that’s 80mA needed. Notice there is a flyback diode in my sketch. You always need that, otherwise when the relay switches off, current can come back into the circuit and let the magic smoke out of something.

Here’s a standard circuit of a BJT transistor switch:

Rc is the resistance of the relay coil (62ohms) so the current flowing through the coil will be 5V/62ohms = 80mA.
When you choose your transistor, there is a specification called hFE , which is the current gain of that particular transistor. I suppose a bigger gain is better, but I’m just going to use what I have lying around and hope it’s enough.
I have a 2924 NPN transistor, and the hFE is 100. Therefore, I need to have 0.8mA minimum to switch the relay coil. The microprocessor can easily do this, so I am happy. Rb maximum should be 6.25k (5V/0.8mA). If I go a little smaller, that will be OK too, since it would be good if there is extra current in case the hFE isn’t exactly 100.

Here’s the circuit. Email me if you have any questions!

Leave a Reply