Configuring L298N Motor Driver

Configuring L298N Motor Driver

Overview

We can simply control the our DC Motor by using L298N Motor Driver by controlling input voltage to the motor. Its also can be done by controlling PWM signal.

Control Speed of Motor by using Pulse Width Modulation (PWM)

Pulse Width Modulation is a method which allows us to adjust the average value of the voltage which we can varies the speed of the motor. The average voltage depends on the duty cycle or amount of time the signal is HIGH and amount of time of signal LOW in period of time.

H – Bridge DC Motor Control

H-Bridge Motor Control is a method to control the direction of DC Motor whether to be clockwise or anti-clockwise rotation.

Clockwise Rotation

In this figure,when S1 and S4 is closed,current will flow through the positive terminal of motor and will give us clockwise rotation.

Anti-Clockwise Rotation

On the other hand,when S2 and S3 is closed the current will flow through the negative terminal of our motor and this will give us an anti-clockwise rotation.

L298N Pinout
L298N Module

L298N basically can control maximum of 2 motors which maximum voltage of 12V. Enable Pin (ENA & ENB) is a PWM Control Pinout to control the speed of the motors. Input pinout is to control the direction of the motor whether to be clockwise or vise versa.

Specification
  • Driver Model: L298N 2A
  • Driver Chip: Double H Bridge L298N
  • Motor Supply Voltage (Maximum): 46V
  • Motor Supply Current (Maximum): 2A
  • Logic Voltage: 5V
  • Driver Voltage: 5-35V
  • Driver Current:2A
  • Logical Current:0-36mA
  • Maximum Power (W): 25W
  • Current Sense for each motor
  • Heatsink for better performance
  • Power-On LED indicator
Connecting Arduino with L298N
/* Arduino L298N Control by Roboshop Technologies Sdn Bhd */

//Setup Variable
const int ENA = 9;
const int ENB = 3;
const int IN1 = 7;
const int IN2 = 6;
const int IN3 = 5;
const int IN4 = 4;

void setup(){
pinMode(ENA,OUTPUT);
pinMode(ENB,OUTPUT);
pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
pinMode(IN3,OUTPUT);
pinMode(IN4,OUTPUT);
}

void loop(){
//Motor 1 Clockwise
analogWrite(ENA,255); //speed can be 0-255
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);

//Motor 2 Anti-Clockwise
analogWrite(ENB,255);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);

//Motor 1 & 2 Stop
analogWrite(ENA,0); 
digitalWrite(IN1,LOW);
digitalWrite(IN2,LOW);
analogWrite(ENB,0);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,HIGH);
}

Leave a Reply