3.3v to 5V logic level shifter using transistors

Hi,
I’m engaged in battle with a LinkSprite JPEG camera and I find that it needs to run at 5V on my 3.3V arduino circuit. I’ve used a voltage divider to get the transmit pin from the camera down to the 3.3V for the arduino but the camera does not appear to be responding to the arduino commands. I’m assuming that I need to increase the voltage of the arduino signal to 5V for the camera. Is a NPN transistor the correct way to manage this signal? Does anyone have simple guidance on a circuit that would do the job?

Thanks

..do you have the TTL version or RS232 one?

Yes, it can be done using NPN transistors, however you would need two, not one.

You would basically be using one NPN to convert your push-pull output into an open-collector output. This though has the effect of inverting the digital signal, so you would need a second NPN to act as an inverter:

However, that is a messy way to do it.

The simplest way is to use a logic chip that can accept a 0-3.3v input signal while running at 5v and output a 0-5v signal. Something like a 74CH08 AND gate chip - pretty common and cheap. Just link 2 inputs together, and it forms a simple buffer. Power it from 5V so the output is at the right level for your camera.

Technically: From the 74HC08 data sheet: Vih (input HIGH voltage threshold) at 6V is just 3.2v At 4.5V the Vih is a mere 2.4v. So, with a 5V supply the Vih should be somewhere between those two figures - well within range of a 3.3v Arduino.

I have the TTL LinkSprite.

As for using the And gate, great idea. I'll see if I can dig one up.

Jim

majenko: The simplest way is to use a logic chip that can accept a 0-3.3v input signal while running at 5v and output a 0-5v signal. Something like a 74CH08 AND gate chip - pretty common and cheap. Just link 2 inputs together, and it forms a simple buffer. Power it from 5V so the output is at the right level for your camera.

Technically: From the 74HC08 data sheet: Vih (input HIGH voltage threshold) at 6V is just 3.2v At 4.5V the Vih is a mere 2.4v. So, with a 5V supply the Vih should be somewhere between those two figures - well within range of a 3.3v Arduino.

No, 74HC chips thresholds are at 30% and 70% of Vdd, ie 1.5 and 3.5 for 5V operation - likely but not guaranteed to work for level shifting. However the 74HCT family will do the job guaranteed (thresholds 0.8 and 2.0V). Perhaps you were looking at the specs for a single manufacturer rather than the family specifications?

I might give this a try. I use the diode-and-pullup resistor a lot, works fine and I prefer it to a voltage divider. Haven’t tried the transistor 3.3V-to-5V shifter but I think it should work.

shifter.png

MarkT: No, 74HC chips thresholds are at 30% and 70% of Vdd, ie 1.5 and 3.5 for 5V operation - likely but not guaranteed to work for level shifting. However the 74HCT family will do the job guaranteed (thresholds 0.8 and 2.0V). Perhaps you were looking at the specs for a single manufacturer rather than the family specifications?

The NXP (Philips) one is what I was going by - one of the more common ones. But yeah, a HCT one would give a greater margin for error.

Thanks... That's the level of sophistication I was looking for. I'll give it a try. I also located a 4066 quad analog switch chip in my junk drawer that says it works for switching digital signals.

OK, I was able to get the 4066 chip to serve as a level shifter with very little issue. My problem now lies in the fact the even when I correct the signals to and from the LinkSprite Camera, the camera won't communicate when driven at 5V. I can go back to 3.3 V and it works as usual, but when I go back to 5V... nothing.

This is now outside the scope of this board. Thanks to all who offered suggestions.

There is a Bi-Directional Shifter made from a pair of 2N7000's and an extra set of pull-ups (for the 3V3 side) that works Very Well, I've used it twice and had excellent results both times NXP10144 I think is the number of the app note from NXP that desccribes the interface. I made one from a pair of C945 transistors and an extra resistor for base current limiting that worked well also, that one I modeled first in MultiSim... before I used it. All worked well bi-directionally.

Doc

I would advise against using transistors. Use logic gate ICs - a quad AND gate IC gives you 4 channels of level translation in one small IC. Tie the two input pins of each AND gate together to form one singular input [or link one input of the AND gate to the VCC + pin - which ever suits yiur construction best]. HCT are cheap, reliable, and simple. Even those considering using transistor solutions would be advised to look instead at HCT family ICs just for simple interfacing. Even a single channel interface made using transistors is larger in circuit board space, more complex to build, and likely to cost more - especially so if you put a value on time. Fault finding with HCT is ridiculously simple, whereas a transistor format has multiple points for potential faults, and will take much longer to fault find, and to replace a faulty component. "Keep it simple" usually pays well in the long run!!

