Author Topic: How to pick a transistor to switch a relay  (Read 3329 times)

0 Members and 1 Guest are viewing this topic.

Offline TomS_Topic starter

  • Frequent Contributor
  • **
  • Posts: 854
  • Country: gb
How to pick a transistor to switch a relay
« on: February 05, 2020, 03:45:04 pm »
Hi everyone.

Im working on a little project at the moment, a relay timer, which will connect and disconnect a battery from a solar charger during certain hours of the day. The reason for doing this is because the charger draws from the battery to power itself and provide load output for lights etc.

But I dont want the charger drawing from the battery - I just want it to be a charger. I suppose I could use a purpose built charger for this, but the ones I already have I got for free, and I felt like doing a little project anyway, so what the hey. :)

I now need to extend this a little bit and add a second relay, because according to the manual I should connect battery before solar so the charger detects and uses the appropriate charging voltage, and at the moment solar is hard wired and the battery is switched in later, so the second relay will allow me to sequence those connections correctly.

But my question. Im using a BC547 as a low side switch for the relay at present, simply because I have a stock of them. "It works fine" (for now?) but I wonder if there is a "better transistor" to use for this kind of application, and how do you go about finding/choosing it? i.e. what sort of parameters are you looking at to determine the suitability of a transistor for switching a relay.

Ive included a back EMF diode (something like a 1N4004 or thereabouts, also because I have a stock of them) next to the relay itself.

Thanks!
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 2217
  • Country: au
Re: How to pick a transistor to switch a relay
« Reply #1 on: February 06, 2020, 12:19:32 am »
You need to be concerned about the maximum current the transistor has to switch, its voltage rating, and power dissipation (related to saturation voltage). If the BC547 works OK, then the 2N2222A should work better as it's designed for switching. Please provide more info about the relay coil resistance and the voltage to the coil. Kind of working in the dark.
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: How to pick a transistor to switch a relay
« Reply #2 on: February 06, 2020, 12:38:02 am »
Ben Krasnow over on the Applied Science YouTube channel did a video that was pretty much about what you are asking about...

https://youtu.be/8DMZSxS-xVc
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: How to pick a transistor to switch a relay
« Reply #3 on: February 06, 2020, 12:44:22 am »
Read the datasheet for the relay and for any transistors you are considering. Look at the current drawn by the relay coil, the voltage you are using, the current available from whatever source is controlling the transistor, the saturation current and gain and go from there. Low voltage switching is a pretty rudimentary use of a transistor and any number of parts will perform suitably. Which one is "best" probably boils down to what you have on hand or can easily get at a reasonable price with specs that meet your requirements.
 

Offline DBecker

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: How to pick a transistor to switch a relay
« Reply #4 on: February 06, 2020, 01:28:53 am »
You need to be concerned about the maximum current the transistor has to switch, its voltage rating, and power dissipation (related to saturation voltage).

I would worry much more about the inductive "kick" of the relay than the simple parameters.  There are parts designed specifically for switching relay coils because of the challenges.

That said, this doesn't seem like an application that requires a power-hungry relay.  What voltage and current does the panel generate?
 

Offline TomS_Topic starter

  • Frequent Contributor
  • **
  • Posts: 854
  • Country: gb
Re: How to pick a transistor to switch a relay
« Reply #5 on: February 06, 2020, 05:24:57 pm »
Thanks for the replies so far. I will have to sit down and go through some of this in more detail.

The particular relay I am using is: https://uk.rs-online.com/web/p/non-latching-relays/5484223/

12V nominal operating voltage supplied by the load side of a charge controller connected to the solar panel, with the PIC running off 5V via a regulator from that supply.

My figurings so far:

12VDC at 160ohm means 75mA for the relay coil.

PIC IO pin can supply a maximum of 25mA, but I am using a 1K resistor, so I understand that to be 5mA supplied to the base of the transistor.

BC547 has a minimum gain of 110, so with the above I guess Im able to switch (comfortably) at least 500mA, which means Im very comfortably within that limit (maybe I could even increase my base resistor value?)

I guess I feel comfortable with the above, but its more the "analoguey bits" that I lack knowledge of, e.g. how inductance comes into play and how its effects would affect the transistor if it is not the correct type. The BC547 datasheet does say its ok for switching purposes, and I have a 1N4004 across the coil to help with back EMF, but I lack the knowledge to really work that all out properly.

