Control a relay with a transistor circuit - Resistor sizing?

Thread Starter

mjscott

Joined May 21, 2014
24
Disclaimer - I'm learning!

I need a 5V circuit which will control my relay. I've been trying to learn from the many examples on the net, but there are so many variations and almost none explain why/how they sized their components. Below is the 2-transistor circuit which makes the most sense to me, however I do not know how to determine the required sizes of R1, R2, and R3. The variable in my circuit is the thermistor, with a range of 5K to 72K. I would like the circuit to switch my relay ON when this thermistor hits 29K or greater. From the data sheet, my 5V relay coil has a resistance of 167ohms and a power rating of 150mW. I believe the transistors and diode are garden variety general purpose.

I would greatly appreciate a lesson in resistor selection/calculation for this circuit. Many thanks! Mike


Screenshot 2021-01-30 080628.png
 

Attachments

DickCappels

Joined Aug 21, 2008
10,153
Let's start with you telling us the current the relay needs or the resistance of the coil. Just to be complete, have you chosen a manufacturer for your transistors?

While at it, we need to know both the dark and illuminated resistance of the photoresistor when used in your application (don't give us the daylight resistance if you are going to use it with a light bulb or LED <= tell us what the illuminated resistance is when your light emitting device is illuminating it.
 

Thread Starter

mjscott

Joined May 21, 2014
24
Dick: my 5V relay coil has a resistance of 167ohms and a power rating of 150mW. You correctly identified the graphic in my circuit as a photoresistor, however the actual component used will be a thermistor. My circuit design app (CircuitLab) doesn't have a thermistor, so I chose the photoresistor since the behavior is the same (variable resistance based on a changing environmental factor). From the data sheet of the thermistor, the range will span 5K to 72K ohms (in my climate). I want to trigger my circuit and switch the relay ON when the thermistor hits 29K ohms (or higher). I hope that is clear. Thank you.

Max: thanks for the tip on a better choice of diode, but I would love to learn why the UF4007 is better. :)
 

Thread Starter

mjscott

Joined May 21, 2014
24
Max: I'm trying to interpret your comment. Are you saying that the UF4007 is a better choice because it doesn't need to be as robust or fast as the 1N4148? Or, did you typo in your explanation and mean to be speaking about the UF4007? :)
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
I prefer to keep a stock of the UF4007 as they cover many types of relays for this function, fast and higher current than the 1N4148.
When using them on relays, brakes, clutches, solenoids etc, 1 size often fits all where the BEMF is unknown.
Max.
 

Thread Starter

mjscott

Joined May 21, 2014
24
Thank you - I've updated my circuit to use the UF4007.
I hope a reader is able to assist with the resistor calculations - the main goal of this thread. I'm sure Ohms Law and voltage dividing is the key - I just don't know how to apply it. I'm assuming I work backwards from my relay coil needs, but this is where my experiences stops... I KNEW I should have taken Electronics back in school!!
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
I would also suggest looking into Mosfets in place of bipolar transistors etc, in the case in question, the impedance offered to the photo resistor will be much higher, using a Mosfet, it being a transconductance device.
The comparitor is a good idea also.
(LM311?)
Max.
 

Thread Starter

mjscott

Joined May 21, 2014
24
I agree that a comparator or mosfet would be a more precise component. In this case however, I'm trying to walk before I run, which is why I'm really hoping to learn how to correctly size resistors for my transistor-based circuit. Once I understand the process (and math), I suspect this will carry over if I need more precision with my 'turn on' point, and move to an IC-based circuit.
With thanks. Mike
 

DickCappels

Joined Aug 21, 2008
10,153
You can remove R2 and R3 and join the Collectors together to make a Darlington pair, and then the NTC will have 1.4V across it to turn on the transistors, .
That probably will work, but I am going to suggest that we use the schematic as found. It is not very good but we can work the resistor problems. Afterward if you want something practical, you should try a comparator solution.

To start Q2 needs to put 5 volts across RLY1 which you said is 167 ohms. That means that the current through RLY1 and Q1's collector-to-emitter will be 5V / 167 Ω = 29.9 = 30 ma.

This 30 ma is what your diode across RY1 needs to handle. If cost is a factor, then 1N4148 /1N914 /1N916 should do it. The UF4001 will be a few pennies more.

