Dual H-Bridge Motor Driver

From GOF_Wiki
Jump to: navigation, search

Contents

Introduction

This Dual H-Bridge Motor Driver Shield, which based on H-bridge driver Chip L298N Motor Driver Integrated Circuit, is a usefull module for controlling of robotics and mechanics. It can drive two brushed DC motors or one 4-wire two-phase stepper motor. 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.Both motors can be driven simultaneously while set to a different speed and direction. All driver lines are diode protected from back EMF.


L298N 3.jpg

Features

Specifications

Application Ideas

Cautions

  • Ensure that the positive and negative pole connected to the VMS and GND
  • Input voltage not exceeding 35V

Hardware Diagram

L298N 1.jpg

Port name Direction Description Usage
VMS GND / connect to external power supply(6V~35V) ENA(ENB) connected to H state will enable MOTORA(MOTORB) IN1(IN3) connected to 5V and IN2(IN4) to GND MOTORA(MOTORB) will move clockwise IN1(IN3) connected to GND and IN2(IN4) to 5V MOTORA(MOTORB) will move Anti-clockwise if you want to control speed you can connect the ENA(ENB) to PWM.
ENA Input TTL Compatible Enable Input:the L state disables the bridge A
IN1 Input TTL Compatible Inputs of the Bridge A
IN2 Input TTL Compatible Inputs of the Bridge A
ENB Input TTL Compatible Enable Input:the L state disables the bridge B
IN3 Input TTL Compatible Inputs of the Bridge B
IN4 Input TTL Compatible Inputs of the Bridge B
M)TORA Output Output of the Bridge A
MOTORB Output Output of the Bridge B
CSA(CSB) / use for testing electric current of Bridge A(Bridge B)
UR1 UR2 UR3 UR4 / pull-up resistor
5V +5V / 5V output
5V Chip Enable Jumper / if connected,5V chip will work.

Getting Started

How to use Jumpers

When you connect the 5V-Enable,the 78M05 will output 5V to supply logic chip,if you take off,you must connect 5V to supply logic chip.

Only if you connect IN1(IN2 IN3 IN4) to MCU which have ports of strong driving ability such as AVR,you can take off the jumpers.

How to connected to your control board

DC motor input port A has three pins,IN1,IN2 and ENA.IN1 and IN2 are digital ports which are used to control the direction of motor,ENA is usually connected to PWM port of control board to control the speed of motor,also it can be connected to digital port. we can control the 4-wire stepping motor the same way as two DC motors with the signal form ENA,IN1,IN2 and ENB,IN3,IN4.

Examples

Drive Two DC Motors

DC motor.jpg

To do this Demo required:

Connect Arduino and L298 shield according to program notes,then upload the sketch to the Arduino board.

int ENA=5;//connected to Arduino's port 5(output pwm)
int IN1=2;//connected to Arduino's port 2
int IN2=3;//connected to Arduino's port 3
int ENB=6;//connected to Arduino's port 6(output pwm)
int IN3=4;//connected to Arduino's port 4
int IN4=7;//connected to Arduino's port 7
void setup()
{
 pinMode(ENA,OUTPUT);//output
 pinMode(ENB,OUTPUT);
 pinMode(IN1,OUTPUT);
 pinMode(IN2,OUTPUT);
 pinMode(IN3,OUTPUT);
 pinMode(IN4,OUTPUT);
 digitalWrite(ENA,LOW);
 digitalWrite(ENB,LOW);//stop driving
 digitalWrite(IN1,LOW); 
 digitalWrite(IN2,HIGH);//setting motorA's directon
 digitalWrite(IN3,HIGH);
 digitalWrite(IN4,LOW);//setting motorB's directon
}
void loop()
{
  analogWrite(ENA,255);//start driving motorA
  analogWrite(ENB,255);//start driving motorB
 
}

Drive Two phase 4-wire stepping motor

Step motor.jpg

To do this Demo required:

Firstly,we should use the multimeter to detect the 4 wires,the 2 wires which connected is a group.In this example,the red wire and gray wires are a group(call A group),the yellow wire and green wire are a group(call B group).Connect Arduino and L298 shield according to the picture above and program notes,then upload the sketch to the Arduino board.

int ENA=2;//connected to Arduino's port 2
int IN1=3;//connected to Arduino's port 3
int IN2=4;//connected to Arduino's port 4
int ENB=5;//connected to Arduino's port 5
int IN3=6;//connected to Arduino's port 6
int IN4=7;//connected to Arduino's port 7
 
void setup()
{
 pinMode(ENA,OUTPUT);
 pinMode(ENB,OUTPUT);
 pinMode(IN1,OUTPUT);
 pinMode(IN2,OUTPUT);
 pinMode(IN3,OUTPUT);
 pinMode(IN4,OUTPUT);
 digitalWrite(ENA,HIGH);//enablae motorA
 digitalWrite(ENB,HIGH);//enable motorB
}
void loop()
{/*In the way of 4 beats to drive the stepping motor,A group connected to motorA,B
 B group connected to motorB,Suppose A representing the forward current of A group,
 A- representing the reverse current of A group,B representing the forward current of B group,
 B- representing the reverse current of B group.
 this way run as follow:
 AB    A-B    A-B-   AB-
 or
 AB   AB-    A-B-   A-B
 */
 digitalWrite(IN1,LOW);
 digitalWrite(IN2,HIGH);
 digitalWrite(IN3,HIGH);
 digitalWrite(IN4,LOW);
 delay(10);
 digitalWrite(IN1,LOW);
 digitalWrite(IN2,HIGH);
 digitalWrite(IN3,LOW);
 digitalWrite(IN4,HIGH);
 delay(10);
 digitalWrite(IN1,HIGH);
 digitalWrite(IN2,LOW);
 digitalWrite(IN3,LOW);
 digitalWrite(IN4,HIGH);
 delay(10);
 digitalWrite(IN1,HIGH);
 digitalWrite(IN2,LOW);
 digitalWrite(IN3,HIGH);
 digitalWrite(IN4,LOW);
 delay(10);
}

Resources

L298 datasheet

How to buy

Dual H-Bridge Motor Driver can be ordered through the GOF store. Its product page is located here

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.

Personal tools
Variants
Actions
Navigation
Support
Toolbox