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!