![]() |
Smart Car Controller
1.0
Library to manage a two wheeled robotic vehicle (DC Motors)
|
The library supports a number of inexpensive DC motor controllers. All use PWM as the mechanism for speed control.
Common to all these motor controllers is that there is no 'set' way to wire them to the motors. The direction of motor spin relative to the body of the vehicle it is attached to depends on the orientation of the motor and how the gearbox works as well as the way the motor is wired.
The best way to work out the wiring is to temporarily make the connections between motor and controller and use the test software and drive the motor 'forward'. If it spins in the wrong direction, reverse the wiring at the motor.
The L298N Motor Driver Module (see below), commonly available from low-cost online stores, is a high power motor driver module for driving DC and Stepper Motors. This module consists of an L298 motor driver IC and a 78M05 5V regulator which can be used to power the Arduino Board. L298N Module can control up to 4 DC motors, or 2 stepper motors, with directional and speed control.
ENA/ENB pins are PWM speed control pins for Motor A and Motor B while IN1/IN2 and IN3/IN4 are direction control pins for Motor A and Motor B. Motors are connected to OUT1/OUT2 and OUT3/OUT4.
An external power supply up to 12V can be connected to the screw connectors to supply power for the motors. This voltage can also feed the 5V regulator to power the Arduino processor board. If the processor has its own 5V supply, then the '5V Enable' jumper should be removed to disable this function.
The L293D is another commonly available 16-Pin Motor Driver Module to drive small motors. A single L293D IC is capable of running two DC motors at the same time with independent direction and speed control.
This controller is physically smaller than the L298N and can control less motor current, but it has essentially the same control pins, output terminals and control mechanism as the L298N, so can be considered a drop in replacement.
The MX1508 Motor Driver Module is an highly inexpensive driver module available from low-cost online suppliers. It has specifications similar to the L293D and looks like it is a low cost Chinese version of the DRV8833 Controller IC, with a few less functions. The MX1805 module can control up to 2 DC motors, with directional and speed control.
IN1/IN2 and IN3/IN4 are direction control pins for Motor A and Motor B. These double as speed control pins using PWM. Motors are connected to OUT1/OUT2 and OUT3/OUT4 (MOTOR-A and MOTOR-B solder pads).
An external power supply up to 10V can be connected to the screw connectors to supply power for the motors. This module does not have a 5V regulator so the Arduino processor must be powered separately.
The DRV8833 is a low voltage, 2A stepper or single/dual brushed DC motor driver.
Similar to the M1805, IN1/IN2 and IN3/IN4 are direction control pins for Motor A and Motor B. These double as speed PWM control pins. Motors are connected to OUT1/OUT2 and OUT3/OUT4. Additionally the DRV8833 has an output status pin to signal fault mode and an input to put the device into 'sleep' mode for very low power consumption.