common emitter amplifier question

I need to invert & convert a 0-3.3v PWM signal to a 0-5v one. Is a common emitter amplifier the best way to go about this? I attempted to make one up in LTSPICE with standard 10k resister values and get some spikes during the transitions, but I don’t know if these are due to LTSPICE itself not liking square waves, or if I need to add some bypass caps/etc.

LTSPICE screenshot below. Blue is input 3.3v, green is output.

That will invert the signal. I assume that is not allowed. The output impedance is high because of the 10k resistor, not every device would accept that.

There are chips for level shifting and converting. I think that even many gates of the 74HCTxxx series can be used as well. Or use two transistors, or a transistor with a mosfet.

In the schematic, the base current is not limited. As soon as V2 is 3.3V, the transistor is blown.

He did say invert & convert. I would ditch the left 2 resistors, put a 120 or 150 ohm in series to the base to limit base current, and change the collector pullup to something smaller, like 1K or 2.2K. Then when the 3.3V is high, the transistor turns out, collector goes low (invert) and when the 3.3V is low, the collector gets crisply pulled to 5V (convert).

You can't put a voltage source directly onto the base like that - BJT's are current driven and pushing the Vbe too high will over-current the base and cause damage.

Input signal should go through somehting like 1k to the base, use perhaps 2k2 on the collector and you'll get crisper transitions.

Thanks much for the help. Feel like an idiot for forgetting the current limit resistor. Both suggestions of pullup to 1k/2.2k and adding a series resistor of 150ohm/1k make the waveform much crisper. The 150ohm series and 1k pullup combo seems to produce the best result.

If you want a perfect PWM, try a small mosfet. 2N7000 is my favourite. Just a 1k drain resistor, no other resistors. Leo..

MrGarak: I need to invert & convert a 0-3.3v PWM signal to a 0-5v one. Is a common emitter amplifier the best way to go about this? I attempted to make one up in LTSPICE with standard 10k resister values and get some spikes during the transitions, but I don't know if these are due to LTSPICE itself not liking square waves, or if I need to add some bypass caps/etc.

LTSPICE screenshot below. Blue is input 3.3v, green is output.

Why not just use something like a 74VHC1G14 single schmitt trigger inverter? It switches at approximately 1/2 VCC so at 5V it will switch at 2.5V (your 3.3 will switch it just fine).

No resistors, transistors, caps or anything else needed.

Krupski: It switches at approximately 1/2 VCC so at 5V it will switch at 2.5V (your 3.3 will switch it just fine).

According to datasheet, it switces on at 3.85V when Vcc=5.5V, or at 3.15V when Vcc=4.5V. Therefore, with 3.3V signals it would be a gamble, in some cases it might work, in others it would not.

An inverting gate of 74HCT series will do the job.

akouz: According to datasheet, it switces on at 3.85V when Vcc=5.5V, or at 3.15V when Vcc=4.5V. Therefore, with 3.3V signals it would be a gamble, in some cases it might work, in others it would not.

An inverting gate of 74HCT series will do the job.

Datasheet I saw said 1/2 VCC. Maybe it varies by manufacturer?

MarkT: Input signal should go through somehting like 1k to the base, use perhaps 2k2 on the collector and you'll get crisper transitions.

That will certainly do the trick with no output load as shown in your simulation but presumably you are driving something with it. What you are driving will possibly change things.

Russell.

Krupski: Datasheet I saw said 1/2 VCC. Maybe it varies by manufacturer?

You referred to a CMOS Schmidt trigger. It has hysteresis. Typically a CMOS Schmidt trigger has low threshold of about 0.35 Vcc and high threshold of about 0.65 Vcc.

akouz: According to datasheet, it switces on at 3.85V when Vcc=5.5V, or at 3.15V when Vcc=4.5V. Therefore, with 3.3V signals it would be a gamble, in some cases it might work, in others it would not.

An inverting gate of 74HCT series will do the job.

Indeed, HC family will not work from 3.3V inputs when run at 5.0V supply, that's outside its static protocol. But the HCT family is perfectly reliable converting 3.3V input signals (and can only be run at 5V supply). Historically the HCT family was designed for interfacing TTL to CMOS, but its turned out really useful for level shifting!

If you want to level shift 3.3V to 5.0V, use HCT, if you want to level shift 5.0V to 3.3V, use LCX which have 5V tolerant inputs (LCX supply is 1.8 to 3.6V).

And whatever you use, transistor inverter, logic chip, remember the decoupling capacitor!

russellz: That will certainly do the trick with no output load as shown in your simulation but presumably you are driving something with it. What you are driving will possibly change things.

It is for a brightness control signal. Since it's going to an IC I would think(hope?) there'd be negligible load imposed.

MarkT: Indeed, HC family will not work from 3.3V inputs when run at 5.0V supply, that's outside its static protocol. But the HCT family is perfectly reliable converting 3.3V input signals (and can only be run at 5V supply). Historically the HCT family was designed for interfacing TTL to CMOS, but its turned out really useful for level shifting!

So something like this would work? http://www.digikey.com/product-detail/en/SN74HCT04N/296-1605-5-ND/277251

MarkT: And whatever you use, transistor inverter, logic chip, remember the decoupling capacitor!

For an inverting transistor, can you go with standard high/low value combo of 100nf/100uf as an example? Do the optimal values vary on the frequency of the signal being applied to the base? I would assume the decoupling would be before the pullup resistor, so 5V to gnd? Tried to do research on this searching for "decoupling capacitor transistor" but didn't come up with relevant results.

100nF is the usual for logic, though you'll probably be fine sharing decoupling with one of the connecting devices if its nearby - discrete transistors are fairly sluggish compared to modern logic families, but its a good discipline to always put in the decoupling, as the symptoms of a lack of decoupling are many varied and frustratingly hard to track down.

MrGarak:
It is for a brightness control signal. Since it’s going to an IC I would think(hope?) there’d be negligible load imposed.

Does that IC require an analogue input? If so you may have to add a simple low pass filter.

Russell.

I managed to salvage a C945P NPN transistor from an old non functional PC power supply. I set up the spice circuit on a breadboard and it seemed to function properly. I added a 10k resistor to ground on the base as I assume if it's left floating there could be issues? That's what I've done on the gate of N channel mosfets, at least.

russellz: Does that IC require an analogue input? If so you may have to add a simple low pass filter.

The signal goes from a microcontroller chip to the IC so I assume it's digital.