It comes as no surprise that heavier robots and vehicles require bigger motors. Bigger motors generally require more voltage and current. In the case of my DIY segway, I needed enough power to propel not only the heavy duty chassis but my weight as well.
The motors I chose for this are 280 watt, 24 Volt electric scooter motors. In free-running mode (No load applied to the shaft), these motors draw around 1.5 Amps. During normal operation, they are rated to draw in the neighborhood of 10-12 amps. This far exceeds the rated current of my favorite motor controller, the L298. The compact L298 dual motor driver is only rated to 2 amps, which is surprising based on the size of the heat sink.
There are some good high current motor drivers available from sources like Trossen Robotics or Pololu. However, these usually cost upwards of $45 and I was needing to keep the cost of this project down to a minimum. In addition, another goal of this project was to build as many of the modules from scratch wherever possible.
As for the design of the motor driver, I took inspiration from jip’s Yet another FET-based H-bridge. In fact, this circuit is essentially the same with exception of the added diodes. I had all but given up on making my own motor driver until I happened upon this design.
The great thing about this circuit is it eliminates the risk of shoot-through by requiring one input to be LOW while the opposing input is HIGH. This design also allows the P-channel FETs to be fully on since the PWM signal is applied to transistors outside the N-Channel gates. Also known as low-side switching.
The Eagle schematic and board files are available for download at the bottom of this post.
The P-Channel FETs
P-Channel FETs are triggered by pulling the gate down to ground. The 10K pull-up resistor ensures the gate is in the off state when not being triggered.
The gates of the P-Channel FETs are connected to the collector of an NPN transistor. The base of the transistor is then connected to the “B” microcontroller output pin. When the NPN transistor is triggered, current is allowed to travel to ground through microcontroller pin “A” when it is in the LOW state.
This voltage drop pulls the P-channel gate low which in turn triggers it. This is only allowed to happen when “B” is HIGH and “A” is LOW.
The N-Channel FETs
N-Channel FETs are triggered by pulling the gate up to certain voltage. The gate is controlled by the actions of a pair of transistors. Essentially, the transistor closest to the gate of the FET is normally ON. This acts as a voltage divider, robbing the FET gate of all of it’s voltage. When this transistor is turned off, the full voltage is applied to the FET gate, opening it fully. This transistor is controlled by another transistor that is normally OFF and connected to the “B” microcontroller output pin. When this transistor is turned on, it robs the current going to the base of the transistor closest to the MOSFET gate, turning it OFF.
And finally, there is a transistor that acts as a final switch for the whole circuit. The base of this transistor is connected to the ENABLE output of the microcontroller. It is through this output that the PWM signal is applied.
Flyback diodes (also known as snubber diodes) provide an outlet for “backed up” voltage from an inductive load like a motor. One great thing about FETS is they already come equipped with their own flyback diodes. However, it’s not a bad idea to add your own to ensure the voltage is released as fast as possible. Schottky diodes are great choices for this appllication since they are generally fast switching and can be triggered at lower currents.
PWM (Pulse Width Modulation)
Motor speed is controlled by applying a PWM signal to a transistor on the low-side of the h-bridge. This transistor essentially forms an “AND-Gate” with the transistors controlling the N-Channel FET’s gate. Only when these transistors are on together will the load be allowed to travel through the H-bridge. This low-side switching allows the P-Channel FET’s to stay engaged eliminating the issue with switching speed often found with these.
For more on controlling the motor driver, see the next part in this series. Also, feel free to ask any questions in the forums or comments below.
Thanks, and happy building!