Logic gate output won't go low enough to turn off NPN transistor - Page 1
Forum section: electronics / beginners

author: Infraviolet
author_rank: Super Contributor
timestamp: June 04, 2023, 08:45:14 pm
content: I'm trying to get a 74HC00 (NAND) logic gate's output to turn an NPN transistor (BC337) on and off. But I'm finding the logic gate's output, although an oscilloscope shows it to be going as low as gnd (and below due to ripple) and as high as the 5V power rail (plus some ripple), doesn't seem to ever go "low" enough to switch the transistor off.Measuring the transistor's base (separated from the NAND's output by a 1K resistor to prevent the NAND gate driving too much current) shows it constantly sitting at the 1.2V or so above ground one would expect to see when it is on, and the NPN's collector, at the the lower end of a high side load, stays at the sort of low voltage one would expect when a current is flowing through the load.I tried pulling the NAND gate's output to GnD with another 1K resistor, transistor still won't turn off when connected.I then resorted to having a 10nF cap in series after the 1K resistor, the other end of this cap is held just above ground by a potential divider between the power rail and gnd, so that the cap lets the signal vary about this reference voltage, decoupled from any DC offset in the NAND's output. This way I can get the transistor to go off and on, but it decoupling its base from DC through the capacitor seems an excessive number of components to need just to get a signal from a logic gate output to a transistor. Is there a way which needs less components and doesn't give a situation where if the logic signal were further attenuated by more than 1K it would no longer be able to get high enough to turn the transistor on.This is a fast signal, square wave with a frequency of several MHz, rise time and fall time not important so long as it can rise and fall the full voltage in the time available for a period.Thanks

author: Benta
author_rank: Super Contributor
timestamp: June 04, 2023, 09:19:46 pm
content: The pinout of the BC337 is different to, eg, BC547.Check that first.

author: bdunham7
author_rank: Super Contributor
timestamp: June 04, 2023, 09:22:24 pm
content: Could you draw out a schematic showing all the details, including the load that the transistor is driving?Are you saying you have an output of 0V at the output of the 74HC00, that output is connected to the base of the transistor by a 1K resistor, and the voltage at the base of the transistor is 1.2V? Is this all true in the steady-state (DC) condition? Is there any other component connected to the base of the transistor?Bentabeat me to it, but I was also going to ask--are the pins of the transistor connected correctly?

author: Andy Watson
author_rank: Super Contributor
timestamp: June 04, 2023, 09:26:35 pm
content: If Benta's solution is not correct:The transistor is probably saturated during the "on" time. It takes extra time to recover from saturation and remove the stored base charge. A quick fix might be to reduce the impedance of the base drive circuit - make the base drive from a potential divider between the output of the logic gate and ground. Aim to get the impedance seen by the base to 100\$\omega\$ or less. Or use a schottkey diode between base and collector to prevent saturation.Using a low base drive impedance would also mitigate the effects of miller capacitance too.If you want to use the speed-up capacitor trick - put it inparallelwith the 1k resistor.

author: DavidAlfa
author_rank: Super Contributor
timestamp: June 04, 2023, 09:43:41 pm
content: Try 10K or 100K with 100pf in parallel.

author: srb1954
author_rank: Super Contributor
timestamp: June 04, 2023, 10:27:15 pm
content: Quote from: Infraviolet on June 04, 2023, 08:45:14 pmThe BC337 transistor is not characterised for high speed switching applications but rather as a medium power driver for lower speed applications so it will be a fairly difficult task to get it to switch at this speed.There are various tricks for speeding up bipolar transistor switching but, depending on the load being driven, it might be a better option to use a small power MOSFET.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 05, 2023, 01:31:16 am
content: Thanks all.I was using a BC337 because I have pleny to hand in through hole for prototyping, it is not the same type I'd use when doing final boards (BCW66GLT1G of which I have a box of SMD format transistors), but at some point in the past (cannot rememebr when, but I've worked this way quite a while) I came to the conclusion that the BC337 and BCW66... seem similar enough to use one in breadboarding and the other on PCBs. I had checked the pins, that wasn't the issue.Andy Watson seems to have diagnosed it best, reducing impedance between the base and ground has helped.I found a 180 ohm pulldown to ground after the 1K resistor (that is to say at the transistor's base) seemed to keep the voltage on the base low enough that it would turn off when the NAND gate output low and turn on when the NAND output a high level. Lower part count than the whole capacitor decoupling of DC offsets. A 100pF in parallel with the 1K has also helped.

