1
\$\begingroup\$

I'm trying to connect my atmega328P to the following H bridge, but I'm using 5V source and 2N3904 & 2n3906 transistors instead of 12V as shown in the picture:

enter image description here

The problem is that two of the transistors are PNP, but I always used NPN's as a switch by connecting micro-controller's output pin to the NPN's base, but I don't understand how can I 'output' a negative signal to trigger the PNP's from the micro-controller. Any suggestions?

\$\endgroup\$
  • \$\begingroup\$ Where are your base resistors? You can connect NPN to ground from the base of your PNPs and pull-ups to rail for your inversion/level shift. \$\endgroup\$ – winny Aug 12 '16 at 19:53
  • \$\begingroup\$ @winny if I understood you correctly, I need to attach additional NPN transistor to the base of each PNP transistors and use them as a 'positive' switch for the micro-controller, correct? \$\endgroup\$ – K666 Aug 12 '16 at 19:59
  • \$\begingroup\$ Correct. And base resistors for all transistors, and pull-up for the PNPs. \$\endgroup\$ – winny Aug 12 '16 at 20:58
2
\$\begingroup\$

PNP transistors don't require a 'negative' voltage to switch. Rather, the current which flows from the Emitter (+) through the Base (-) is amplified to produce a current (up to ~100x, dependent on the demand) flowing from the Emitter (with the arrow on it) to the Collector. The Base-Emitter junction is generally modeled as a diode, so in order to get any current to flow through it, you have to at least create a voltage difference that exceeds its diode-voltage drop, but more is better.

Waving my hands a lot here, but if you set up a condition whereby you sink 2mA into your Arduino pin, you'll be able to drive about 200mA into the motor in this way. To set up that condition, given that your PNP transistor has a 0.7V base-emitter junction voltage drop, and your VCC is 5V, you want to size your base resistor at (5 - 0.7) / 0.002 = ~2kOhms. Then drive the PNP transistor low to open the valve and let current flow, and high to choke the current off.

Note, you actually might be able to sink as much as 40mA into the Arduino pin, under several caveats, and get a commensurately larger emitter-collector current. Just keep in mind that BJTs are current-controlled devices, voltages are (mostly) incidental (within limits).

\$\endgroup\$
4
\$\begingroup\$

You can't directly drive the PNP's with your microcontoller, as they would need 12V High signals to shut off.

Edit: In response to your clarification, the pnp transistors are OFF when you set the base to 5V, and ON when you set the base to 0V. You can tie the bases of A and B together, and control them with the same bit, and only one will be on at any given time. Same with C and D.

\$\endgroup\$
  • \$\begingroup\$ Sorry, the schematic is an example I found online, I'm actually using 5V source with 2N3904 and 2N3906 transistors \$\endgroup\$ – K666 Aug 12 '16 at 19:49
1
\$\begingroup\$

I usually use 4 n-fets, with the high side fets having a clamping diode such that the gate does not see the motor voltage. This way I don't have to worry about driving bjts (and can use a uC directly).

\$\endgroup\$
  • \$\begingroup\$ oh also freewheeling diodes. or boom. \$\endgroup\$ – klamb Aug 12 '16 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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