Let's Make Robots!

H_Bridge Motor Driver or how to control my DC motors

Dear, Mates ! 

For less than ten days i suffer for second time trying to construct my own HBridge so probably i really need somebody helps me, please.

The last time i bought the set i thought everything whould be fine :

- 4 Transistors (2xIRF640 and 2xIRF9540n) and two resistors(8K,0.25) this should be the most basic things to build an HBridge ?  

I am not really sure as i've been 30 minutes ago, but the most important parameters i had to suppose was

 -For IRF640       VDSS 100 V  ID 22 A

 -For IRF9540N  VDSS -100 V  ID -22 A

( I chose them because i am expecting to turn a motor with 30V and 4A consumption. )

and VGS(th) for both transistors 2 to 4 Volts - perfect for my parallel port.

If you haven't corrected me yet please don't be ashame, but isn't VGS(th) the trigger and the Only requirement on Gate to turn transistors working ?



I don't know where do i make mistake so, please look at the diagram above.

As i see when in initial position OUT A and OUT B are 0V so PChannels are passing, but NChannels do not and as result noting happens.

If i set OUT A to 5V left PChannel stops passing, right P is passing and left N is passing so motor is working.

If i set OUT B, motors spins opossite.


If all this is fine with you i would like to ask if the problem is wrong pin mapping? Both P and N Channel Mosfets are Gate,Drain,Source oriented when look at in front (they have an equal mapping) 


Any help for how HBridge works would be highly appreciated ! 

The reason i need to know it is becouse i want to call myself one day a robot builder as you do !

Thank you again !

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Do you have a multimeter or something you can use to check the voltages around your circuit? As far as I can tell, the high level output of your parallel port will be somewhere in the 2.6 - 5V range, so if it's on the low end it may not be enough to switch your transistors.

Also there is a ground connected to OUT B on your schematic, is this part of the real circuit? If so, you won't be able to turn on Q4 or turn off Q3.


Here i thing is the place to say that initial, when no pin output were sent and power to the circuit was applied my motor started spinning for about 5sec and that was last work for ever. Just after that i started measuring everywhere voltage was equal to VSS.

Strange. 12 Volts everywhere

And also. Do you think this mosfet would work fine for the range 12-30 or 48 Volts ?

When the parallel port is not producing an output to the transistors, the gate voltage can 'float' to an unknown value. This can allow the gate voltage to drift to a value where both the N channel and P channel transistors turn on, causing what's known as 'shoot-through' where the current from the supply can go directly to ground through the transistors. This can waste a lot of power and overheat your transistors very quickly.

The easiest way to get around this is to add some weak pull-up or pull-down resistors to the transistor gates. These are just resistors (often 20kΩ or greater) that connect the gates to the supply or ground, and force the gates to a high or low voltage when the output is not active.

As OddBot has pointed out, you need some extra parts to convert your voltage levels to control the transistors. The pull-up/down stuff can be integrated into the level converter circuitry at the same time.

At minimum you can add a diode to each of your OUT A/B lines so that they can only pull the gates to ground when they go low, and use a pull-up resistor to pull the gates up to the supply voltage again when the parallel port outputs go high. The pull-up resistors will have to be several times greater than the 8kΩ gate resistors you have already, so you might want to think about using smaller gate resistors instead.

What do you mean ?

"The easiest way to get around this is to add some weak pull-up or pull-down resistors to the transistor gates"

Once Gates are connected to parallel port pin trough 8K and once to short them with 20K to GND ?  

Pull-up would be from gate to supply, pull-down would be from gate to ground.

If you keep your 8kΩ resistors between the parallel port and the gates, you'll need much larger pull-up or pull-down resistors. The two resistors will form a voltage divider when the parallel port output is low when using pull-up resistors, or high when using pull-down resistors.

Using 8kΩ with 20kΩ pull-downs for example, your 4.45V parallel port output will be reduced to 4.45V*(20k/(8k+20k)) = 3.18V at the actual gate. This is too low, so in this case you'd need a larger pull-down, a smaller gate resistor, or both.

Its true for both.

4.45V is the output. but how do you know if it is enough or not ?

I don't understand because i thought the only parameter is VGS(th).

About the ground there is not such a thing on the real circuit, sorry i forgot to clean this part. 

4.45V is greater than the maximum required Vgs, so this should be fine.