To make the collector-to-emitter voltage of Q2 as low as possible to assure the relay pulls in on a cold day (just and expression but current gain goes down when transistors get cold) you need to drive the base of Q2 with 3 ma. Why 3 ma? Because the current gain of the transistor will be all over the place as temperature changes, so we do this (Ib = Ic / 10) to make sure there is plenty of drive.

I am referring to the old Motorola (now On Semiconductor) 2N2222 datasheet (attached) because it is a more thorough datasheet than provided by many others. On the datasheet you can see that the typical transistor has plenty of gain to drive the 30 ma relay with the 3 ma stated above. It is always good to check.

The transistor will start to pull in the relay when the voltage divider made of R1 and then thermistor crosses about 1.2 volts and will be fully engaged at a little higher voltage. At this time the NTC will be 29 microamps and let's estimate that when the transistors are fully on with Q1 will need about 30 microamps to get 3 ma into the base of Q2 (using Figure 5 in the datasheet). Notice the huge difference in current gain as a function of temperature. In real life you would probably use a rheostat with series resistor instead of R1, and in REAL real life you would use that comparator.

Current through the thermistor will be about 1.2 volts/ 29k = 41 microamps.
The current through R1 is (5V - 1.2V) / 41 microamps + 3 microamps) = 44 microamps.

The resistance of R1 will be (very) approximately
Control a relay with a transistor circuit - Resistor sizing?
Reply
Unwatch



Thread Starter
mjscott
Joined May 22, 2014 17
Yesterday at 11:19 PM
Disclaimer - I'm learning!

I need a 5V circuit which will control my relay. I've been trying to learn from the many examples on the net, but there are so many variations and almost none explain why/how they sized their components. Below is the 2-transistor circuit which makes the most sense to me, however I do not know how to determine the required sizes of R1, R2, and R3. The variable in my circuit is the thermistor, with a range of 5K to 72K. I would like the circuit to switch my relay ON when this thermistor hits 29K or greater. From the data sheet, my 5V relay coil has a resistance of 167ohms and a power rating of 150mW. I believe the transistors and diode are garden variety general purpose.

I would greatly appreciate a lesson in resistor selection/calculation for this circuit. Many thanks! Mike


Screenshot 2021-01-30 080628.png


Attachments
Like Quote Reply
Select for moderation Report Edit Delete Spam IP Warn
[IMG align="left" alt="DickCappels"]https://forum.allaboutcircuits.com/data/avatars/m/27/27805.jpg?1604752454[/IMG]

DickCappels
Joined Aug 21, 2008 6,836
Yesterday at 11:49 PM
Let's start with you telling us the current the relay needs or the resistance of the coil. Just to be complete, have you chosen a manufacturer for your transistors?

While at it, we need to know both the dark and illuminated resistance of the photoresistor when used in your application (don't give us the daylight resistance if you are going to use it with a light bulb or LED <= tell us what the illuminated resistance is when your light emitting device is illuminating it.

+ -, + + -, + + - +, + + + - +, + + + - - + -, + + + - - - + - - + -, + + + + + - - + + - + - +
Quote Reply
Select for moderation Report Edit History Delete IP
[IMG align="left" alt="MaxHeadRoom"]https://forum.allaboutcircuits.com/data/avatars/m/212/212212.jpg?1374379731[/IMG]

MaxHeadRoom
Joined Jul 19, 2013 22,085
Yesterday at 11:59 PM
You would be better off with a UF4007 in place of the 1N4148.
Max.

"Imagination is more important than knowledge.
Knowledge is limited. Imagination encircles the world."
Albert Einstein
Like Quote Reply
Select for moderation Report Edit Delete IP Warn


Thread Starter
mjscott
Joined May 22, 2014 17
Today at 12:35 AM
Dick: my 5V relay coil has a resistance of 167ohms and a power rating of 150mW. You correctly identified the graphic in my circuit as a photoresistor, however the actual component used will be a thermistor. My circuit design app (CircuitLab) doesn't have a thermistor, so I chose the photoresistor since the behavior is the same (variable resistance based on a changing environmental factor). From the data sheet of the thermistor, the range will span 5K to 72K ohms (in my climate). I want to trigger my circuit and switch the relay ON when the thermistor hits 29K ohms (or higher). I hope that is clear. Thank you.

Max: thanks for the tip on a better choice of diode, but I would love to learn why the UF4007 is better. :)

