Difference between revisions of "DC Motor Driver Breakout (L298 Chipset)"
(→Arduino Sample Code) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
PWM control, I2, I1, I4 and I3 are used to control the direction of the DC motors. | PWM control, I2, I1, I4 and I3 are used to control the direction of the DC motors. | ||
+ | |||
+ | [[File:Solid L298N 1.jpg | 400px]] | ||
==Specification== | ==Specification== | ||
Line 30: | Line 32: | ||
==Interface== | ==Interface== | ||
− | [[File:DC motor.jpg]] | + | [[File:DC motor.jpg | 600px]] |
==Schematic== | ==Schematic== | ||
− | * | + | *[https://s3.amazonaws.com/linksprite/robot/motordriver/1333172687.pdf Schematic] |
==Arduino Sample Code== | ==Arduino Sample Code== | ||
+ | |||
+ | <syntaxhighlight lang="c"> | ||
+ | unsigned char PWM = 100; | ||
+ | int incomingByte = 0; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | pinMode(2,OUTPUT); | ||
+ | pinMode(3,OUTPUT); | ||
+ | |||
+ | pinMode(5,OUTPUT); | ||
+ | pinMode(6,OUTPUT); | ||
+ | |||
+ | analogWrite(10, PWM); | ||
+ | analogWrite(9, PWM); | ||
+ | |||
+ | Serial.begin(9600); | ||
+ | } | ||
+ | void loop() | ||
+ | { | ||
+ | if(Serial.available() > 0) | ||
+ | { | ||
+ | incomingByte = Serial.read(); | ||
+ | switch(incomingByte) | ||
+ | { | ||
+ | case 'w': | ||
+ | digitalWrite(2,HIGH); | ||
+ | digitalWrite(3,LOW); | ||
+ | digitalWrite(6,HIGH); | ||
+ | digitalWrite(5,LOW); | ||
+ | delay(300); | ||
+ | digitalWrite(2,HIGH); | ||
+ | digitalWrite(3,HIGH); | ||
+ | digitalWrite(6,HIGH); | ||
+ | digitalWrite(5,HIGH); | ||
+ | break; | ||
+ | case 's': | ||
+ | digitalWrite(3,HIGH); | ||
+ | digitalWrite(2,LOW); | ||
+ | digitalWrite(5,HIGH); | ||
+ | digitalWrite(6,LOW); | ||
+ | delay(300); | ||
+ | digitalWrite(2,HIGH); | ||
+ | digitalWrite(3,HIGH); | ||
+ | digitalWrite(6,HIGH); | ||
+ | digitalWrite(5,HIGH); | ||
+ | break; | ||
+ | case 'a': | ||
+ | digitalWrite(2,HIGH); | ||
+ | digitalWrite(3,LOW); | ||
+ | delay(300); | ||
+ | digitalWrite(2,HIGH); | ||
+ | digitalWrite(3,HIGH); | ||
+ | break; | ||
+ | case 'd': | ||
+ | digitalWrite(6,HIGH); | ||
+ | digitalWrite(5,LOW); | ||
+ | delay(300); | ||
+ | digitalWrite(6,HIGH); | ||
+ | digitalWrite(5,HIGH); | ||
+ | break; | ||
+ | case 'j': | ||
+ | if(PWM<220) | ||
+ | PWM +=30; | ||
+ | analogWrite(10, PWM); | ||
+ | analogWrite(9, PWM); | ||
+ | break; | ||
+ | case 'k': | ||
+ | if(PWM>100) | ||
+ | PWM -=30; | ||
+ | analogWrite(10, PWM); | ||
+ | analogWrite(9, PWM); | ||
+ | break; | ||
+ | default:; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </syntaxhighlight> |
Latest revision as of 17:44, 23 April 2014
Description
This LinkSprite DC motor driver board uses one L298N, and can control two motors.
The LinkSprite DC motor driver uses L298N as the driver chip. A 7805 is added to the boardas the power supply of the logic circuit portion. Jumper P4 can be used to determine if 7805 is used or not. There are also optional pull-up resistors to used for the MCUs of weak output driving capability. Diodes are added to prevent the reverse output of DC motor that hurts L298N.
VMS is the power supply of the driving circuit.
+5V is the power supply of the logic circuit.
VCC is the driving pin of the motor.
EA and EB are the two enabling pins of the dual-H bridges.
PWM control, I2, I1, I4 and I3 are used to control the direction of the DC motors.
Specification
- chipset: L298N
- Driving power supply voltage Vs: +5V to +46V
- Peak current of driving power supply Io: 2A
- Vss: +5V to +7V
- Current of logic power supply: 0 - 36mA
- PWM control signal range:
- Low level: -0.3V < Vin < 1.5V
- High level: 2.3V < Vin< Vss
- Enable signal range:
- Low level: -0.3V
- High level: 2.3V < Vin< Vss
- Maxium power consumption: 25W
- Working temperation: -25C to 130C
Interface
Schematic
Arduino Sample Code
<syntaxhighlight lang="c"> unsigned char PWM = 100; int incomingByte = 0;
void setup() {
pinMode(2,OUTPUT); pinMode(3,OUTPUT);
pinMode(5,OUTPUT); pinMode(6,OUTPUT); analogWrite(10, PWM); analogWrite(9, PWM); Serial.begin(9600);
} void loop() {
if(Serial.available() > 0) { incomingByte = Serial.read(); switch(incomingByte) { case 'w': digitalWrite(2,HIGH); digitalWrite(3,LOW); digitalWrite(6,HIGH); digitalWrite(5,LOW); delay(300); digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(6,HIGH); digitalWrite(5,HIGH); break; case 's': digitalWrite(3,HIGH); digitalWrite(2,LOW); digitalWrite(5,HIGH); digitalWrite(6,LOW); delay(300); digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(6,HIGH); digitalWrite(5,HIGH); break; case 'a': digitalWrite(2,HIGH); digitalWrite(3,LOW); delay(300); digitalWrite(2,HIGH); digitalWrite(3,HIGH); break; case 'd': digitalWrite(6,HIGH); digitalWrite(5,LOW); delay(300); digitalWrite(6,HIGH); digitalWrite(5,HIGH); break; case 'j': if(PWM<220) PWM +=30; analogWrite(10, PWM); analogWrite(9, PWM); break; case 'k': if(PWM>100) PWM -=30; analogWrite(10, PWM); analogWrite(9, PWM); break; default:; } }
}
</syntaxhighlight>