Thanks again.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: How to pick a transistor to switch a relay
« Reply #6 on: February 06, 2020, 06:13:37 pm »
If you are worried, you could scope the emitter and see how high the voltage spikes when the relay turns off however I would expect the diode to largely prevent this.

This is one of those situations where any one of 100 different parts would likely work perfectly fine. If you had more specialized requirements then you would need to choose more carefully but controlling a 12V relay is a bit like propping open a door, it's a simple task and the exact characteristics of the doorstop are not particularly important.
 
The following users thanked this post: TomS_

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: How to pick a transistor to switch a relay
« Reply #7 on: February 06, 2020, 06:24:48 pm »
I think your design sounds fine as-is.

I wouldn't increase the size of the base resistor.  You may even want to make the base resistor a little smaller (~680 \$\Omega\$) since you will want to drive a fair amount of current into the base so that you can keep the collector-emitter voltage as low as possible.  (See attached.)  This will prevent the transistor from dissipating any more power than necessary.
 
The following users thanked this post: TomS_

Offline WattsThat

  • Frequent Contributor
  • **
  • Posts: 788
  • Country: us
Re: How to pick a transistor to switch a relay
« Reply #8 on: February 07, 2020, 05:47:24 am »
While some very good points have been made, I see different specs out there for BC547 based on who’s making it. What I see that causes concern on most datasheets is an absolute max collector current of 100ma (based on the Fairchild DS on Mouser). That’s not enough margin for me.

https://www.mouser.com/datasheet/2/149/BC547-190204.pdf

Another point worth making is that for non-linear applications, the hfe is irrelevant and you need to use the graphs for Vce at various base currents to arrive at the best case base current operating point.

While the doorstop analogy is appropriate in one-off hobby projects, when total power consumption really matters, a properly selected mosfet wins every time with lower on voltages without the wasted steady state base current.
 

Offline Circlotron

  • Super Contributor
  • ***
  • Posts: 3362
  • Country: au
Re: How to pick a transistor to switch a relay
« Reply #9 on: February 07, 2020, 06:01:40 am »
Next time, if you are still going to use a BJT rather than a mosfet, use a 2N2222 or similar as suggested. A switching transistor will have lower saturation voltage, need less base current, and switch faster. If you used one for audio, then noise and distortion would probably be not very exciting. This is where the BC547 is way better. Switching a relay is not a BC547's strong point, but generally it will work well enough, particularly for non-critical hobby stuff.
 
The following users thanked this post: TomS_

Offline johnkenyon

  • Regular Contributor
  • *
  • Posts: 123
  • Country: gb
Re: How to pick a transistor to switch a relay
« Reply #10 on: February 07, 2020, 10:38:39 am »
How to chose a relay driving transistor from your spares bin:

1) Characterise your load
What's the coil voltage?
What is coil rated current?

The OP has already stated: 12V 75mA

2) Characterise your selected part(s) - in this example I have a BC547, a 2N2222 and a big bag of BC337.
a) Get hold of the data sheet for the transistor, and look for the "Absolute Ratings" part
b) Look for the Collector Current (lc - that's 'eye'-'cee'). Is it sufficient to drive your relay? (BC547 - 100mA, 2N2222 - 800mA, BC337 - 800mA)
c) Look for the emitter-collector voltage (Vceo). Is it sufficient to withstand the voltage across the relay? (BC547 - 45V, 2N2222 - 30V , BC337 - 45V)

From this information:
All three transistors can handle the voltage (worst device 2N2222 @ 30v, +150% margin)

The BC547 can handle the current, but there isn't much margin. The 2N2222 and BC337 can both handle >x10 the expected current.
The relay may also draw a transient current when energising - that's when your safety margin becomes useful - more margin, the less likely that the transistor will fail prematurely.

The 2N2222 has a TO18 case, and the BC337 and BC547 have a TO92 case.

I would leave the BC547, and 2N2222 for another project, and use the BC337, with the following reasons

i) The BC547's low Ic sends it to the back of the queue
ii) The 2N2222's metal TO-18 case would be better used in case where a higher dissipation is required (i.e. linear operation rather than being driven into saturation)
iii) I have lots of BC337's because that's my jellybean part.

Note that this selection process should be carried out when you purchase your jellybean parts - there is a reason why I have a bag of BC337s.