Like Quote Reply
Select for moderation Report Edit Delete Spam IP Warn
[IMG align="left" alt="crutschow"]https://forum.allaboutcircuits.com/data/avatars/m/19/19451.jpg?1414634345[/IMG]

crutschow
Joined Mar 15, 2008 26,099
Today at 12:42 AM
MaxHeadRoom said:
You would be better off with a UF4007 in place of the 1N4148.
Max.
And why is that?
The 1N4148 has more than a sufficient rating to handle the momentary transient current when the relay is turned off, and the 1N4148 is faster.

Zapper -- Curmudgeon Elektroniker
--The important thing about having knowledge is knowing where it correctly applies.--
My circuit collection.
Like Quote Reply
Select for moderation Report Edit Delete IP Warn


Thread Starter
mjscott
Joined May 22, 2014 17
Today at 1:18 AM
Max: I'm trying to interpret your comment. Are you saying that the UF4007 is a better choice because it doesn't need to be as robust or fast as the 1N4148? Or, did you typo in your explanation and mean to be speaking about the UF4007? :)

Like Quote Reply
Select for moderation Report Edit Delete Spam IP Warn
[IMG align="left" alt="MaxHeadRoom"]https://forum.allaboutcircuits.com/data/avatars/m/212/212212.jpg?1374379731[/IMG]

MaxHeadRoom
Joined Jul 19, 2013 22,085
Today at 1:44 AM
I prefer to keep a stock of the UF4007 as they cover many types of relays for this function, fast and higher current than the 1N4148.
When using them on relays, brakes, clutches, solenoids etc, 1 size often fits all where the BEMF is unknown.
Max.

"Imagination is more important than knowledge.
Knowledge is limited. Imagination encircles the world."
Albert Einstein
Like Quote Reply
Select for moderation Report Edit Delete IP Warn


Thread Starter
mjscott
Joined May 22, 2014 17
Today at 2:32 AM
Thank you - I've updated my circuit to use the UF4007.
I hope a reader is able to assist with the resistor calculations - the main goal of this thread. I'm sure Ohms Law and voltage dividing is the key - I just don't know how to apply it. I'm assuming I work backwards from my relay coil needs, but this is where my experiences stops... I KNEW I should have taken Electronics back in school!!

Like Quote Reply
Select for moderation Report Edit Delete Spam IP Warn
[IMG align="left" alt="dl324"]https://forum.allaboutcircuits.com/data/avatars/m/264/264264.jpg?1431138158[/IMG]

dl324
Joined Mar 30, 2015 12,292
Today at 3:28 AM
mjscott said:
I would greatly appreciate a lesson in resistor selection/calculation for this circuit.
You'd get a more defined turn on point if you used a comparator.

Best Regards,
Dennis
Like Quote Reply
Select for moderation Report Edit History Delete IP Warn
[IMG align="left" alt="MaxHeadRoom"]https://forum.allaboutcircuits.com/data/avatars/m/212/212212.jpg?1374379731[/IMG]

MaxHeadRoom
Joined Jul 19, 2013 22,085
Today at 4:16 AM
I would also suggest looking into Mosfets in place of bipolar transistors etc, in the case in question, the impedance offered to the photo resistor will be much higher, using a Mosfet, it being a transconductance device.
The comparitor is a good idea also.
(LM311?)
Max.

"Imagination is more important than knowledge.
Knowledge is limited. Imagination encircles the world."
Albert Einstein
Like Quote Reply
Select for moderation Report Edit History Delete IP Warn


Thread Starter
mjscott
Joined May 22, 2014 17
Today at 10:24 AM
I agree that a comparator or mosfet would be a more precise component. In this case however, I'm trying to walk before I run, which is why I'm really hoping to learn how to correctly size resistors for my transistor-based circuit. Once I understand the process (and math), I suspect this will carry over if I need more precision with my 'turn on' point, and move to an IC-based circuit.
With thanks. Mike