I'm inclined to agree. 1) I'm too green with transistors to be comfortable with everything that could go wrong and 2) I have some logic chips sitting around. I used the 4066 analog switch chip which has a bandwidth well above what I need for 38400 baud and when I set the circuit up for 3.3V as a test it worked like a charm. When I set the system up with the Arduino at 3.3V and the camera at 5V I got nothing back from the camera. My next step is to hook the logic lines up to my USB scope and make sure I'm getting a clean signal. If the 4066 is not a good fit for this application, I have some logic gate chips that I can use.

Any other ideas why my logic shifter would work at 3.3V but not at 5V?

salacain:
OK, I was able to get the 4066 chip to serve as a level shifter with very little issue. My problem now lies in the fact the even when I correct the signals to and from the LinkSprite Camera, the camera won’t communicate when driven at 5V. I can go back to 3.3 V and it works as usual, but when I go back to 5V… nothing.

This is now outside the scope of this board. Thanks to all who offered suggestions.

So you are switching 0V or 5V to the output using 3.3V control signal - ingenious.

So I’m a bit confused - are you powering the camera at 3V3 and it works (although its meant to be powered at 5V?) I thought it wasn’t liking 3V3 at all?

The camera was flaky at 3.3V but at least it was responding to commands. By inserting the 4066 chip into the 3.3V circuit at least I know it sends commands correctly before I move to the 5V circuit. After having done this, the chip worked like a charm on the 3.3V circuit but did not seem to work on the 5V circuit. After putting the USB scope on the chip it turns out when you put a voltage on the switch terminal which exceeds VCC for the chip (I was still using the 3.3V) it closes the switch and you get a flat line voltage. After I changed the hip to 5V voltage also, the chip worked as advertised. Problem is that the camera circuit did not work even after I did the logic level shift. Very frustrating. I'm going to buy a replacement camera on the notion that the one I got is a defect or that I fried it in my many sloppy attempts to get it working.

The major failing in Any (almost) IC level shifter is that it isn’t Bi-Directional, Most data bus are bidirectional. There are 8 connections to use both Mosfets and at least that many pins on an IC. Don’t forget you must deal with the inputs to Any unused gates. The possible reason \why the 4066/4016 failed… @ 5V it has a typical on resistance of 400 ohms @ 5V Vcc. at lower voltages it gets worse… The TI data sheet I enclosed isn’t the same as the RCA as the chip is characterized and Specified to 3V, The Resistance would almost double, If the curves for 5, 10 and 15 volts hold true.
One last point about the Mosfet Level Shifters… all the parts would plug into an 8Pin IC socket… with 2 extra pins left free. the pull-ups are required with either solution so they don’t count.

Doc

CD4066BE.pdf (547 KB)

Yes but a 4066 is a bidirectional circuit. I am intrigued how you used this as a level shifter, can you say how it is powerd and wired. This is an analogue switch so it will not act as a level shifter by itself.

Why do you mess with those chips in such simple 38kbaud circuit?? Use a simple resistor divider from camera’s tx to arduino’s rx and direct connection from arduino’s tx to camera’s rx. It must work :roll_eyes:
PS: you need special active level shifter when running ie. an sdcard with 10MHz clocks and data, not the 38kBaud serial rxtx data… :slight_smile:
PS1: see below - even @125kBaud and relatively high value resistors you get a perfect rxtx signal…

I did use a resistor divider to to reduce the camera's 5V output to the Arduino's 3.3v input. Problem is I needed a different solution to get the Arduino's 3.3V output into the camera's input. Originally I was hoping the 3.3V signal would be sufficient to trigger the logic in the camera but in early tests the camera was not responding so I sought to increase the signal level of the Arduino but, sadly, I still am not getting a response from the 5V camera.

Here’s the circuit I used to perform the level shifting for the LinkSprite. Comments Welcome.

LinkSprite Checkout Circuit.pdf (100 KB)

Why not do it with few mosfets?

http://www.electro-tech-online.com/custompdfs/2008/09/an97055-3.pdf

page 10, i used irf540 since i had few spares