author: RJSV
author_rank: Super Contributor
timestamp: June 05, 2023, 04:44:05 am
content: Srb1954 Seems to have right.Can you test at reduced speed, like 500 khz, just for that section? That would relate to the issues being brought up, where the transistor can't keep up, at the 2 Mhz.That bit about 'driving impedance' sounds more like RF stuff, but how about then changing the base resistor, to maybe 2 kohms, to keep the transistor 'honest' (not saturating)...Rough figure say 3 volts driving 2 K would be base current of roughly1.5 mA. With a typical beta of 40 to 80 that would drive, say about 60 to 120 mA.

author: RJSV
author_rank: Super Contributor
timestamp: June 05, 2023, 04:58:07 am
content: ...oh and actually, most common emitter circuits (you have ? right ?), the base drive ON voltage is a static 0.6, 0.75, that sort of base to emitter characteristic.

author: RJSV
author_rank: Super Contributor
timestamp: June 05, 2023, 05:00:14 am
content: ...You mention 1.2 volts, which isn't a typical ON value, assuming common emitter, and generally always having a base resistor of some value, typically.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 05, 2023, 02:10:30 pm
content: I could swear it was showing 1.2V when it wasn't working, but since my changes which made it work the base pin is getting a waveform of zero volts when the NAND is outputting low and around 0.7V when the NAND is high.I can definitely try a lower frequency signal later, but it thankfully seems to be working now. In the final application it needs to be at 3 or so MHz though.

author: bdunham7
author_rank: Super Contributor
timestamp: June 05, 2023, 02:28:36 pm
content: Quote from: Infraviolet on June 05, 2023, 02:10:30 pmI had asked you if that 1.2V remained the case in the DC or LF case. The data sheet for the BC337 actually shows a VBE(on) of 1.2V under stated conditions that don't quite appear to be saturation. I don't know what the recovery (turn-off) time would be from that condition but from what you've posted, that appears to be the issue.Tweaking the components until it works in your prototype may not result in a stable result that works in production. One solution that might be less dependent on individual device characteristics is a Baker clamp.https://en.wikipedia.org/wiki/Baker_clamp

author: Infraviolet
author_rank: Super Contributor
timestamp: June 05, 2023, 02:56:31 pm
content: Thanks for the baker clamp link, I'll give that a go.

author: bdunham7
author_rank: Super Contributor
timestamp: June 05, 2023, 03:20:04 pm
content: Quote from: Infraviolet on June 05, 2023, 02:56:31 pmBAW56 might be a good selection.https://assets.nexperia.com/documents/data-sheet/BAW56.pdf

author: David Hess
author_rank: Super Contributor
timestamp: June 05, 2023, 03:48:25 pm
content: It seems the delay time because of saturation is the problem. Solutions include:1. Place a small capacitor in parallel with the series resistor to move charge in and out of the base more quickly.2. Baker clamp the transistor to prevent saturation, which can be done with a single schottky (or germanium) diode. This can be combined with the capacitor above.3. Use a faster transistor, like a fast saturated switching transistor. This is *not* the same as an RF transistor however, and they are no longer commonly available.If you really need faster switching, then an alternative is to drive the emitter with the output of the HCMOS gate instead of the base, with the base held at a fixed voltage. However this requires the load current to flow through the gate which may or may not be acceptable.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 05, 2023, 10:19:20 pm
content: I tried various capacitors in parallel with the 1K resistor, 10pF, 100pF, 1nF, with no success.I tried the two diode type of baker clamp, but no success.I've also tried substituting the BC337 with a 2N3904 (correcting for alternative pinout, 2N3904 has a short t_on and t_off in the datasheet), this doesn't make the baker clamp or parallel cap work, yet like the BC337 the 2N3904 does work when a 180 resistor is run from base to ground (emitter is at ground).Changing the 1K series resistor whilst keeping 180 ohms from base to groundReducing that 180 ohms to 150 ohms makes the transistor barely able to turn on any more, lowering to 120ohms it doesn't turn on at all, raising to 220 ohms it turns on and off as well as at 180, 270 ohms behaves well, 470 ohms has the transistor only managing to turn off for a brief portion of the input wave form and at higher resistances the transistor never goes off at all.Do these observations reveal anything further?Thanks

