H Bridge Motor Speed Controller Tutorial


Welcome to my h-bridge motor driver
tutorial. I’m going to explain what H bridges are and how to build one. So what is an h-bridge? An h-bridge is a circuit that you can
use to control the speed and direction of a brushed DC motor. There are many ways to
design an h-bridge but I’m going to show you a simple one that can work with input voltages
between 6 and 15 volts, for motor loads up to two amps. 30 watts
of power is plenty for small to medium sized motors. It’s not the most efficient H bridge,
but it’s easy to understand, and I think it’ll be fine for your first
motor controller. So here’s a 12 volt power supply, a 1000uF capacitor to help
filter it, four carefully arranged transistors, and a motor. I’ll put the exact part numbers
in the video description. Do you see the H? This is an H bridge!
If we turn these two transistors on, and these two off, here’s the equivalent
circuit. Now current can flow from your positive power supply rail, through this transistor, through the
motor, through this other transistor, down to your circuits ground. This will
make the motor spin in one direction. Now how do we reverse the direction the
motor is spinning? We do that by reversing the direction of
the current going through the motor. If we turn these two transistors on and
these two off, now current will flow from your power
supply, through this transistor, through the motor in this direction,
through the other transistor, down to ground. Since we changed the
direction of the motor current, we change the direction of the motor.
Hey… what happens if we turn all transistors on? The motor should go twice as fast!
(aww crap) Yeah so if you turn all the transistors on, you create two high current paths
straight from power to ground, effectively shorting out your power
supply and blowing up the transistors. Let’s make sure that never happens again.
Let’s make the circuit idiot proof so people like me can use it. First I’m going to set my current limiting
power supply to a 3 amp limit. That way things can get hot, but they
probably won’t catch fire. If you don’t have a current limiting
power supply, consider using 3 amp fuse and fuse holder like these. Just put it in series with the positive
side of your battery. Now let’s be a little more careful when
controlling the transistors. Lets tie the gates of these two
transistors together, and do the same on the other side. Then let’s add 1 a kilohm resistor between
the transistors gates and ground. Any charge that might be on the gates
will drain through the resistor. So by default the voltage here at the
gates will be 0 volts, and the n-channel FETs will stay off,
preventing any sustained short-circuits. But now the motor can’t do anything!
So let’s add a 47 ohm resistor here. These two resistors form a voltage
divider. So if we apply 12 volts here, the gate voltage will be 11.45 volts.
Now our H bridge will stay off by default, but we can easily apply enough voltage
to the gate to turn things on. The voltage between gate and source on
the n-channel MOSFET will be 11.45 volts, so the transistor turns on. On the top half of the bridge, the voltage between gate and source of
the p-channel MOSFET will be -0.55 volts so the P-FET turns off. On the other side of the bridge, the
opposite is happening because the gate voltage is still 0. On the left hand side, the N-FET is off,
and the voltage between gate and source of the P-FET -12 volts so the P-FET is on. So now motor current can flow again!
With this arrangement, the N and P FETs can never both stay on at
the same time. Now that’s not 100% true,
there is some shoot through that lasts a couple of microseconds, but for this simple low-power h-bridge
you don’t need to worry about that. If we want to reverse the direction of the current, we can start by applying 0 volts here,
or we can just leave it floating because we’ve got that 1k pull-down resistor to ground. Then we just apply 12 volts to the other side, and now the other side of the bridge is active. In the real world, how can we easily
switch from side to side? Well, if we add a single pole double
throw switch to the circuit now only half the bridge can be active
at any given time. I’m using a big switch for demonstration
purposes here but you don’t have to. Any switch that can handle 100 milliamps
will be fine. Alright, now instead of just forwards or
backwards, let’s control the speed of the motor. In a previous video I talked about a
technique called pulse width modulation and you can use it for speed control!
If we take the circuit from that video, we can use a potentiometer to get a
pulse width modulated signal. Here I am getting a square wave from
0 volts to 12 volts with a duty cycle ranging from nearly
zero to 100 percent. Now let’s just add that to the center
pole of the switch here and now we have a bi directional motor speed controller. Wait… what’s that noise? (Motor is making a whining noise)
(Arnold Schwarzenegger yells “Stop whining!”)
I can’t! The PWM frequency is 1kHz. That means power to the motor will be
pulsed in at 1kHz and that’s within hearing range. You’ll need a better H bridge circuit to
get rid of it. But as you can see, if you use PWM to change the percentage
time that current can flow through the motor, you change the average current of the
motor, which changes its speed. Finally, I want to highlight that it’s very
important to use the exact same components that I used in this circuit. The 555 timer should be an NE555 because it can source and sink a lot of
current on the output. A TLC555 will not work. And you should use the exact same MOSFETs
and the same resistor values. Alright, now you know what an H bridge is, and with
suitable components you can use this technique to build anything from an electric screwdriver to an
electric vehicle! Thank you for watching, subscribe, and check out the video
description section to see how you can support me if you want see more videos!

