Go Down

Topic: L298N connection details, (Read 1 time) previous topic - next topic

sailezzy

Jun 16, 2012, 12:34 pm Last Edit: Jun 16, 2012, 12:44 pm by sailezzy Reason: 1
Although there seems to be a few topics related to the L298N I'm still having difficulty in working out how to connect this one, the board we've bought is - http://www.rcubestation.com/r3cart/index.php?route=product/product&product_id=75
There were no connection details when it arrived and have only been able to get the attached schamatic from the seller.
The board has a number of terminals, jumpers and header plugs, these are (with my assumed usage),

Terminals
5V - +5v for the board?
GND - Common ground
VCC - +V for the motors

Jumpers
ENA - +5v pull up to enable motor A
ENB - +5v pull up to enable motor B
PWM1 - ?
PWM2 - ?

Header plug 1
GND - Common ground
5V - +5v for the board logic
ENB - Motor B enable used inplace of the jumper ENB above
ENA - Motor A enable used inplace of the jumper ENA above
IN1 - ?
IN2 - ?
IN3 - ?
IN4 - ?

Header plug 2
A1 - ?
A2 - ?
B1 - ?
B2 - ?

The seller has also given the following sketch which suggest a logic input for Forward and another for Backwards for each motor and one input for the speed PWM for each motor, (I've remove the matching motor B code for clarity as it matches motor A)
Code: [Select]
// motor A
int dir1PinA = 13;
int dir2PinA = 12;
int speedPinA = 10;
unsigned long time;
int speed;
int dir;
void setup() {
pinMode(dir1PinA, OUTPUT);
pinMode(dir2PinA, OUTPUT);
pinMode(speedPinA, OUTPUT);
time = millis();
speed = 0;
dir = 1;
}
void loop() {
analogWrite(speedPinA, speed);
// set direction
if (1 == dir) {
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
} else {
digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinA, LOW);
}
if (millis() - time > 5000) {
time = millis();
speed += 20;
if (speed > 255) {
speed = 0;

}
if (1 == dir) {
dir = 0;
} else {
dir =1;
}
}
}

Any assistance will be appreciated,
Thanks,
Michael.

JimboZA

Each motor is driven by three logic signals: ENA enables motor A, and if you PWM it from an Arduino PWM pin you can regulate the speed; or just have it high or low to have that motor on or off. Then the two inputs IN1 and IN2 control the direction of motor A... high / low will give one direction, low / high the other way. IN3 and IN4 are for motor B along with ENB.

Seems that the jumpers might set it for either on (enabled) or PWM'd?

HTH
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

Go Up