author: bdunham7
author_rank: Super Contributor
timestamp: June 05, 2023, 10:52:11 pm
content: Quote from: Infraviolet on June 05, 2023, 10:19:20 pmDo you have a DSO that you can use to provide a screenshot of the voltage at the base of the transistor and perhaps at the input side of the 1K resistor at the same time? Can you slow your input signal rate down and look at the transitions? Also, what is the (approximate) collector current in the on state, or IOW, what is your load?

author: Infraviolet
author_rank: Super Contributor
timestamp: June 05, 2023, 11:30:06 pm
content: Yes, I have a scope. I can how two traces at once, I'll get those pics uploaded ASAP.The "load" is from the collector upwards towards the 5V rail. It is an LC tank circuit which I am driving at resonance (plus some extra resistances and smoothing capacitors to ensure the resonance doesn't cause ripples on the 5V rail). The DC current would be a maximum of 24mA. The AC current, judged by the voltages on a 56 ohm resistance in series after the LC tank and before the collector (diagram coming up) seems to be peaking at about 70mA with a mean of 22mA.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 06, 2023, 10:12:59 pm
content: Thank youImages are attached,Schematic: the NAND gate is powered from 5V and Gnd, the signals feeding in to it aren't shown. The load is an LC tank consisting of a PCB coil (L) and a capacitor, when this is in resonance it is used for wireless "power transfer", transferring a smal amount of power to be reflected off the geometry of some carefully shaped rotors as a type of angular resolver. C3 and C4 as well as the 56R resistors are there to serve to prevent any high voltages generated in the LC tank at resonance causing ripples or spikes on the power rails, they may be excessive for the task and somewhat inefficient but they do work. That string of diodes (to be replaced with an appropriate zener facing the other way in future versions) and the stuff righward of it is only there incase component variation means one gets really utterly perfect resonance in the LC tank, in which case it is there to take away any higher voltages which might threaten the transistor well before they get serious, as the resonance isn't quite perfect the peak voltages around the LC tank are under 8 volts and never quite get clipped by the diode string.O-scope images: One shows the waveforms when R2 is present, the other shows how the base stays high (transistor never turns off, and though not shown in traces here the collector never gets pulled down so all one gets in the LC is a DC current through L) when R2 is pulled out so there is "infinite" resistance (or anything large enough, performance gets bad for R2>470 ohms) from the base to ground. Yellow trace is at the NAND gate's output pin, blue is at the transistor's base pin, note the different voltage scales on the channels. I've been making those scope measurements using scope probes with the hook covers taken off so the needle pin can go stright in to breadboar, and with little wire loops round the probe end for grounding rather than the long grounding clip, else I get ringing on the edges.

author: David Hess
author_rank: Super Contributor
timestamp: June 06, 2023, 11:20:30 pm
content: That looks about right for driving a transistor into saturation. I do not understand why a capacitor across R1 does not result in better results.

author: bdunham7
author_rank: Super Contributor
timestamp: June 06, 2023, 11:27:46 pm
content: I would be interested in seeing the output of the 74HC00 and perhaps another set with a two-diode Baker clamp setup, with and without R2. I have the feeling we're all missing something here.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 07, 2023, 02:15:58 am
content: The yellow trace is the 74HC00's output.Something very odd must have been going on, I just tried a cap (10nF) in parallel with R1 againand took out R2. The trace at the NAND gate's output is now somewhat distorted with the falling edge becoming multi-stepped, but the trace at the transistor's base in now a distorted square waveform in phae with the 74HC00's output which has a high level at 800mV and a low at -3.12V. Transistor now switches fully on and off without needing R2, like it did when R2 was present but this time with base going below ground (emitter) at times when the transistoris turned off.A 1nF also worked here, waveform from NAND more distorted (I can't post a picture so quickly, so imagine a row of Burj Al Arab skyscrapers in profile, the sort of sail shaped building), wavefrm at base a square with sloping tops/bottoms high 960mV, low -1.84V.330pF gave a distorted square wave at the base of 960mV and -240mV. Smaller capacitances led to the scenario where the transistor never turns off.It seems a cap parallel to R1 is working instead of R1 this time, don't know why it didn't last time.The choice is whether the cap in parallel or the resistor to ground is the better choice, is it helthy for the NAND gate to be, even only for a brief fraction of each wave to be driving in to the "short-circuit" of the cap, and is it ok for the base of the transistor to go so far below the grounded emitter?Thanks

author: bdunham7
author_rank: Super Contributor
timestamp: June 07, 2023, 03:17:21 am
content: Quote from: Infraviolet on June 07, 2023, 02:15:58 amDoh! That should have been obvious...QuoteAre you doing this on a breadboard?QuoteI don't know about the first two and to an exent it depends on exactly how you need the circuit to perform, but as far as reverse-biasing the BE junction 5V is the limit if there's any energy behind it. Is the -3.12V a spike from ringing or something or is that the approximate level of the bottom of the distorted square wave?

author: Infraviolet
author_rank: Super Contributor
timestamp: June 07, 2023, 06:26:25 am
content: Yes, this is on breadboard for now. I get things working on breadbords before I design PCBs (and whenever possible do PCBs with SMD versions of the through hole parts I use when breadboarding). Perhaps I might have let one end of the cap go in to an empty row or something first time round, tricky to see which one it is going in to when there are leads of other components all around.-3.12V is the level of the bottom of any spikes as per my o-scope's reading, but by eye on the scope's graph I could judge the flat bottom of the waveform was down in the -2.5V to -3V area.Given what I've found now, what difference is the parallel cap or 200 ish ohms to ground making which lets the transistor turn off where it otherwise remained stuck on throughout?

author: magic
author_rank: Super Contributor
timestamp: June 07, 2023, 10:12:42 am
content: Quote from: Infraviolet on June 07, 2023, 06:26:25 amThey pull current out of the base and suck out stored charge faster than it would clear naturally. The resistor adds an extra ~3.5mA current sink (which also reduces base current going into the transistor when ON from 4.3mA to 0.8mA) and the capacitor draws sharp negative current pulses each time NAND output goes down.Whatever you do, if you want this to be reproducible, check if it works with transistor specimens with different β (as there is likely at least 2:1 spread between the guaranteed maximum and minimum). Particularly the resistor option, which significantly decreases base current.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 07, 2023, 11:46:49 pm
content: Thank you, for different beta my best options is to work my way through testing with a whole pile of transistors of different models (each model having a different range of beta values) and check the circuit still works in all cases?Just to better my understanding I'm also going to make a test and see hwo this circuit behaves if the NAND gate is giving a much slower square signal to the base, shuld be able see how long the transistor would take to turn off under such circumstances.

author: bdunham7
author_rank: Super Contributor
timestamp: June 08, 2023, 12:25:36 am
content: Quote from: Infraviolet on June 07, 2023, 06:26:25 amYou probably need to explain why that is happening and you might start by checking the emitter lead measured right at the lead of the transistor itself.

author: r6502
author_rank: Regular Contributor
timestamp: June 08, 2023, 09:27:59 am
content: HelloI'm would expect that the circuit will oscillate, as L1 and C2 form a LC resonator?Did you simulate the circuit with spice (LT-Spice or TI-Tina)?Guido

author: Infraviolet
author_rank: Super Contributor
timestamp: June 08, 2023, 10:58:29 pm
content: The LC resonator is very deliberate, the idea is to generate resonance there and thereby have a reasonably effective way of having a large dI/dt in the L coil, this is necessary for inducing voltages in a nearby sensor, the whole point of this circuit. The NAND gate is part of a system generating an input waveform at roughly the resonant frequency to keep this driven.bdunham7, thanks for the advice. I'll try it tomorrow and post some notes on what I see at the emitter lead (in theory it is grounded, few cm of wire to the setup's main ground rail, but maybe at short timescales it isn't staying so due to breadboard effects). I'll give a description then of how things appear with a much slower input square wave signal too.

author: Benta
author_rank: Super Contributor
timestamp: June 08, 2023, 11:11:04 pm
content: Have you considered using a Baker clamp or a Schottky clamp on the transistor? It's very effective.https://en.wikipedia.org/wiki/Baker_clampI'd suggest either the simple Schottky clamp, or for best performance the three-diode Baker clamp using Schottky diodes.

author: David Hess
author_rank: Super Contributor
timestamp: June 08, 2023, 11:12:07 pm
content: I wonder if resonance is pulling the collector below the base when the transistor is suppose to be turning off. The collector could be clamped to ground with a schottky diode to prevent this.This might also explain why the baker clamp did not work better.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 09, 2023, 12:38:26 am
content: Measurements I made earlier on the collector show it never goes below ground, not sure if it would therefore be possible for that to make the base do weird things?

author: Benta
author_rank: Super Contributor
timestamp: June 09, 2023, 07:41:49 pm
content: I did a Spice sim of the circuit you show in reply #18 with just a resistive load (170 ohms, but it makes no big difference whether it's 100 or 300 or 1k ohms).R1 1 kohm, R2 220 ohm.I get the same trace for base voltage that your 'scope snap shows.Apparently, the CB and BE capacitance is very high on the BC337 and the actual problem is the turn-on time (which surprised me). Turn-off time is like turn-on, adding a Baker/Schottky clamp makes it much faster, which is as expected.Traces:Green: idealized output from 74HC00Red: BC337 collector currentBlue: BC337 VBEbc3371.png: without clampbc3372.png: with clamp BAT41I tried reducing R1 to 470 ohms, which improved turn-on time, but not a lot.My conclusion: the BC337 is not really suited for this job. Or you'll need to rethink the dircuit to let it run in linear mode.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 09, 2023, 07:58:32 pm
content: I've done some further tests:1) Whatever I do the emitter is pretty near ground (10s of mV away at a maximum, it never goes more than 60mV below ground at most negative "peak" value in any circuit setup (pulldown, cap in parallel...).2) A close look at the base shows that the smaller the pulldown resistor the less delay between the falling edge of the signal from the NAND gate at the time when the base gets to ground, anything in the range of 180 ohms to 270ohms (40 to 120ns ) is very suitable to bring the base down fast enough for it to stay down a while before the NAND gate signal rises again.Tthere is no significant delay betwen the rise of the NAND gatevsignal and the rise of the base.3) At a lower driving frequency the problem remains the same, without a pulldown the base never gets to ground, with it the delay between the NAND signalfalling and the base falling is the same for a given resistance as when driving at 3MHz.4) I tried increasing and lowering the value of the 1K resistor, in all cases removing the pulldown stopped the base ever getting to ground, and with the pulldown the waveforms were fairly similar to with a 1K resistor between the NAND gate and the transistor's base.I'm not keen on the capacitor in parallel to the 1K resistor because that causes some further ripples on the base signal which translate to extra ripples in the output, and a clean signal is quite important for my application. So as it seems to still work for a reasonably wide range of pulldown strengths, a range of series resistance values between the NAND' output and the transistor's base, and it still works if the transistor type is swapped...Is there anything wrong with the pulldown solution?Is it more vulnerable to suddenly not working in some circumstances than the capacitor solution would be, given it still worked with alteration of the values I would assume not?P.S. baker clamp, that I tried earlier without success, although I haven't any Schottky's to hand right now (only normal small signal diodes), s had to use normal diodes. I'll remember to get some Schottky's for future uses when I next order any other components.ThanksEDIT: Just saw your latest reply. Using a 2N3904 instead of a BC337 gives similar results including a similar delaying the turning of of the base. I'll check through the datasheets of those transistors I have to hand right now and see which claim low capacitance.

author: Kleinstein
author_rank: Super Contributor
timestamp: June 09, 2023, 08:29:55 pm
content: The baker clamp does not really work with a "normal" diode. To make it work it needs a diode with lower forward voltage than the transistors - at least in the simpler version. One can get around it would an additional divider at the base, kind of combining it with the pull down resistor and an extra base resistor.The pull down resistor reduces the base current and increases the load to the logic gate. This may be an issue with higher current.The capacitor parallel to R1 can speed up also the turn on part and can be more effective than the pull down resistor.With the current circuit the collector voltage is expected to initially go up, possibly quite a bit and via the collector - base capacitance slow down the turn off, especially with the slightly larger BC337.

author: Benta
author_rank: Super Contributor
timestamp: June 09, 2023, 09:31:48 pm
content: Apologies: forgot to mention that the Schottky/Baker clamp diode is a BAT41. Corrected in my reply.

author: Benta
author_rank: Super Contributor
timestamp: June 09, 2023, 10:12:52 pm
content: Try this instead. Let's call it "active turnoff". You really need to get hold of some small-signal Schottky diodes.Turn on is now ballpark, a 2N2222A which is specified for switching is appr. 2x faster.Trace colours the same as in previous post.

author: Benta
author_rank: Super Contributor
timestamp: June 09, 2023, 10:59:02 pm
content: Without the Baker clamp (D1 removed):

author: bdunham7
author_rank: Super Contributor
timestamp: June 10, 2023, 12:07:12 am
content: Quote from: Kleinstein on June 09, 2023, 08:29:55 pmThe two-diode one works to keep the collector from going below the base with any sort of diodes as long as they both have the same Vf. The three-diode version which goes beyond the 'clamp' action adds a diode to drain the charge from the base back through the input signal, bypassing all or part of the input resistor. The input signal has to actually go low (not open) and be able to sink this current. Using a Schottky for this third diode probably makes sense, but here's an interesting example using regular 1N4148 diodes.https://hackaday.io/project/18138-bullet-movies/log/49133-faillog-first-flash-driver-prototype

author: Benta
author_rank: Super Contributor
timestamp: June 10, 2023, 12:14:21 am
content: Quote from: bdunham7 on June 10, 2023, 12:07:12 amSorry, but whacking a transistor base through 100 ohms is easy for anyone. Especially at only 500 kHz. Not impressed.But OK, that's hackaday I guess. I don't go there.

author: David Hess
author_rank: Super Contributor
timestamp: June 10, 2023, 12:50:34 am
content: Quote from: Infraviolet on June 09, 2023, 07:58:32 pmIf a clean signal is important, then emitter switching is the way to go. This means driving the emitter with the output of the gate instead of the base and driving the base with a low impedance fixed voltage, usually ground but it could be something else.Reference level pulse generators work this way to produce very clean output pulses.

author: bdunham7
author_rank: Super Contributor
timestamp: June 10, 2023, 01:12:25 am
content: Quote from: Benta on June 10, 2023, 12:14:21 amI didn't post it because I thought it was a Nobel-worthy accomplisment, but rather because it clearly documented the differences in performance (for that case) in the three clamp configurations and had nice pictures to boot. He clearly had the same sort of issues as the OP even with only a 100R (total) base resistor.