There are many methods to control the speed of a DC motor, in our case the 50:1 gear ratio Polulu part 2203. The simplest of which being to vary the amount of voltage across the motor. This can be done using a variable resistor in series with the motor: when the resistance is increased, the resistor’s voltage drop will be higher and thus the motor will receive less voltage. However, this comes with a few downsides. We observed through experimentation that the motor is usually at its lowest speed when the motor has a voltage of 3V. If we are using a supply voltage of 4.8V, this would result in nearly half of the supply voltage applied just across the resistor and therefore a significant amount of power uselessly dissipated.
Instead, we used a method called Pulse-Width Modulation to avoid wasting power. This involves the periodic switching of a voltage supply between the supply voltage and 0V, with the total “on time” being varied to adjust the average power delivered, usually measured with duty-cycle.
The next aspect to consider of motor control is changing direction, and braking. Reversing the direction of a motor is achieved by simply reversing the polarity of the power supply fed to the motor, and stopping the motor is achieved by putting the motor in series with a very high impedance. These methods are slightly hard to implement using only a microcontroller, and as such, an “H-Bridge” is used, a simple switching circuit that can put the motor in forwards and reverse polarity, as well as providing a high impedance.
In this project we used the DRV8835 Dual Motor Driver circuit. Depending on which of the two input pins for each motor was supplied with PWM signal, it performs the relevant logic to drive the motor in the desired direction. When both inputs receive supply voltage, it engages high impedance brake-mode, and when neither input has any input voltage, the wheels free-wheel.
Inputs and the corresponding outputs for DRV motor driver
Input 1 | Input 2 | Result |
Vcc | 0V | Forwards |
0V | Vcc | Backwards |
Vcc | Vcc | Brake |
0V | 0V | Free wheel |