2
\$\begingroup\$

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

\$\endgroup\$

3 Answers 3

2
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ I tried that with several resistors, I think the NPN transistor I used to convert the logic level to 5V pulls the RPi pin up to around 3V when its floating ,regardless of the pulldown resistor at the input. also Isn't it bad for the RPi to sink all that current? I built my own H-bridge following this design pocketmagic.net/2009/03/a-simple-h-bridge-design/#.UqjoLFXxteW \$\endgroup\$ Commented Dec 19, 2013 at 10:07
  • \$\begingroup\$ 1. Why are you building your own h-bridge out of discretes? Unless this is for educational purposes, it's not worth it. 2. You need buffers to drive that thing anyways. The rPi can only source/sink 4 mA. 3. You definitely need level-shifting for that to work properly. \$\endgroup\$ Commented Dec 19, 2013 at 10:46
  • \$\begingroup\$ You need a totem-pole output buffer. You could build one yourself, but that's silly, considering how cheap they are. Just buy a non-inverting buffer, and use that. \$\endgroup\$ Commented Dec 19, 2013 at 10:48
1
\$\begingroup\$

You probably want a 74HCT125 buffer circuit. It has a separate "enable" from the "data" value. Thus, you can make it so that it doesn't go "enable" until you decide it should do that, with a weak pull-up for example. The HCT version accepts anything over 2V as "high" even when you feed it a 5V VCC.

\$\endgroup\$
0
\$\begingroup\$

This does not directly answer the question, but you could avoid the dangerous input configuration that shorts the battery contacts through the transistors by using the control logic from this H-Bridge.

The trick in this h-brigde is that it cleverly uses 3 control signals to turn on the diagonal transistors (to move the motor forward and in reverse) without ever letting you turn both vertical transistors (both left, both right or all four transistors) at once, preventing you from shorting the battery contacts.

The h-bridge I mentioned also uses optocouplers between the logic and bridge circuits, which might also help with the level logic conversion.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.