100 thoughts on “H Bridge Motor Speed Controller Tutorial

  1. What would be ideal for very low rpm's with high torque? Something like 5-10 rpm or even lower. I'm trying to make a variable speed power feed for my metal lathe. I've got plenty of dc motors laying around. I've got a few stepper motors as well, but they seem overly complicated for what I want to do. I need the low rpm's so I can get a finer finish without the need for hand polishing.

    On a metal lathe, the power feed is run from the spindle with a series of gears. You change gear sizes to get different feed rates. The feed is based on one revolution of the spindle. So, we say for every one revolution of the spindle, the carriage will move 0.003" of an inch. That's a relatively "coarse" fine feed and ideally you'd want something below one thousandths of an inch per rev.

    I'd like to be able to run this off of a dc wall transformer just to make it simple.

  2. what can i use to reverse the direction of rotation of an AC motor
    What can i use to increase and reduce speed of AC motor

  3. Is there a way to replace the switch for the current direction with a 555 chip or something to make the motor switch directions automatically?

  4. ¿what changes i need to do to this circuit to use it with a power supply of 19 volts 2.1 amps?

  5. I have a question, the mottor is controlled by a PWM, so we should be using a freewhel diode. But here the current flow in the two direction, so if we put a diode in parallel with the motor, there would have a short circuit when it rotates in the opposite direction.

    So why doesn't it blow up even without a freewheel diode?

  6. I have a doubt sir…I'm using a L293D IC (ready made dual H bridge) to control two DC motors …I'm a bit concerned that the back emf might damage my microcontrollers.What safety components must I use to make sure that my microcontroller is safe from the high input voltage on the motor ?

  7. Hi dear,
    Thanks for such a good tutorial. Is it mandatory to use 2 P-channel and 2 N-channel mosfet or 4 N-channel will serve the purpose? I've all IRF540N.

  8. Awesome explanation! Could you use an Arduino to turn on and off the transistors? Allowing to control the direction of the dc motor through software instead of a manual switch?

  9. I'm a newbie here and just asking to know, why don't we connect the positive terminal of the power supply to the center pin of one side of the switch and negative to the other center pin, then connect both of the outside pins on each side together so we use the switch as an H bridge? I've done that years ago for a school project without knowing a thing about electronics and this made me wonder.

  10. How can you use this with an Arduino controlling the logic? Like with only 2 wires, for PWM each direction. Also how would you stop the motors from spinning? This method you show would need 3 wires to control from an Arduino right? A PWM for the speed, plus which direction its going? Have not been able to find any specific info on how to turn the motors off when only using 2 wire control..

  11. +Afrotechmods the arabic subtitles are a joke. The maker literally translated "motor" as a fucking car!! and "H bridge" as a literal car bridge! Power as in literally power (i.e. person in charge) wtf… it's seems auto generated

  12. I’m a software developer and I came here to kinda relax my brain a little. Now my brain is more tired than it originally was. In another life, I’d like to be an electrical engineer.

  13. Hi there, I love how you explain your process! Thanks so much

    Is there any way to use a H-Bridge to control a DC motor and make it spin and stop at 4 or 5 separate points? Something that could operate a 4 way valve? Sorry I just have to ask…

  14. Could you use a small capacitor to smooth out the square wave through the motor, and thus reduce the 1Khz whine? Also, does attaching an inductive load directly to a mosfet, and feeding through a square wave, risk damaging the mosfet?

  15. hi, I am trying to copy your circuit to 3 dc motors (with reductions ), but the 3 IC 555 gets too hot, I am using 2p2t swicth for each motor instead of transistors, ac/dc adaptor 12v and 0.3 amp as power supply, what do you advice me ?? thanks in advance

  16. Can you show us how to find the Kn and Kp factor of the NMOS and PMOS on datasheets? Did you use it to find the drain voltages assuming the triode operation?

  17. Thanks for the info. great video, one question:
    What elements in the circuit should I change to make it work safely with a 24v 100w DC motor? I just want to control the speed of motor, reverse not necessary. Thank you.

  18. Hello ! , thanks for sharing this knowledge ! 🙂 , helps a lot ! ; Just have some questions please, help !
    Please I want to ask you,
    – Can I use another diode , replacement instead of the 1N4004 ? and the same for the MOSFETS ? , can I use replacements ?. which ones ?
    – What is the voltage on the 1000uf capacitor ? and Resistors ?
    Thanks a lot again !
    Will wait for you answer to go to the electronic shop , can´t wait 😀
    Greetings !

  19. Alternatively if you need to drive your motor with more current than the NE555 can handle, just connect its output to the gate of an N-channel MOSFET, and use the N-channel MOSFET to drive the motor directly. The MOSFET will be able to handle much more current than the NE555 ever could. 😉

  20. man…your videos are THE shit! spot on, easy to UNDERSTAND, easy to follow and easy to "rewind" n access specific info. no bull crap filler, good occasional humor and always SOLID FUNDAMENTAL INFORMATION! Great use of my time and throttled mobile connection EVERY SINGLE TIME I decide to click on an Afro! I appreciate the channel, the content, your knowledge & TIME! Thank YOU!

  21. Why do we use 2 p channel mosfets and 2 n channel mosfets instead of all n or p type mosfets? @Aftertechmods

  22. Hey! Great video! Just one comment: The speed of an DC motor is proportional to the terminal voltage, not to its current.

  23. Hey! could you please tell me about the MOSFETS? Because those links in the description are not working.
    -Thanks

  24. so odds are the answer to this question will be over my head but here goes nothing.. say I want to limit the amount of time i want the motor to stay on but at a constant speed, would a relay suffice?Also, I don't understand what the point is to all of the extra parts in the video when I was able to adjust the speed of my motor with an spdt switch, microcontroller and a potentiometer

  25. Interested in learning about wireless power? Subscribers can get up to 80% off Wireless Power to the People – Wireless Charging 101 on udemy using the coupon code "YOUTUBE"
    http://www.udemy.com/wireless-power-to-the-people-wireless-charging-101/?couponCode=YOUTUBE

  26. Very nice video.
    I have on request. Can you please tell me which types of MOSFET you used for this H bridge. I need to build that for school in Tuesday.
    Thank you

  27. Hello, i was wondering is it possible to control 555 ics dutycycle length?? What iam trying to do is ,spin a motor (brushed dc) to some clockwise and some anti clockwise to do this i need to produce a limited length pwm signal it is ofcourse much easier with arduino but can only 555 or any cheap ics can do this!!! I am going to feed this signal with any h bridges or h bridge ic s …
    And one more thing as i read that 555 can only produce any timing of certain points as 1, 5min…etc is it possible to bring down to seconds??
    In case there is no option without using 2. 555s one for pwm and one for length cut out…plz let me know.. Regards..

  28. Hey! I have a couple of questions:

    Are there advantages to using MOSFETs as opposed to power BJTs?
    Is there a reason for using a 1K-ohm resistor as opposed to a 2.2k-ohm resistor?
    We want to use the PWM signal from an Arduino, but those can only output 5V. If we're using a 12V source to power the motor, what can we do to the PWM signal from an Arduino to control the speed of the motor?

  29. Hey can you do a tutorial for something that can handle closer to 40 amps continuous? how to adjust frequency and how would I control the duty cycle with a temp sensor instead of a potentiometer

  30. Afrotechmods
    Maybe it's a stupid question, but why do you use PWM signal instead of just varying the resistance (so that the voltage at the switch and the speed of the motor change)

  31. Why do you put a fuse in series with positive side of your battery? I mean why did you mention the positive side? Shouldn't it work equally well on the other side?

  32. great video man. i have one question . can this circuit run for 15 minutes continuosly?? i have to make it as my semester project and my teacher says that i should run for 15 minutes at 9volts and 2 amps…. Thanks in advance

  33. Can I use separate voltage supplies for the NE555 and the H-Bridge? Do I need to have the same ground for everything?

  34. I didn't comprehend why is it necessary to use 4 PFETs to run the motor. If we wanted to run it with only the highest speed we could connect it directly to the Vsrc. If we wanted to be able to control the speed, couldn't we just put PWM in the middle? And to change direction we just needed a switch to change polarity. Of course I know I am wrong but why?

  35. I have a schematic for a two motor driver that uses the LM555 timer IC in an astable configuration and a single N-channel MOSFET (because I only want it in one direction), however its power supply is two 12V lead acid batteries is series, which means that I need to turn that into stable voltage of 24V likely using a buck-boost converter. Is there anything else in particular that you'd suggest?

  36. Thank you for the amazing demonstration. I am interested in building a high current motor driver where there should be 24 A continuous currrent. I figured out the MOSFETs that I will be using but I cannot figure out the values of resistors and capacitors that are required. Could you please help me?

Leave a Reply

Your email address will not be published. Required fields are marked *