EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: redgear on September 07, 2020, 07:19:11 am

Title: How to choose a transistor?
Post by: redgear on September 07, 2020, 07:19:11 am
I need to pick a transistor to drive a 12v relay with a coil resistance of 160 and the current will be 75mA. Can I use a BC547B (http://www.farnell.com/datasheets/2284253.pdf) ? What are the things I should look at when choosing a transistor for driving a relay? Is it only the Ice?
Title: Re: How to choose a transistor?
Post by: Ian.M on September 07, 2020, 07:35:26 am
Usually for BJT switching applications you check max. VCEO and IC; and min. hFE, the latter to check you can provide enough base drive to get it into hard saturation if you cant meet the common 'forced beta' of ten (i.e. IB=10% of max. ILoad) rule of thumb.
Title: Re: How to choose a transistor?
Post by: Doctorandus_P on September 07, 2020, 07:37:36 am
For such a simple application almost any BJT will do.

maximum collector current is a limit, but most will do 100mA or more.
The transistor has to withstand the relay voltage when it's off, but this is also not problematic with 12V.
Some of the new MOSfet's are specifically made for only upto 6V, but I have not seen such low voltages for BJT's (But I have not looked either).


Then there is Hfe, the current amplification factor. There is a huge variety in this, and you have to ensure that your transistor gets enough base current.

But don't just ask. Get your breadboard and do some simple experiments.
For around EUR10 you can get an assortment box with several hundred transistors from Ali / Ebay / China and with around 20 different kinds of transistors. Such a box is perfect for all kind of experiments and you don't have to worry about damaging a few during your experiments.

https://html.duckduckgo.com/html?q=aliexpress+transistor+assortment+box (https://html.duckduckgo.com/html?q=aliexpress+transistor+assortment+box)

I even encourage you to damage a handful of transistors during such experiments. Try to (ab) use the transistors in several different ways, observe what happens. Such experiments are very quick and easy to do on a breadboard.
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 08:03:17 am
Usually for BJT switching applications you check max. VCEO and IC; and min. hFE, the latter to check you can provide enough base drive to get it into hard saturation if you cant meet the common 'forced beta' of ten (i.e. IB=10% of max. ILoad) rule of thumb.

Thank You.

For such a simple application almost any BJT will do.

maximum collector current is a limit, but most will do 100mA or more.
The transistor has to withstand the relay voltage when it's off, but this is also not problematic with 12V.
Some of the new MOSfet's are specifically made for only upto 6V, but I have not seen such low voltages for BJT's (But I have not looked either).


Then there is Hfe, the current amplification factor. There is a huge variety in this, and you have to ensure that your transistor gets enough base current.

But don't just ask. Get your breadboard and do some simple experiments.
For around EUR10 you can get an assortment box with several hundred transistors from Ali / Ebay / China and with around 20 different kinds of transistors. Such a box is perfect for all kind of experiments and you don't have to worry about damaging a few during your experiments.

https://html.duckduckgo.com/html?q=aliexpress+transistor+assortment+box (https://html.duckduckgo.com/html?q=aliexpress+transistor+assortment+box)

I even encourage you to damage a handful of transistors during such experiments. Try to (ab) use the transistors in several different ways, observe what happens. Such experiments are very quick and easy to do on a breadboard.
Thank you will try experimenting.

I have another question, while this can be a separate thread, I will see if I can get answers here.

How do I estimate the output current I need from a transformer? The transformer will power the said relay, ATTiny404 (http://ww1.microchip.com/downloads/en/DeviceDoc/00001572B.pdf) mcu, CAP1203 (http://ww1.microchip.com/downloads/en/devicedoc/50002687a.pdf) and a 7 Segment Display (https://www.vishay.com/docs/83180/tdcx10x0m.pdf). The 7 seg takes about 10mA per segment, does that meant the total current required will be 280mA(7*4*10) when all segments are on? Idk if my mcu can provide so much current, so I need a transistor there too. The mcu and touch IC won't consume much current. So my total current required will be 280mA+75mA+30mA, 380mA? Which means my transformer should be capable of supplying 550mA(380/0.7). Are the calculations correct?
Title: Re: How to choose a transistor?
Post by: Ian.M on September 07, 2020, 08:23:29 am
That gives you the min. acceptable DC supply current *IF* the 10mA per segment is the time averaged current when on, which may not be the case for a multiplexed display.

If you are colloquially (and incorrectly) referring to a complete SMPSU as a 'transformer', then yes, that DC supply current + an appropriate safety margin to improve reliability is what you need to know to specify the PSU.

If you are designing a linear PSU and want to know the min. required secondary current rating, it gets a lot more complex because the conversion ratio between mean DC output current and RMS secondary current depends on the rectifier topology and to a lesser extent the size of the reservoir capacitor(s).   For the commonest case of a bridge rectifier feeding a capacitor input load, the RMS secondary current is much higher than the DC load current.  Hammond Mfg (transformer division) recommends* the DC load current does not exceed 62% of the secondary's RMS current capability.

* See Hammond's Design Guide for Rectifier Use (http://www.hammondmfg.com/pdf/5c007.pdf).   They aren't pulling the numbers out of their corporate arse to up-sell you, as the various factors can be confirmed by SPICE simulation.  I highly recommend anyone interested in linear PSUs and other line frequency power transformer applications save a copy. 
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 08:50:47 am
That gives you the min. acceptable DC supply current *IF* the 10mA per segment is the time averaged current when on, which may not be the case for a multiplexed display.

If you are colloquially (and incorrectly) referring to a complete SMPSU as a 'transformer', then yes, that DC supply current + an appropriate safety margin to improve reliability is what you need to know to specify the PSU.

If you are designing a linear PSU and want to know the min. required secondary current rating, it gets a lot more complex because the conversion ratio between mean DC output current and RMS secondary current depends on the rectifier topology and to a lesser extent the size of the reservoir capacitor(s).   For the commonest case of a bridge rectifier feeding a capacitor input load, the RMS secondary current is much higher than the DC load current.  Hammond Mfg (transformer division) recommends* the DC load current does not exceed 62% of the secondary's RMS current capability.

* See Hammond's Design Guide for Rectifier Use (http://www.hammondmfg.com/pdf/5c007.pdf).   They aren't pulling the numbers out of their corporate arse to up-sell you, as the various factors can be confirmed by SPICE simulation.  I highly recommend anyone interested in linear PSUs and other line frequency power transformer applications save a copy.

Thank you for the link, I am designing a linear PSU and wanted to know how to calculate the secondary current rating of the transformer.
Title: Re: How to choose a transistor?
Post by: Ian.M on September 07, 2020, 09:07:40 am
Ooofff!!!  Calculating it properly without resorting to SPICE simulation, rules of thumb, or pre-calculated factors is *NASTY* and *DIFFICULT*.  If you want to jump down that rabbit hole, ask!
Title: Re: How to choose a transistor?
Post by: tggzzz on September 07, 2020, 09:11:54 am
I need to pick a transistor to drive a 12v relay with a coil resistance of 160 and the current will be 75mA. Can I use a BC547B (http://www.farnell.com/datasheets/2284253.pdf) ? What are the things I should look at when choosing a transistor for driving a relay? Is it only the Ice?

Don't forget the catch diode around the relay coil, optionally with a series resistor. A resistor implies increasing the transistors' minimum Vceo spec.
Title: Re: How to choose a transistor?
Post by: Zero999 on September 07, 2020, 10:08:18 am
I need to pick a transistor to drive a 12v relay with a coil resistance of 160 and the current will be 75mA. Can I use a BC547B (http://www.farnell.com/datasheets/2284253.pdf) ? What are the things I should look at when choosing a transistor for driving a relay? Is it only the Ice?
The BC547 is fine.

According to the data sheet, the transistor will be in the saturation region when IB > 120IC, so when IC = 75mA, you need 3.75mA of base drive. Assuming you're driving it from a 5V MCU output and according to the data sheet, the transistor's maximum base emitter voltage is 0.8V:

V = 5V
VBE = 0.8V
IB = 3.75×10-3
RB = (V - VBE)÷IB = (5 - 0.8)÷3.75×10-3 = 4.2÷3.75×10-3 = 1120 Ohm

The nearest standard resistor value is 1k1, but 1k is much more widely available and will do.
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 10:52:01 am
Ooofff!!!  Calculating it properly without resorting to SPICE simulation, rules of thumb, or pre-calculated factors is *NASTY* and *DIFFICULT*.  If you want to jump down that rabbit hole, ask!

Is there a tutorial online?

Don't forget the catch diode around the relay coil, optionally with a series resistor. A resistor implies increasing the transistors' minimum Vceo spec.

Is the attached circuit good?

The BC547 is fine.

According to the data sheet, the transistor will be in the saturation region when IB > 120IC, so when IC = 75mA, you need 3.75mA of base drive. Assuming you're driving it from a 5V MCU output and according to the data sheet, the transistor's maximum base emitter voltage is 0.8V:

V = 5V
VBE = 0.8V
IB = 3.75×10-3
RB = (V - VBE)÷IB = (5 - 0.8)÷3.75×10-3 = 4.2÷3.75×10-3 = 1120 Ohm

The nearest standard resistor value is 1k1, but 1k is much more widely available and will do.

Thank you. I put up a simple circuit. Please review.
Title: Re: How to choose a transistor?
Post by: Zero999 on September 07, 2020, 11:01:29 am
Ooofff!!!  Calculating it properly without resorting to SPICE simulation, rules of thumb, or pre-calculated factors is *NASTY* and *DIFFICULT*.  If you want to jump down that rabbit hole, ask!

Is there a tutorial online?

Don't forget the catch diode around the relay coil, optionally with a series resistor. A resistor implies increasing the transistors' minimum Vceo spec.

Is the attached circuit good?

The BC547 is fine.

According to the data sheet, the transistor will be in the saturation region when IB > 120IC, so when IC = 75mA, you need 3.75mA of base drive. Assuming you're driving it from a 5V MCU output and according to the data sheet, the transistor's maximum base emitter voltage is 0.8V:

V = 5V
VBE = 0.8V
IB = 3.75×10-3
RB = (V - VBE)÷IB = (5 - 0.8)÷3.75×10-3 = 4.2÷3.75×10-3 = 1120 Ohm

The nearest standard resistor value is 1k1, but 1k is much more widely available and will do.

Thank you. I put up a simple circuit. Please review.
Yes, that will work. If you connect the zener diode's anode to 0V, so it's across the transistor, then the 1N4148 is not needed.

What does the Schottky diode do? Is it for reverse polarity protection? If so, you need to make sure it will survive the short circuit current for long enough to blow the fuse.
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 11:13:32 am
Yes, that will work. If you connect the zener diode's anode to 0V, so it's across the transistor, then the 1N4148 is not needed.

I read a Application Note (https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=13C3264_AppNote&DocType=CS&DocLang=EN) from TE, they recommend both Zener and a diode. What should be the Zener's voltage rating?

Quote
What does the Schottky diode do? Is it for reverse polarity protection? If so, you need to make sure it will survive the short circuit current for long enough to blow the fuse.

The two connector before the relay connects to a microswitch, opening and closing the supply to the relays. It is to clamp the back emf when the switches open. How do I check it? I'm also not sure about the voltage rating of the diode. Can they be same as the coil voltage?

Thanks
Title: Re: How to choose a transistor?
Post by: tggzzz on September 07, 2020, 11:52:29 am
Don't forget the catch diode around the relay coil, optionally with a series resistor. A resistor implies increasing the transistors' minimum Vceo spec.

Is the attached circuit good?

Sorry, that is too drawn as too much of a tangled mess for me to understand what you are trying to do.

There are standard ways of drawing diagrams that emphasise the intended operation of a circuit - just as in software there are standard ways of indenting code to make it readable. The TI App note shows the relevant one in this case.
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 12:34:43 pm
Sorry, that is too drawn as too much of a tangled mess for me to understand what you are trying to do.

There are standard ways of drawing diagrams that emphasise the intended operation of a circuit - just as in software there are standard ways of indenting code to make it readable. The TI App note shows the relevant one in this case.

Neater version(?) attached.
Title: Re: How to choose a transistor?
Post by: Zero999 on September 07, 2020, 12:52:20 pm
Yes, that will work. If you connect the zener diode's anode to 0V, so it's across the transistor, then the 1N4148 is not needed.

I read a Application Note (https://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=13C3264_AppNote&DocType=CS&DocLang=EN) from TE, they recommend both Zener and a diode. What should be the Zener's voltage rating?
The diode is only needed if it isn't convenient to put it across the switching transistor i.e. the relay is in a separate enclosure. In your case, the switching transistor is easilly accessible, so only a zener diode is required across the transistor.

The higher the zener diode's voltage rating, the faster the coil will turn off. The minimum voltage rating of the zener, should be 10% above the power supply's maximum voltage and the maximum rating, 10% below the transistor's maximum rating.

Quote
Quote
What does the Schottky diode do? Is it for reverse polarity protection? If so, you need to make sure it will survive the short circuit current for long enough to blow the fuse.

The two connector before the relay connects to a microswitch, opening and closing the supply to the relays. It is to clamp the back emf when the switches open. How do I check it? I'm also not sure about the voltage rating of the diode. Can they be same as the coil voltage?

Thanks
You already have a back-EMF diode for the relay, so I don't see why you need another one.
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 01:03:38 pm
The diode is only needed if it isn't convenient to put it across the switching transistor i.e. the relay is in a separate enclosure. In your case, the switching transistor is easilly accessible, so only a zener diode is required across the transistor.

The higher the zener diode's voltage rating, the faster the coil will turn off. The minimum voltage rating of the zener, should be 10% above the power supply's maximum voltage and the maximum rating, 10% below the transistor's maximum rating.

Thanks. I will remove the 1N4148.

Quote
You already have a back-EMF diode for the relay, so I don't see why you need another one.
Sorry if it was stupid. Beginner here.
I was suggested that I add it in a different thread when driving the relay from a ULN2003A relay driver. It had inbuilt freewheel diodes as well. I will remove it if it is unnecessary.
Title: Re: How to choose a transistor?
Post by: Ian.M on September 07, 2020, 01:17:35 pm
You'd need to have been following Redgear's other thread (https://www.eevblog.com/forum/beginners/is-my-circuit-correct/) to know *WHY* I recommended that diode.  TLDR: the connector 'J? Microswitch' goes to a switch.  If it opens while the coil is energized, without the diode consider what happens to the poor MCU's pin that 'sees' the back-EMF from the relay coil with only a 10K resistor in series.  The relay coil was originally being driven by a ULN2003, so there weren't many options short of an extra diode.

However, now if the catch diode is *DIRECTLY* across the relay coil, the extra diode is redundant.  If you are using a catch diode + series resistor or zener for faster release when the transistor cuts off, you would need to keep it.
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 01:26:16 pm
You'd need to have been following Redgear's other thread (https://www.eevblog.com/forum/beginners/is-my-circuit-correct/) to know *WHY* I recommended that diode.  TLDR: the connector 'J? Microswitch' goes to a switch.  If it opens while the coil is energized, without the diode consider what happens to the poor MCU's pin that 'sees' the back-EMF from the relay coil with only a 10K resistor in series.  The relay coil was originally being driven by a ULN2003, so there weren't many options short of an extra diode.

However, now if the catch diode is *DIRECTLY* across the relay coil, the extra diode is redundant.  If you are using a catch diode + series resistor or zener for faster release when the transistor cuts off, you would need to keep it.

So I have two options now, either connect a diode directly across relay coils and remove the schottky diode or use a zener diode and leave the schottky diode undisturbed. Am i correct?
Title: Re: How to choose a transistor?
Post by: Ian.M on September 07, 2020, 01:41:59 pm
It might be better to clamp right at the MCU pin with a BAT54S or similar dual series Schottky diode, as then you can get rid of the power Schottky clamping node 'SW' and let your Zener clamp across the relay coil work effectively to speed up turnoff for both the case when the transistor cuts off and the case where the microswitch opens.
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 01:45:10 pm
It might be better to clamp right at the MCU pin with a BAT54S or similar dual series Schottky diode, as then you can get rid of the power Schottky clamping node 'SW' and let your Zener clamp across the relay coil work effectively to speed up turnoff for both the case when the transistor cuts off and the case where the microswitch opens.

Thank you. Never used them before. I will look for sample circuits.
Title: Re: How to choose a transistor?
Post by: Ian.M on September 07, 2020, 02:01:08 pm
Its quite easy.  They are two diodes in series in the same package with the middle connection brought out: Connect cathode to Vcc, Anode to ground and Common to the I/O you want to clamp.  The diodes are both reverse biased in normal operation, but one or the other becomes forward biased and clamps the pin voltage if anything tries to drive the pin past either supply rail.
Title: Re: How to choose a transistor?
Post by: redgear on September 07, 2020, 02:10:01 pm
Its quite easy.  They are two diodes in series in the same package with the middle connection brought out: Connect cathode to Vcc, Anode to ground and Common to the I/O you want to clamp.  The diodes are both reverse biased in normal operation, but one or the other becomes forward biased and clamps the pin voltage if anything tries to drive the pin past either supply rail.

That's cool... Thank you.
Title: Re: How to choose a transistor?
Post by: David Hess on September 07, 2020, 09:03:44 pm
I need to pick a transistor to drive a 12v relay with a coil resistance of 160 and the current will be 75mA. Can I use a BC547B (http://www.farnell.com/datasheets/2284253.pdf) ? What are the things I should look at when choosing a transistor for driving a relay? Is it only the Ice?

Maximum specified collector current for the BC547 is 100 milliamps which is marginal for a 75 milliamp load, but it will work.  A BC337 with 800 milliamp maximum collector current would be more suitable.
Title: Re: How to choose a transistor?
Post by: Zero999 on September 07, 2020, 09:25:29 pm
I need to pick a transistor to drive a 12v relay with a coil resistance of 160 and the current will be 75mA. Can I use a BC547B (http://www.farnell.com/datasheets/2284253.pdf) ? What are the things I should look at when choosing a transistor for driving a relay? Is it only the Ice?

Maximum specified collector current for the BC547 is 100 milliamps which is marginal for a 75 milliamp load, but it will work.  A BC337 with 800 milliamp maximum collector current would be more suitable.
Whilst I agree the BC337 is more suitable, I dispute the BC547 being marginal, at just 75mA, which is just 75% of its absolute maximum rating.
Title: Re: How to choose a transistor?
Post by: David Hess on September 07, 2020, 10:11:06 pm
Whilst I agree the BC337 is more suitable, I dispute the BC547 being marginal, at just 75mA, which is just 75% of its absolute maximum rating.

25% is the *minimum* derating that I would accept, and a 200 milliamp 2N3904, 600 milliamp 2N4401, or 800 milliamp BC337 are hardly going to cost more.
Title: Re: How to choose a transistor?
Post by: redgear on September 08, 2020, 01:14:43 pm
25% is the *minimum* derating that I would accept, and a 200 milliamp 2N3904, 600 milliamp 2N4401, or 800 milliamp BC337 are hardly going to cost more.

Thanks. They almost cost the same, will go with 2n4401.
Title: Re: How to choose a transistor?
Post by: David Hess on September 08, 2020, 11:49:54 pm
25% is the *minimum* derating that I would accept, and a 200 milliamp 2N3904, 600 milliamp 2N4401, or 800 milliamp BC337 are hardly going to cost more.

Thanks. They almost cost the same, will go with 2n4401.

The NPN 2N4401 and PNP 2N4403 are my go-to transistors for switching but I recommended the BC337 earlier since your original question was about the BC547.

Even at lower currents where the 200 milliamp 2N3904 would be suitable, the 2N4401 will usually have higher gain.  The BC547 that you asked about is unusual in that it maintains high gain up to its maximum collector current.  Usually a higher current transistor than neccessary is used because the gain drops by that point.
Title: Re: How to choose a transistor?
Post by: Zero999 on September 09, 2020, 08:21:19 am
25% is the *minimum* derating that I would accept, and a 200 milliamp 2N3904, 600 milliamp 2N4401, or 800 milliamp BC337 are hardly going to cost more.

Thanks. They almost cost the same, will go with 2n4401.

The NPN 2N4401 and PNP 2N4403 are my go-to transistors for switching but I recommended the BC337 earlier since your original question was about the BC547.

Even at lower currents where the 200 milliamp 2N3904 would be suitable, the 2N4401 will usually have higher gain.  The BC547 that you asked about is unusual in that it maintains high gain up to its maximum collector current.  Usually a higher current transistor than neccessary is used because the gain drops by that point.
The good thing about the BC337 is the hFE is specified at 60 when VCE = 1V, up to 300mA, so drive the base with 5mA and with 300mA, you're pretty much guaranteed saturation.
Title: Re: How to choose a transistor?
Post by: Doctorandus_P on September 12, 2020, 06:58:16 pm
Tl;DR, but about the ratings for (simple laminated ireon core) transformers.

Often they have some current rating, but the VA rating is more important.
If you have a 10V transformer, and put the output through a bridge rectifier, the the output will be the peak voltage 10 * sqrt*2) = 14V minus 2 diode drops from the bridge, so it will be around 12.8V.

If your transformer was rated for 1A or 10VA, then it would only be able to delver a sustained current of 10VA / 14V = 710mA.

The output voltage rating is usually under full load, and at no load the output voltage will be higher. With small transformers it can easily be 30% higher.

A very simple, but yet good method is to keep track of the transformer temperature over time. When (not too badly) overloaded, transformers do not self destruct such as most electronics, but they just start loosing efficiency and overheat. So as long as your transformer stays cool or luke warm with your intended load you're on the safe side.
Title: Re: How to choose a transistor?
Post by: redgear on September 13, 2020, 05:26:49 am
Tl;DR, but about the ratings for (simple laminated ireon core) transformers.

Often they have some current rating, but the VA rating is more important.
If you have a 10V transformer, and put the output through a bridge rectifier, the the output will be the peak voltage 10 * sqrt*2) = 14V minus 2 diode drops from the bridge, so it will be around 12.8V.

If your transformer was rated for 1A or 10VA, then it would only be able to delver a sustained current of 10VA / 14V = 710mA.

The output voltage rating is usually under full load, and at no load the output voltage will be higher. With small transformers it can easily be 30% higher.

A very simple, but yet good method is to keep track of the transformer temperature over time. When (not too badly) overloaded, transformers do not self destruct such as most electronics, but they just start loosing efficiency and overheat. So as long as your transformer stays cool or luke warm with your intended load you're on the safe side.

Thank You.
My current requirements are very less. A micro, a touch IC, 3 leds and a 7 Segment display. The 7 seg display and the LEDs will be always ON. So the transformer will never be under no load condition. 10mA is what I am planning to feed each seg of the 7seg display with, so for digits it consumes at max 280mA. All the segments don't stay ON all the time, so avg current draw can be assumed to be 150mA. Total average current draw will be 200mA. I have a 12v 7VA transformer. So, going by the calculations the transformer will be able to deliver 410mA. For a capacitor load, the Hammond Application note (http://www.hammondmfg.com/pdf/5c007.pdf) recommends derating to 60%, even in that case it should be fine.

Please correct me if I am wrong.
Title: Re: How to choose a transistor?
Post by: mzzj on September 13, 2020, 08:34:31 am

A very simple, but yet good method is to keep track of the transformer temperature over time. When (not too badly) overloaded, transformers do not self destruct such as most electronics, but they just start loosing efficiency and overheat. So as long as your transformer stays cool or luke warm with your intended load you're on the safe side.
Quite a few small transformers run "luke warm" even without load because of core losses so your approach might be even bit too much on safe side.  Typical specification for temperature rise under rated load for small transformers might be 30-40 °C
Some specifiy <65°C or <70°C like ones here https://download.altronics.com.au/files/docs_286.pdf

65°C temperature rise in a 40 °C ambient is noticeably more than luke warm... at least your finger doesn't make hissing sounds yet.  :-DD