Quantcast
Channel: The Raspberry Pi Hobbyist
Viewing all articles
Browse latest Browse all 60

Revision to Relay Circuit

$
0
0
I have used the relay circuit from my earlier post many times and I know that it works.  However, I have seen that circuit drawn with a 1KΩ resistor and also with a 10KΩ resistor and started to wonder why.   Since this blog is intended to help new hobbyist learn, I thought it would be good to share what I found out.  (Warning:  There is math involved )

After some thought and further research I made the following changes to the GPIO relay control circuit.  The current limiting resistor is now 10K and I will explain why in a moment.  Also, a 100KΩ resistor has been added.  This is recommended to ensure that the transistor turns off if the input is left open.  In my design, the input is always either high or low and is never open, so I am leaving this out of my interface.
The current limiting resistor must be sized to allow enough current to saturate the base of the transistor to guarantee that it switches.  Current too far above this level could damage the transistor.  Every transistor has an inherent property known as the common emitter current gain, commonly referred to as HFE.  The proper size for the resistor may be calculated using the following formula.
R = Supply Voltage / ( max A / HFE * 1.3 )
The supply voltage (from the GPIO pin) is 3.3V.  The HFE for a 2N2222 transistor is assumed to be at least 100.  The current draw on the relays that I use ranges between 30 and 50mA.  Plugging in the numbers for 30mA gives a result of R = 8461.  If 50mA is used, then R = 5076.  However, the HFE is very likely higher.  If we assume that it is 150, then the resistor value at 30mA becomes 12692.  This shows that a 10KΩ resistor is probably more appropriate for this configuration.

The bottom line is that any resistor between 1K and 10K should work OK.  I just felt that this issue should be addressed before any arguments start.


Viewing all articles
Browse latest Browse all 60

Trending Articles