The L298N Dual-H Motor Driver Motor is a high power motor driver module for driving DC motors and stepper motors. This module has an L289N driver IC, 5V regulator, 5V jumper, a power LED, and a heat sink. This module can control a single DC motor, 2 DC motor, and 4 DC motor. This driver is used to control the speed and direction of the motor.
The voltage regulator will be enabled only when the jumper is placed when the DC supply is less than or equal to 12V, the internal circuitry will be powered by the voltage regulator and the 5V pin can be used as an output pin to power your microcontroller or development board. The jumper should not be placed when the voltage is greater than 12V and separate 5V should be given through the 5V terminal to power the internal circuitry.
The jumper should not be placed when the voltage is greater than 12V and separate 5V should be given through the 5V terminal to power the internal circuitry.
- ENA: Enables PWM signal for motorA which controls the speed of the motorA
- ENB: Enables PWM signal for motorB which controls the speed of the motorB
- IN1 & IN2: MotorA input pins used to control the direction of rotation of MotorA
- IN3 & IN4: MotorB input pins used to control the direction of rotation of MotorB
- OUT1 & OUT2: Output pins for motorA
- OUT3 & OUT4: Output pins for motorB
- GND: Ground pin
- 5V: Supplies power for switching Logic circuitry inside the motor driver
Now I am going to show you how the L289N motor driver controls the dc motors. The L289N controls the direction of the motor by reversing the direction of the current flow through the motor, The motor driver has an H-bridge containing four switching elements, transistors and the motor at the center forming an H-like configuration.
By activating two particular switches at the same time we can change the direction of current flow thus changing the direction of rotation of the motor.
We can control the speed of the motor by controlling the input voltage to the motor and one of the methods of doing so is by using the PWM signal. Combining the H-bridge manipulation and the PWM signal you can have complete control of the motor
Follow the steps below to configure the motor controller board to work as a basic motor driver for a robot that is using two DC motors.
- Attach your robot’s motors to the green Motor A and Motor B screw terminals.
- Connect the ENA and ENB to PWM capable digital outputs on your robot’s microcontroller.
- Connect the IN1, 2, 3, and 4 pins to any digital outputs your robot’s microcontroller.
- Apply 5-16V to the board by connecting positive (+) to the blue VMS screw terminal and ground (-) to the blue GND screw terminal.
- See below for details on controlling the motors with your robot’s microcontroller.
All inputs are TTL compatible. If you plan to supply more than 16V to your motors do not enable the onboard 5V regulator.
You can control the speed of the motors by connecting PWM outputs from your robot’s microcontroller to the ENA and ENB input pins on the motor driver board. The ENA pin controls the Motor A and the ENB pin controls the Motor B. At the point when these pins are HIGH i.e receive power, the motor also gets powered.
By using the PWM, we are turning the power on and off to adjust the speed of the motor and the longer the PWM duty cycle is, the faster the motor will turn. It’s recommended you always use a PWM duty cycle of 90% or less.
By using the IN1, IN2, IN3, and IN4 input pins on the motor driver board, we can control the direction that the motors turn. Connect these pins to digital outputs on your robot microcontroller. To make the Motor A move forward, set IN1 = HIGH and IN2 = LOW. To make the Motor A move backward set IN1 = LOW and IN2 = HIGH. The same method is used to control the Motor B, set IN3=HIGH and IN4 = LOW to move forward and set IN3 = LOW and IN4 = HIGH to move backward.
Note that the “forward” and “backward” movement refer to the direction of the motors themselves. If the robot does not move in the expected direction, you can reverse the motor polarity by swapping the green screw terminals for the Motor A + and – and/or Motor B + and –.
To remove power from the motors, just set ENA = LOW for your Motor A and ENB = LOW for the Motor B. This will make the motors to stop slowly and naturally from the friction. To perform a quick braking operation, simply set the ENA = LOW, IN1 = LOW, and IN2 = LOW for the Motor A and ENB = LOW, IN3 = LOW, and IN4 = LOW for Motor B and the motors will come to an instant stop.
Enjoyed reading about this component see our other posts here