Like Quote Reply
Select for moderation Report Edit Delete Spam IP Warn
[IMG align="left" alt="Dodgydave"]https://forum.allaboutcircuits.com/data/avatars/m/170/170203.jpg?1340441078[/IMG]

Dodgydave
Joined Jun 23, 2012 9,882
Today at 3:25 PM
You can remove R2 and R3 and join the Collectors together to make a Darlington pair, and then the NTC will have 1.4V across it to turn on the transistors, .

NECESSITY IS THE MOTHER OF INVENTION !
Like Quote Reply
Select for moderation Report Edit Delete IP Warn

[IMG align="left" alt="DickCappels"]https://forum.allaboutcircuits.com/data/avatars/m/27/27805.jpg?1604752454[/IMG]
You can remove R2 and R3 and join the Collectors together to make a Darlington pair, and then the NTC will have 1.4V across it to turn on the transistors, .
That probably will work, but I am going to suggest that we use the schematic as found. It is not very good but we can work the resistor problems. Afterward if you want something practical, you should try a comparator solution.

To start Q2 needs to put 5 volts across RLY1 which you said is 167 ohms. That means that the current through RLY1 and Q1's collector-to-emitter will be 5V / 167 Ω = 29.9 = 30 ma.

This 30 ma is what your diode across RY1 needs to handle. If cost is a factor, then 1N4148 /1N914 /1N916 should do it. The UF4001 will be a few pennies more.

To make the collector-to-emitter voltage of Q2 as low as possible to assure the relay pulls in on a cold day (just and expression but current gain goes down when transistors get cold) you need to drive the base of Q2 with 3 ma. Why 3 ma? Because the current gain of the transistor will be all over the place as temperature changes, so we do this (Ib = Ic / 10) to make sure there is plenty of drive.

I am referring to the old Motorola (now On Semiconductor) 2N2222 datasheet (attached) because it is a more thorough datasheet than provided by many others. On the datasheet you can see that the typical transistor has plenty of gain to drive the 30 ma relay with the 3 ma stated above. It is always good to check.

The transistor will start to pull in the relay when the voltage divider made of R1 and then thermistor crosses about 1.2 volts and will be fully engaged at a little higher voltage. At this time the NTC will be 29 microamps and let's estimate that when the transistors are fully on with Q1 will need about 30 microamps to get 3 ma into the base of Q2 (using Figure 5 in the datasheet). Notice the huge difference in current gain as a function of temperature. In real life you would probably use a rheostat with series resistor instead of R1, and in REAL real life you would use that comparator.

Current through the thermistor will be about 1.2 volts/ 29k = 41 microamps.
The current through R1 is (5V - 1.2V) / 41 microamps + 3 microamps) = 44 microamps.

The value of R1 will need to be (very) approximately( 5V - 1.2V) / 44 microamps = 86k.

Now what about R2? That is selected to limit the maximum current into base of Q2 which we said will need to get
up to 3 milliamps in base drive. Making the assumptions that the base of Q2 is at 0.6 volts, Q1 saturates at lower than 1 volt and remembering the power supply is 5 volts we can say that there is more than 5 volts -1.6 volts =3.4 volts across R3 when Q2 is fully on, and to get 3 milliamps from 3.4 volts you need a resistor of 3.4 V /3 milliamps = 1.1 k ohms. Use 1.0K

The last value is that of R3 which should be low enough to keep the collector cutoff leakage currents from Q1 and Q2 from generating more than a few hundred millivolts - say 300 millivolts as an example. We have about 20 nanoamps at 25° C but let's assume the junctions of the transistors run at 80° C (In the attic on a hot day) and for silicon transistors the collector cutoff current about every 6 degrees. (80° -25°) / 6° so the cutoff current doubles 9 times or is multiplied by 2^9 or 512. Our 20 nano amps has become 20 nano amps x 512 = 10.24 microamps. To keep the base of Q2 below 0.6 volts (and thus the transistor off) the value of R3 needs to be less than 0.6 volts / 10.24 miicroamps = 58k. Use R3 = 27k to be safe.

As you can see I made some simplifying assumptions to get to the answers. Others undoubtedly made different assumptions. In real life, I would not use this circuit but would instead use the comparator such as half of an LM339 in place of transistors.

Looking forward to seeing your simulation results.








Attach files
You May Also Like
 

Attachments

Top