In robotics, there are many types of motors such as DC motors, servo motors, stepper motors, etc. Choosing the right motor for a robotics project depends on the user’s intended application and there are different ways to use them.
Some motors can directly be controlled and run in a variety of ways, such as connecting a power supply directly to them. But if we want to control these motors using other control devices like wireless systems, microcontrollers, etc., we need something known as “MOTOR DRIVERS”.
Motor drivers act as interfaces between motors and control circuits. The motor requires high current while the controller circuit operates on low current signals. Therefore, the function of motor drivers is to take a low current control signal and convert it into a higher current signal that can drive the motor.
An overview of the L298N Motor driver
The L298 is an integrated monolithic circuit in a 15- lead Multiwatt and PowerSO20 packages. It is a high voltage, high current dual full-bridge driver designed to accept standard TTL logic levels and drive inductive loads such as relays, solenoids, DC and stepping motors. Two enable inputs are provided to enable or disable the device independently of the input signals. The emitters of the lower transistors of each bridge are connected together and the corresponding external terminal can be used for the connection of an external sensing resistor. An additional supply input is provided so that the logic works at a lower voltage.
Specification
- DC Output Current: 2A
- Output Channels: 2
- VM: 7.5V to 30V
- Output type: Analog-Voltage
For more specifications, please refer to datasheet
GebraBit L298N module Key Features
- On Board, ON/OFF LED indicator
- On Board LED indicator for direction and PWM pins
- On Board 5V regulator
- Control Pin access with IDC connector
- Screw terminal blocks for power and motor connections
- GebraBit Pin Compatible with GEBRABUS
- It can be used as a daughter board of GebraBit MCU Modules
- Featuring Castellated pad (Assembled as SMD Part)
- Separatable screw parts to reduce the size of the board
- Package: GebraBit large (36.29mm x 61.23mm)
- Schematic (.pdf)
GebraBit L298N module
Gebrabit L298N is a 4A, up to 35V dual channel motor driver module which needs two separate power supplies for the internal circuitry and motors. The internal circuitry operates with a 5V through the “5V” pin or onboard module regulator. Users can connect motors to the GebraBit L298N with voltages between 5 to 35V with a peak current up to 2A. Users can access the most important pins of the L298N through the GebraBit L298N module. And also, for easy accessibility, GebraBit L298N gives access to the “5V”, “GND”, and “IN1”, “IN2”, “IN3”, “IN4”, “ENA”, ” ENB” pins by a 2×4 pin IDC connector to extend them on other boards.
To use this module it is enough to put the GebraBit L298N module in the BreadBoard, then by applying the proper voltage, set-up the GebraBit L298N module. Because of the compatibility of the GebraBit L298N module pins with the GebraBit STM32F303 pins, we recommend using the GebraBit STM32F303 microcontroller development module for testing and setting up this module.
To do so, you just need to put the GebraBit L298N module as Pin-to-Pin on the GebraBit STM32F303 module.
Introduction of module sections
L298N motor driver
It’s the main IC of the following module, which is in charge of controlling the motors and is placed in the top of the module.
“5V EN” Jumper and 5V regulator
The onboard regulator output will be enabled only when the “5V EN” jumper has been shorted; then, the internal circuitry will be powered by the voltage regulator, and the “5V” pin can be used as an output.
Note: Must not connect a separate power supply to the “5V” pin when the “5V EN” jumper has been shorted.
Motor terminal block
GebraBit L298N has two screw terminal blocks for “OUT1” to “OUT4” to connect motors.
AS you can see in the below pic, the left terminal block is installed for”OUT1” and “OUT2” and the right one is for “OUT3” and “OUT4”.
power supply terminal block
The third terminal block on this module is the power supply terminal which is considered to connect “VIN”, “GND” and “V5” to the module.
Enable pins LEDs
Each of the module enable pins, which are intended to control the speed of the motors, have a dedicated LED, which will turn on when the proper voltage is applied to each of these pins.
IN pins LEDs
Each of the “IN1”, “IN2”, “IN3”, “IN4” pins of the module, which are intended to control the movement direction of the motors, have a dedicated LED, which will be lit by applying the proper voltage to each of these pins.
signal port
For easier access to the “5V”, “IN1”, “IN2″,” IN3″, “IN4”, “ENA”,” ENB” and “GND” pins, an ” IDC-2×4″ connector is installed on the GebraBit L298N module, which helps the users to connect to the mentioned pins easier just by connecting a proper IDC cable to this connector.
You can see how the pins are arranged in the below picture.
ON/OFF detection LED
By applying voltage to the module through the corresponding pins, this LED will be lit.
GebraBit L298N Module pins
Supply pins
- VIN: The “VIN” pin gives power to the internal H-Bridge of the IC to drive the motors and the onboard integrated regulator.
- 5V: The internal circuitry operates with a 5V through the “5V” pin or onboard module regulator. it means this pin is in charge of supplying the main power supply to the module. also when the “5V EN” jumper has been shorted; the internal circuitry will be powered by the regulator voltage, and the “5V” pin can be used as an “output”.
- GND: This is the ground pin of the module.
Current measuring pins
SENA and SENB: these two pins can be used to measure the current. Each of these two pins has an on-board dedicated selector jumper, If the jumper corresponding to the desired pin is connected to a resistor, the current can be measured through the corresponding pin, and if There is no need to measure the current, it is enough to short the corresponding jumper by completely covering the surface of the jumper with tin.
In GebraBit L298N modules, both SENA and SENB jumpers are shorted by default.
Speed control pins
- ENA and ENB: these two pins can be used as speed control (PWM) pins.
Direction control pins
- IN1,IN2,IN3 and IN4: “IN1” and “IN2” pins are the direction control pins for motor A and the “IN3” and “IN4” are the direction control pins for motor B.
By applying voltage to the “IN1/IN3” Pin, motor A/B is ON and turning forwards and by applying voltage to the “IN2/IN4” Pin, motor A/B is ON and turning backwards.
Connect to the processor
connect to GebraBit STM32F303
To connect the GebraBit L298N module to the GebraBit STM32F303 microcontroller module, due to the compatibility of the pins of this module with the GebraBit STM32F303 pins, it is enough to place it on the microcontroller as Pin to Pin.
Here, due to the same size of the GebraBit L298N module as the GebraBit STM32F303 microcontroller module, to better understand how to connect, instead of pin to pin connection, we have separated the modules and made connections using jumpers.
In this connection method, just connect each pin of GebraBit L298N module to its corresponding pin on GebraBit STM32F303.
You can see how to connect the two modules according to the above mentioned Descriptions, in the below picture:
Note: As explained in the “power supply pins” section, the GebraBit L298N module works with “5V” voltage supplied either through the “5V” pin or the internal regulator, when the “5V” regulator is selected as the module power supply (i.e. jumper “5V EN” is connected) the IC is powered by the regulator and the “5V” pin can be used as an output. In GebraBit L298N module, the “5V” jumper is tinned and is shorted, by default. As a result, the “5V” regulator is active and you can easily connect the “9V” power supply to the “VIN” pin of the GebraBit L298N module and use the GebraBit L298N “5V” pin as an output. By connecting the “5V” pin of the GebraBit L298N module to the “5V” pin of the microcontroller, the supply voltage of the microcontroller is also provided. In fact, here the microcontroller module gets its power from the L298N module.
connect to GebraBit ATMEGA32A
To connect the GebraBit L298N module to the GebraBit ATMEGA32A microcontroller module, after connecting the “GND” and “5V” pins of the two modules, it is enough to connect each of the “ENA” and “ENB” pins of the GebraBit L298N module to one of the GebraBit ATMEGA32A “PWM” pins (OC1A and OC1B pins) and then Connect the “IN” and “SEN” pins to the other pins of the microcontroller.
According to what we explained about the “SENA” and “SENB” pins earlier, if the jumpers are connected, the current cannot be measured through these pins, so since the “SENA” and “SENB” jumpers are connected by default in the GebraBit L298N module, there is no need to connect the “SENA” and “SENB” pins.
Attention: We applied 9V voltage to the modules assuming that the “9V” voltage does not harm the motors.
connect to ARDUINO UNO
follow the below steps to connect the GebraBit L298N module to the ARDUINO UNO:
- Connect the “5V” pin of L298N module to the “5V” output pin of the ARDUINO UNO board. (red wire)
- Connect the “GND” pin of the L298N module to the “GND” pin of the ARDUINO UNO board (black wire).
- Connect the “VIN” pin of the L298N module to the “VIN” pin of the ARDUINO UNO board.(blue wire)
- Connect each of the “ENA” and “ENB” pins of the L298N module to one of the “PWM” pins of the Arduino UNO board. (purple and green wires)
- Connect each of the “IN” pins of the L298N module to one of the ARDUINO UNO board pins.
According to what we explained about the “SENA” and “SENB” pins, these pins remain unconnected.
Note: when you use the Arduino board to start the L298N module, if your Arduino board is connected to the computer (PC) and gets its power from the USB port of the PC, you should note that the PC USB port does not flow more than 500mA. So we recommend you use a better voltage source for Arduino. (The current consumption of this module when no motor is connected and all the LEDs are on is about 60mA and when the “6V” motor is connected to the two outputs it is about 300mA)
You can see how to connect the two modules according to the above mentioned Descriptions, in the below picture:
Attention: When applying voltage to the “VIN” pin, pay attention that the applied voltage is not higher than the maximum working voltage of the motors you have, otherwise the motors will be damaged.