Transistor Switching - Page 1
Forum section: electronics / beginners

author: Oslaw
author_rank: Contributor
timestamp: July 06, 2018, 11:03:31 pm
content: Hello all, I was testing switching with a 2n2222 NPN transistor and every time I connect the base directly to data source( or set my potentiometer to zero), the LED on the collector side turns off or goes dull Please what might be wrong.

author: Zero999
author_rank: Super Contributor
timestamp: July 06, 2018, 11:38:44 pm
content: A schematic would help.The transistor must have a base resistor and the LED a current limiting resistor.

author: Oslaw
author_rank: Contributor
timestamp: July 07, 2018, 06:24:21 am
content: This is the schematic I used. It switches well until I remove 1k resistor connected to the base, then the LED goes dim or dies.

author: hamster_nz
author_rank: Super Contributor
timestamp: July 07, 2018, 07:40:08 am
content: What are you using as a power source?Without either a base resistor, or a current limiting resistor for the LED everything should burn out (that is unless you are using a current limited power supply).Do you want to:a) see a design that will workorb) to understand why the existing design doesn't work, allowing you to design something that will.

author: Oslaw
author_rank: Contributor
timestamp: July 07, 2018, 01:25:03 pm
content: Both. I did just that and still same result. I am using a 9v battery. Below are pictures of the potentiometer tuned to both ends. At level 0 Ohm LED is dull and at 10k Ohms bright(at any resistance level above 0 ).

author: MK14
author_rank: Super Contributor
timestamp: July 07, 2018, 02:13:44 pm
content: Assuming you mean that the potentiometer. Is replacing the 1K resistor. I.e. The potentiometer, is connected between the base of the transistor, and the positive +9V battery terminal. (I've looked at the pictures, and it looks like it might be, but I'm not 100% sure).Then the LED would tend to switch off, when you set the potentiometer to around 0, because you should really have an extra series resistor, between the potentiometer and the base, of e.g. 1K. Otherwise excessive current will try to flow between the base and +9V supply, because the diode junction of the transistors Emitter/Base will start to hugely conduct, at around 0.6V/0.7V.The small 9V cell I can see, can probably only supply a few hundred milliamps (probably less), so the whole supply voltage will probably drop to around 0.8V (guestimate), and hence the LED will turn off. It may also damage the potentiometer and the small signal transistor.

author: Zero999
author_rank: Super Contributor
timestamp: July 07, 2018, 06:38:22 pm
content: Quote from: MK14 on July 07, 2018, 02:13:44 pmI would have thought it would burn out the transistor, so this is surprising.QuoteYes, I expect you're right, the battery's internal impedance is limiting the current to a safe level and the transistor's base-emitter junction is clamping the supply voltage down, below the LED's on voltage. I suppose this is more likely if it's a high power transistor and the battery is already heavenly discharged.Quote from: Oslaw on July 07, 2018, 01:25:03 pmWhat do you want to do? Dim the LED? If so, this isn't the right way to do it. You'll be better of connecting the potentiometer and another, fixed value resistor, in series with the LED.

