Driver Shields L293D
Driver Shields L293D
- Current Requirement
The second thing is to know what the current requirement of your motor is. The driving chip on the motor
shield is designed to provide as high as 600mA and 1.2A peak. You need to install the heatsink when the current is
close to 1A, otherwise the chip may break.
Require larger power?Buy another piece of L293D driver solder it to one driving chip piggyback. look!Double
current driving capability! You can solder 2 or more, until it cannot bring more benefit to you.
You cannot use a 9V battery to drive the motor. Do not waste your time and batteries! Use a big Lead-acid battery or
Ni-MH battery pack. Suggest use two independent powers, one for Arduino and the other is for motor driving. 99%
strange questions came from power line noise caused by shared power or the power supply is not enough
DC motor is powered by high voltage instead of regular 5V. Do not connect the motor power to 5V line. It is bad unless
you know what you are doing.
There are 2 ways to power your motor using high voltage. One is the DC barrel on the Arduino, and the other one is
the 2-pin header on the motor shield marked as EXT_PWR. You won’t make damage if you connect wrong polarity as
there is a protection diode after the DC barrel on the Arduino board. However, the EXT_PWR on motor shield board
doesn’t have the protection diode (for a nice reason). So you have to be careful, or may burn your motor shield or
Arduino.
Note: you may see Arduino resets if the power is not enough. So it’s not recommended to use this approach.
If you want to use USB to power up Arduino, and use another DC supply to power up the motor, plug USB to Arduino,
and connect DC power supply to PWR_EXT on the motor shield. Note: please don’t install the power jump on the
motor shield. This is the way we recommend to power up the motor.
(if you use Diecimila Arduino, don’t forget to set Arduino power jumper to USB).
If you want to use 2 separate DC powers for Arduino and motor, plug in the power supply to DC barrel of Arduino, and
connect the other power supply to PWR_EXT on the motor shield. Remove the power jumper on the motor shield.
If you use Diecimila Arduino,set Arduino jumper as EXT. We suggest you use this way to power your motor.
There is an advantage if you use onboard PWM. It has precise logic and has background processing. You can use
Arduino’s servo library to control the servo motor.
It’s very simple to use servo motor. Please read official Arduino files which have Arduino usage and relate servo motor
sample programming.
- DC Motor
DC motor can be used in all Robot projects. The motor shield can drive 4 motors at most. The motors can rotate
forward or backward. Using high quality built-in PWM can change the speed by a delta of 0.5%. That means a very
smooth speed.
Note: H bridge chip cannot afford more than 0.6A or 1.2A peak value. It is suitable for
low power motors. Read the motor part of the data manual to make sure whether it is suitable or not.
Motor connecting:
Connect the two lines to terminals M1, M2, M3, or M4. Then follow the steps:
2. Use AF_DCMotor(motor#, frequency) to create AF_DCMot object,and the constructor has two parameters. The
first one is the motor connecting terminal 1,2,3,4. Frequency is the speed control signal value. For motor 1 and 2, you
can choose MOTOR12_64KHZ, MOTOR12_8KHZ, MOTOR12_2KHZ, or MOTOR12_1KHZ. The high frequency like 64 KHz
won’t make noise. However, the low frequency like 1KHz can save more power. Motor 3 and 4 can only run in the
frequency below 1KHz. It will neglect any other
frequency setting.
3. You can set the motor speed through the function setSpeed(speed). The speed range 5 / 8is from 0(stop) to
255(full)。You can set whatever you want.
4. Turn on the motor and by calling the run(direction)direction is FORWARD, BACKWARD or RELEASE。Of course,
actually Arduino doesn’t know whether the motor is driving forwardly or backwardly. If you want to change the way
you think, just exchange the lead.
#include <AFMotor.h>
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“Motor test!”);
motor.setSpeed(200); // set the speed to 200/255
}
void loop() {
Serial.print(“tick”);
motor.run(FORWARD); // turn it on going forward
delay(1000);
Serial.print(“tock”);
motor.run(BACKWARD); // the other way
delay(1000);
Serial.print(“tack”);
motor.run(RELEASE); // stopped
delay(1000);
}
- Stepper Motor
Stepper motor controls semi-precision very well. It is perfect for many Robots and CNC projects. This motor shield
supports 2 stepper motors at most. The library can support two-phase well.
Before connect unipolar stepper motor, you need to know which pins are connected to winding (coil), which to middle
wilding (coil). If it is 5-wire stepper, it must have 1 middle-plug of two group coils. There are many courses of how to
make reserve engineering to coil pin. The mid-plug should be connected to the output GND on the motor driving
board. Coil 1 should be connected motor terminal (M1 or M3). Coil 2 should be connected to other motor terminals
(M2 or M4)
The bipolar stepper motor is the same as unipolar except the 5th lead to the ground. The codes are the same also.
Driving stepper motor is complex than DC motor. However, here it is still very simple.
1. Make sure the header file include<AFMotor..h> .
2. Use AF_ Stepper (steps, stepper#) to set up AF_ Stepper object and the constructor has two parameters even. The
first is the steps the motor needs of each turning, One 7.5 degree / step motor has 360/7.5=48 steps. Stepper# is the
terminal connected to. If you use M1 and M2,it is terminal 1. if you use M3 and M4, it is terminal 2. 7 / 8.
3. Set laps you want the stepper move every minute through function setSpeed(rpm).
4. When you want to run the stepper, you just need to use function step(#steps, direction, steptype). #steps refers to
the steps you want the motor move. Direction is FORWARD or BACKWARD,and steptype is
SINGLE,DOUBLE,INTERLEAVE or MICROSTEP。“single” is signal coil driving, “double” is double coils driving(to the
demand of big torque), and “interleave” means the alternately between signal and double to get doubled-resolution
(when the speed half down). “Microstepping” is the way which uses PWM to set up smooth move between each step.
There are a lot articles about the advantages and disadvantages among different stepping. You can use the stepping
way as you like. During the moving, you can change to the min-power, biggest torque or highest precision.
5. Default will keep the position as it stops. If you want to release all of the coils, you need to call the function
realease(). Stepping order will return as soon as it finishes the action. It is cool if you can write the repository which
#include <AFMotor.h>
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“Stepper test!”);
motor.setSpeed(10); // 10 rpm