Electronic – Logic level converter for H-bridge and UART for Raspberry Pi

h-bridgelogic-levelraspberry pitransistorsuart

Here is my situation:

I'm using a raspberry Pi to control a H-Bridge. The H-Bridge is not tolerant of both it's inputs being high logic value, which causes a short through the transistors, bypassing the motor. Because the H-bridge requires a 5V input, I slapped together this disaster:

Getting rid of floating input in a logic level converter

Now, as i understand, that circuit sinks current to the RPi, which is not only dangerous, but also crashes the Pi. Not only that, but the RPi boots with the output pins floating, which causes the logic level converter to output 5V, shorting the H-bridge as mentioned.

At, first I got around the issue with having a manual switch disconnect the H-bridge until I could set the RPi pins as outputs, the current sinking was tolerated. Now, I connected UART also through this converter(TX) and a voltage divider(RX) and it just crashes the Pi-s UART, I think it is because the RPi cannot handle sinking that much current. (UART works fine if motors inputs from the RPi are disconnected)

I need a schematic for a 3.3V to 5V logic level converter that acts like this:

1. on floating input, outputs 0V 
2. does not sink to input
3. uses PNP and NPN transistors
4. is relatively easy to build

I'm assuming a voltage divider is fine for dropping the RX line from 5 to 3.3

Best Answer

Uh, I'm not entirely clear on the issue here. You do know you can simply apply a static pull-down directly on the raspberry pi IO pins? The rPi can easily drive a few kilo-ohms load.

Just tie the output pin to ground with a ~5-50K resistor. That way, when the pi isn't set as an output, the pin will be pulled to ground, and when you do set the pins as an output, the output driver can just overpower the pull-down, and it'll work as normal.


For that matter, what H-Bridge are you using? The common L298 will work fine with 3.3V logic-level inputs, it's probable that the bridge-driver you're using will probably also be fine.