author: MK14
author_rank: Super Contributor
timestamp: July 07, 2018, 07:02:13 pm
content: Quote from: Hero999 on July 07, 2018, 06:38:22 pmI can't see a maximum base current limit, on the 2N2222's datasheet (http://www.farnell.com/datasheets/296640.pdf). But, since the maximum collector current is 800 mA, as a rule of thumb, the limit is usually at least a tenth of the maximum collector current (also, that usually saturates the transistor), which it comes to 800/10 = 80 mA's.Also, it looks like a cheap (possibly part run down), zinc/carbon or similar, type of non-alkaline PP3 battery. This probably means the short circuit current, is more like around a 100mA's (guestimate, as you said, limited by the batteries relatively high internal resistance/impedance).I said hundreds of milliamps in my original reply, as it might be that high.Really, it varies, from battery to battery etc. So I have to be extremely rough with something like that.If it was a powerful power source, then I agree, the small transistor, could easily be toast, in such circumstances.

author: Zero999
author_rank: Super Contributor
timestamp: July 07, 2018, 07:48:56 pm
content: Silly me, I missed the 2N2222 bit.Even if it's exceeding the maximum rated base current, it doesn't mean it's automatically toast. Components can often withstand way over their maximum ratings, with no damage,. Obviously it's bad design practise to build anything which will stress the components beyond their maximum ratings, even if they tolerate it.

author: MarkF
author_rank: Super Contributor
timestamp: July 07, 2018, 11:46:02 pm
content: Alan Wolke did an in depth video on bipolar transistor switching times that I found very informative

author: tpowell1830
author_rank: Frequent Contributor
timestamp: July 08, 2018, 05:10:54 am
content: The observations regarding the lack of 1k resistor is good, also the internal resistance of the battery, however, someone is missing the elephant in the room.. this is not an incandescent bulb. It is an LED.

author: hamster_nz
author_rank: Super Contributor
timestamp: July 08, 2018, 07:11:10 am
content: Quote from: tpowell1830 on July 08, 2018, 05:10:54 amJust did a quick test. With a good alkaline 9V battery the short circuit current is about 400mA - giving the battery about 22.5 ohms of internal resistance.That is enough to burn out an LED, but not enough to burn out a transistor (at best you might be able to get half a watt of heat outside of the battery).Without the resistor (or the pot dialed to 0 ohm) there will be a few hundred mA flowing through the tranaiator's base, and due to the internal resistance the battery voltage has dropped to about volt or less, causing the LED to go out.

author: Zero999
author_rank: Super Contributor
timestamp: July 08, 2018, 08:33:52 am
content: Quote from: hamster_nz on July 08, 2018, 07:11:10 amThe text clearly said LED, so the symbol is just wrong. I suspect it's been copied from another site.Yes, 400mA is expected from a new alkaline battery, but I think the original poster is probably using a tired zinc battery, which will have a much higher impedance.

author: MK14
author_rank: Super Contributor
timestamp: July 08, 2018, 10:31:01 am
content: Quote from: hamster_nz on July 08, 2018, 07:11:10 amIf you examine the pictures, carefully. I can apparently see, a 220resistor, connected in series with one of the LEDs leads.I.e. The LED should be fine. Although strictly speaking, the resistor should be higher, if it is intended to run the circuit from 9V, to keep it below 20mA, the LEDs (presumed, as I don't know the exact spec of that LED) max currrent limit.

author: tpowell1830
author_rank: Frequent Contributor
timestamp: July 08, 2018, 10:52:15 am
content: Okay, another hint, how do you dim an LED? The linear region in an LED is tiny, so a pot is difficult to hit that unless there has been careful calculations done. This setup is very tricky in order to get the LED to dim the full sweep of the pot.Last hint... hope it helps...EDIT: Think digital.

author: ruffy91
author_rank: Regular Contributor
timestamp: July 08, 2018, 01:06:03 pm
content: Regulate current, not voltage.

author: tpowell1830
author_rank: Frequent Contributor
timestamp: July 08, 2018, 01:37:57 pm
content: Quote from: ruffy91 on July 08, 2018, 01:06:03 pmBINGO!Where do you put the resistor on a transistor hookup for current regulation? Keep in mind that you will need to regulate from approximately 50 µA (not 0) to 100 mA. Still, not the method that I would recommend.

author: Oslaw
author_rank: Contributor
timestamp: July 08, 2018, 04:06:05 pm
content: Thanks Everyone. I used a new 9v battery and it burnt the LED and got the transistor hot ( replacement LED also got burnt). It seems the dimming was probably a result of the LED glitching due to over-current.(New 9V Battery:9.01 V andOld 9V Battery:7.48 V ).

author: Zero999
author_rank: Super Contributor
timestamp: July 08, 2018, 04:27:43 pm
content: Quote from: tpowell1830 on July 08, 2018, 01:37:57 pmThe resistor needs to go in the emitter side, to regulated the current, which can then be controlled by varying the base voltage with the potentiometer.Also what's wrong with regulating down to 0mA?And 100mA is too high for a small 5mm LED.

author: MK14
author_rank: Super Contributor
timestamp: July 08, 2018, 04:43:50 pm
content: Quote from: Oslaw on July 08, 2018, 04:06:05 pmYou should be using/designing circuits, which respect the limits of the components. E.g. Transistor bases, LEDs and things, don't like big currents.Otherwise, you will risk breaking the components, which is what you seem to be saying, has just happened.I still haven't seen a proper schematic of how you wired things up, or an explanation of exactly what you are trying to achieve. So it is difficult to comment any further.

author: james_s
author_rank: Super Contributor
timestamp: July 08, 2018, 04:53:05 pm
content: Reminds me of the first time I played with LEDs when I was about 4 years old. I remember wondering why they get so hot and don't last very long when I connect one to a 9V battery.Like most future engineers seem to have done, I also tried connecting a NE-2 lamp to 120V prior to learning what a ballast resistor was.

author: MK14
author_rank: Super Contributor
timestamp: July 08, 2018, 07:41:39 pm
content: Quote from: Hero999 on July 08, 2018, 04:27:43 pmI hope you don't mind me criticising your (apparently), adjustable 0 to 20 mA (approx), constant current circuit.But, the way you have drawn it, the 100K pot, will probably not do anything, for around half its travel.If, you changed it, so that the bottom lug of the pot, which currently goes to ground, was instead, connected to the point where the two diodes meet. Which should be around 0.6 to 0.7 volts.Then most of the transistors Emitter/Base voltage drop will effectively be cancelled out.Hence the adjustable pot, should vary over nearly all its range (rather than only half of it).On the other hand, it is possible, my suggested change may reduce or cause instability. I would have to simulate it, or build it, or calculate hard, in order to find that out.

author: tpowell1830
author_rank: Frequent Contributor
timestamp: July 09, 2018, 01:50:50 am
content: Okay, so if you want to dim an LED, your best option is a PWM (Pulse Width Modulator) circuit. The circuit allows the user to adjust the width of pulses, without changing the frequency of the pulses. This means that the effective voltage varies while the power supply voltage remains constant. This effectively regulates the average current applied. The LEDs will dim from dark to fully lit based on the regulating resistor in series with the LEDs or single LED and the voltage applied (power supply voltage).A PWM circuit can be produced with discrete ICs, such as a 555 timer circuit or a µC with the proper connections and software. There are many ways to produce a PWM, just do a search for PWM circuits or pulse width modulator circuits.I have supplied a couple here:We have to do Dave's version of course.Hope this helps...

author: Zero999
author_rank: Super Contributor
timestamp: July 09, 2018, 07:51:44 am
content: Quote from: tpowell1830 on July 09, 2018, 01:50:50 amWhy is PWM better?I can see why it's better than varying the value of a series resistor, but don't see why it's better, than regulating the current. Simple PWM, with a resistor and no regulated power supply, will cause the LED's brightness to change, with the power supply voltage. A current regulated driver will keep the brightness constant. The only thing I can think of is, some phosphor LEDs, such as white ones, may change their colour, at low currents, but it's not something I've noticed myself.Quote from: MK14 on July 08, 2018, 07:41:39 pmThanks for your comment. I realised this later, when I was away from the computer.Yes, connecting the resistor to the node where the diodes meet will help, but it still might not go all the way to zero. Another resistor, with a slightly lower value, than the pot, in series with the bottom side of the pot will fix it, although there will still be some dead-band.

author: MK14
author_rank: Super Contributor
timestamp: July 09, 2018, 08:26:48 am
content: Quote from: Hero999 on July 09, 2018, 07:51:44 amYes, that is also a good or even better, way of improving it.Afterwords, I also worried, because, although diode junctions typically are between 0.6V and 0.7V, at low (but not too low) currents, in the LED part of the circuit. Very little current, will flow into the base of the transistor (in that circuit), especially if its Hfe happens to be high.That might cause the base/emitter voltage, to drop below 0.6V, depending on the characteristics of the actual transistor, that is being used. There is probably significant transistor, to transistor variation, on parameters like that, even for identical types of transistors. (e.g. at 50 microamps base current).

author: tpowell1830
author_rank: Frequent Contributor
timestamp: July 09, 2018, 08:37:26 am
content: Hero999, PWM is a better choice because with a current circuit as you have shown, the full sweep of the pot will have to be precisely calculated as far as your limiting base resistance. This will be a hunting game every time that you add a new LED or simply replace the LED with the same type that you had working well with the circuit. Your circuit will work with some fidling around with the resistor values, but as soon as you replace the LED with another one of the same type or a different type, your limiting resistor will probably need to be changed again. It is very difficult to get the deadband out of the adjustment pot.With PWM, the LED will change brightness from dark to bright every time, no fiddling around, no deadband. Change or add LED, no worries.Hope this helps...

author: Zero999
author_rank: Super Contributor
timestamp: July 09, 2018, 10:35:27 am
content: Quote from: tpowell1830 on July 09, 2018, 08:37:26 amI concede your point about the deadband, but the LED current will be fairly independent of the forward voltage. The current through the transistor is controlled by varying the base voltage. The voltage across the emitter resistor and therefore the current, is proportional to the base voltage, minus the base-emitter voltage. Even replacing the LED with a short circuit will not increase the collector current by much.IC= (VB-VBE)/REThe only issue I have with the circuit now is the potentiometer's value of 100k is be a bit high, as the impedance looking into the base will be about 7k, assuming an Hfe of just over 200. Reducing it and the resistor in the lower leg, by a factor of 20 would help, but the original poster might only have a 100k pot, which will probably do, even though it isn't optimal. It also doesn't need to be perfectly linear, as the operator will compensate to some degree, when adjusting the pot.

author: MK14
author_rank: Super Contributor
timestamp: July 09, 2018, 10:57:08 am
content: Quote from: Hero999 on July 09, 2018, 10:35:27 amTwo points.One is the OP, seems to say he has a 10K pot, rather than a 100K one.Quote from: Oslaw on July 07, 2018, 01:25:03 pmSecondly, the 7K impedance looking into the base, is only at full brightness, when the pot will be a very low resistance (as regards, the top two terminals of the pot, the other will be at nearly 100K, of course).As the pot then decreases the current/brightness, into the base, the current flow reduces, so the effective impedance into the base, increases.E.g. At 10% brightness = 10% of base current at full brightness = 10 x 7K = 70K very approximately, since Hfe will probably increase as the collector current drops.tl;drAssuming OP has 10K pot, it should work reasonable well in that circuit, assuming there are not other issues.

author: Zero999
author_rank: Super Contributor
timestamp: July 09, 2018, 11:23:20 am
content: Quote from: MK14 on July 09, 2018, 10:57:08 amGood, I don't know why I thought 100k.10k and 8k2 would certainly be better.The base impedance will probably drop, at lower currents. It's roughly equal to RE*Hfe. The 2N2222 data sheet gives a maximum Hfe, of about 400, with a collector current of 50mA, as the current is reduced further it drops. At 20mA, it's just over 200, hence why I rounded up to 7k but at 2mA, it'll be just over 150, so the input impedance will be around 5k.https://www.onsemi.com/pub/Collateral/P2N2222A-D.PDF

author: MK14
author_rank: Super Contributor
timestamp: July 09, 2018, 11:55:53 am
content: Quote from: Hero999 on July 09, 2018, 11:23:20 amDon't worry about the 10K vs 100K mistake. It is terribly easy to make M1sTTaces.I was getting mixed up as regards the Hfe changes with current. It is power transistors, whose Hfe usually drops as the current increases, especially at many amps. Small signal transistors can be different, sorry.[Deleted next part of post - mistakes in it]For now, I agree with you about the impedance. I will think about it further.

author: Zero999
author_rank: Super Contributor
timestamp: July 09, 2018, 08:55:52 pm
content: I've done some simulations and have tweaked the values a bit. In my previous circuit, I overestimated the forward voltage of the diodes, so reduced the emitter resistor and increased the current through them, so it gives roughly 20mA through the LED.The potentiometer is modelled as two resistors: VR1_A and VR2_B: the former is swept from 1R to just over 10k and the latter from 10k to 1R, to simulate the pot wiper being adjusted.V2 represents the LED's forward voltage drop. It's swept from 0V to 8.5V in 1V increments. Notice there's hardly any change in current between 0V and 8V and it only drops, when the forward voltage goes past 8.5V and the drop is only significant at higher current settings.