So going back to the beginning, if I were the OP and only had a couple of BC147's in my spares box, I would order some BC337's (to the first price break) rather than 2N2222 solely on the higher Vceo rating (one for the project and the other 9/19/24 for the spares box)



 
The following users thanked this post: TomS_

Offline moffy

  • Super Contributor
  • ***
  • Posts: 2217
  • Country: au
Re: How to pick a transistor to switch a relay
« Reply #11 on: February 07, 2020, 11:40:36 am »
Just for accuracy, I think your data about the 2N2222a is a little out of date: Haven't seen a TO-18 metal case in a while, they're TO-92 like most others. The other specs seem a little off too: https://www.onsemi.com/pub/Collateral/P2N2222A-D.PDF
:)
« Last Edit: February 07, 2020, 12:00:59 pm by moffy »
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: gb
Re: How to pick a transistor to switch a relay
« Reply #12 on: February 07, 2020, 11:43:58 am »
While some very good points have been made, I see different specs out there for BC547 based on who’s making it. What I see that causes concern on most datasheets is an absolute max collector current of 100ma (based on the Fairchild DS on Mouser). That’s not enough margin for me.

https://www.mouser.com/datasheet/2/149/BC547-190204.pdf

I strongly suspect the Fairchild datasheet from Farnell showing 500mA max is incorrect.  Parts from every other manufacturer I've found, including the later Fairchild datasheet in your link shows 100mA.
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 2217
  • Country: au
Re: How to pick a transistor to switch a relay
« Reply #13 on: February 07, 2020, 12:00:17 pm »
While some very good points have been made, I see different specs out there for BC547 based on who’s making it. What I see that causes concern on most datasheets is an absolute max collector current of 100ma (based on the Fairchild DS on Mouser). That’s not enough margin for me.

https://www.mouser.com/datasheet/2/149/BC547-190204.pdf

I strongly suspect the Fairchild datasheet from Farnell showing 500mA max is incorrect.  Parts from every other manufacturer I've found, including the later Fairchild datasheet in your link shows 100mA.

Thanks for that. I thought the BC547 was 100ma until I looked at the Farnell data sheet, which said 500ma. The power rating on the Mouser sheet is 500mw, looks like they mistyped that into the current rating. Based on that I would stay away from the BC547 also.
 
The following users thanked this post: TomS_

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: How to pick a transistor to switch a relay
« Reply #14 on: February 07, 2020, 02:15:01 pm »
I routinely use MUN2211 for such things. Same as cheap as any other transistor, but less stuff to solder. Normal BJTs require 2 additional resistors and MOSFETs require at least one or they are susceptible to spontaneous turn-on due to noise if control lines are long.
I love the smell of FR4 in the morning!
 
The following users thanked this post: spudboy488

Offline TomS_Topic starter

  • Frequent Contributor
  • **
  • Posts: 854
  • Country: gb
Re: How to pick a transistor to switch a relay
« Reply #15 on: February 09, 2020, 04:40:21 pm »
Thanks everyone. Much to go over when I have some more time (something to do on the commute over the coming week, since I'll be stuck on a train instead of riding my motorbike as usual), but it would seem the general consensus at this point that I should ditch the BC547's and probably replace them with some BC337's.
 

Offline sam[PS]

  • Contributor
  • Posts: 46
  • Country: fr
Re: How to pick a transistor to switch a relay
« Reply #16 on: February 28, 2020, 05:08:32 am »
Might be off topic here but might not :

If you have more than one relay to drive on the same board consider using a ULN2003 or similar, it's not a transistor it's an ic, but it's special purpose for that application, it doesn't cost much, can drive up to 8 relay and need no other external component (even flyback diode is already in there)...

Just my 2cts...

 

Offline TomS_Topic starter

  • Frequent Contributor
  • **
  • Posts: 854
  • Country: gb
Re: How to pick a transistor to switch a relay
« Reply #17 on: March 01, 2020, 02:16:41 am »
Interesting idea.

I've only got to control two relays, so for now I reckon these transistors will do the trick.
 

Offline graybeard

  • Frequent Contributor
  • **
  • Posts: 443
  • Country: us
  • Consulting III-V RF/mixed signal/device engineer
    • Chris Grossman
Re: How to pick a transistor to switch a relay
« Reply #18 on: March 03, 2020, 01:27:49 am »
I have used an ULN2803A in many designs to drive relays.  It has the transient suppressor diodes built in.

http://www.ti.com/lit/ds/symlink/uln2803a.pdf


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf