Single transistor level shifter - Page 1
Forum section: electronics / beginners

author: belzrebuth
author_rank: Frequent Contributor
timestamp: May 24, 2021, 09:28:29 pm
content: Hi all,I'm trying to build a simple circuit that accepts a 0 to 1V (maybe more) square and converts it to 0 to 10V square or thereabouts.Typical input value can be 0 to 5V and approx output should be at least 0 to 7V.The caveat is that the output should be 0V when the input is disconnected.This circuit feeds a flip flop clk input so it needs to be zero output when nothing is connected to the input.Power supply is around 10V.At first I thought about the attached circuit but then I realised that while it works for zero input when the input is entirely disconnected the output sits at almost VCC potential because it forms a voltage divider between VCC and ground.Is there any single transistor that can do this?NPN, PNP or even a MOSFET is acceptable but there's no room for an opamp or else I could use that.I know that there are single opamps in smd package like the lm321 that take as much space as a transiistor and I could use that but wondering if there's any single transistor or mosfet solution.Thanks!

author: pqass
author_rank: Super Contributor
timestamp: May 24, 2021, 10:23:28 pm
content: See attached schematic. When the switch is open the output goes 0V (see center part in LOAD trace).Also, you won't reach 10V exactly because of the 1K (pull-up)/10K (load) divider max'ing out at 9V.Play with it here:http://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEBmB0BskBMAWdn0B2SQwgTggUhCSpoFMBaMMAKABcQcz0V0AOGoV7IBUcFGgIykZP34IsYSERKEck9AnmFkZMoX5Y4OZBuXUAJvQBmAQwCuAG3asA5kJH8NCYV3Qa1JCsAE6eKIrhuEHg8KwASlE41L68xoIxybHiQVKsAO7hqFggWiKRwWFlESXVODgZsXEedQ2lCLx4gVAFSdTcaVmVXDwg0SMiYtQWcL3VxSCExjU9AA6LywtL-W0QQe4bO4Lb-t3B68nUooKXXLs5B7f1N3CnD4nIm2Lj1xIldDAkICcnlLBM+C8rt8QNZ7M5XBdRr8BndBHseh4Uc9wV0HgBnFBfSEQnIgexOPH0VgAe3AGgC4lM6BKykkcGQYCwQLGdJQIAAwgAZADSNJopW6pgQ5lycDAHS54n+fMFAHkAIIAEVYQA

author: Manul
author_rank: Super Contributor
timestamp: May 24, 2021, 10:49:00 pm
content: Quote from: belzrebuth on May 24, 2021, 09:28:29 pmI know, that it is not your question, but keep in mind rise and fall times, which might be important. Normally we try to keep digital signals transitioning fast. So op amp is a very poor choice. It is typically way too slow and also slows down even more because of saturation. With level shifters like in your schematic, it might be required to keep pull-up quite low to achieve fast transitions and high frequencies, because of transistor and load capacitance. If your flip flop has schmitt trigger inputs - you will not get digital flicker problems, but clock speed might be limited by slew rate if it is slow.

author: belzrebuth
author_rank: Frequent Contributor
timestamp: May 24, 2021, 10:54:45 pm
content: That's perfect pqass.I really wouldn't have thought of that.So you're keeping the transistor biased at all times with the 10k going to the base?Is the diode only there to protect the input from current flowing from VCC?Will this be safe if I apply a square of say 0 to 10V at the base?Maybe I should include a resistor in series with the input?Manul :Thanks for your insight; this is not a high speed circuit.It's intended to switch a signal on-off manually via a remote trigger.There's actually a push-button with a debounce network in there as well and never had a false trigger event.I only now needed to remotely turn this FF on and off while keeping the pushbutton functionality intact.

author: pqass
author_rank: Super Contributor
timestamp: May 24, 2021, 11:12:35 pm
content: Quote from: belzrebuth on May 24, 2021, 10:54:45 pmYes, the 10k keeps the transistor on by default.The diode is there to suck current away from the base to 0V when the input is 0V.Notice the voltmeter says 658mV when input is 1V. That's the BE diode in the transistor.So when the input is 1V, the diode is reverse biased and no current goes from input to base, therefore, no resistor required.However, it may be necessary to use a schottky diode if a regular 1N4148 has a forward drop higher than the BE-drop.Since the diode is reverse biased if input is greater than 0V, it doesn't matter how high the input can get (well, up to diode breakdown). What's important is that the input can get down to 0V. Or use a schottky and get ~200mV more headroom.

author: belzrebuth
author_rank: Frequent Contributor
timestamp: May 24, 2021, 11:14:06 pm
content: Thanks so much for your awesome solution and explanation pqass.

author: pqass
author_rank: Super Contributor
timestamp: May 25, 2021, 12:10:40 am
content: Quote from: belzrebuth on May 24, 2021, 11:14:06 pmYou're welcome.See new simulator link below. I've slowed down the clock and added ammeters to the base and input diode.Notice that as the input goes from 1V to 0V, the current of 0.9mA alternates to the base or to the diode (which has a lower voltage drop at that current) pulling the node at the base from 638mV to 446mV (the latter shuts-off the transistor entirely; just some 31nA leakage).Also, if you right-click the mouse over the CLK, click Edit, and change Max Voltage to 10 and DC Offset to 10 (ie. 0V-20V square wave), that it has no effect on the voltages at the base base node; still alternating between 638mV and 446mV.http://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEBmB0BskBMAWdn0B2SQwgTggUhCSpoFMBaMMAKABcaccV0AOGoXS8B1CIz4YcYPoSyRZOPjgqjo3dFjBY+VMroToEhcHBAATegDMAhgFcANu1YBzQcOTL3IPD2qRWACdvVCxvXH9TOFYAJXCcamNheVEoHzFI-2gEVgB3EIQwow9CqCCQYpRSyu5UsHgAtxqlCsMfdD8y-KSQCJ8WvoDg2t6E-oFkfjT6+DzWkrC5alCygAcQJarF+XHwNMaNnZHN333WdZXJidKRiH9XLd2V0-u4rDkRcDIwq72wpBgAOy+2yrHMTymCWWUzCllsjmc6xGvxGtzOblRLVRHTOAGdeh9fpcppFbA5cfRWMhiBCBAhuJ87mVqdQoZ9iQImQEAPbgHg41mTf5QWCQZDaAG9PkoEAAYQAMgBpVi8pACnyoHj1EVwMCGLCS4XIEDygDyAEEACKsIA

author: AndersJ
author_rank: Frequent Contributor
timestamp: May 25, 2021, 01:19:46 am
content: The diode MUST be a schottky.To avoid the need of a schottky diode,add a diode pointing right, in series with the base.Also,the driving circuit needs to be able to SINK the current through the 10K resistor.The original circuit needed to SOURCE the current.If the input is always 0-5V,or 1-3V,the diodes can be omitted if a 2N7002 or BS170 FET is used instead of a BJT.If input sink current is an issue,the 10K resistor can be larger, if a FET is used.