[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”DC Motor Power Supply Requirements ” tab_id=”1393228066-1-78″][vc_column_text]Motor needs a lot of power, especially for those cheap ones as their efficiency is very low. The most important thing is to know the required voltage of the motor. If you are luck, your motor will come with certain specifications. Some small amateur motors’ voltage is only 1.5V. However, they are commonly used as if they care specified to be 6V or 12v. This motor driver shield is designed to drive 4.5V to 36V. (Anyway, in theory, it
can be lowered to somewhere around 2.5V).
[/vc_column_text][/vc_tab][vc_tab title=”Current requirement” tab_id=”1393228066-2-11″][vc_column_text]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.[/vc_column_text][/vc_tab][vc_tab title=”set Arduino + driving shield” tab_id=”1393228441797-2-7″][vc_column_text]Servo is powered by the 5V used by Arduino. It doesn’t matter to small amateur motors. If you need bigger power, cut the line to “+” and connect to your own servo power.
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.
The following is the working principle:
If you want to use only one DC power supply to power up Arduino and motor, you can plug in the power to DC barrel or EXT-PWR on the motor shield. Then, you need to install the power jumper on the motor shield.
If you use Diecimila Arduino,set Arduino power jumper as EXT.
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.[/vc_column_text][/vc_tab][vc_tab title=”Servo Motor (Servos) ” tab_id=”1393229019490-3-8″][vc_column_text]
Amateur Servo
Amateur servo is the easiest to be controlled. It has 3-wire input: 5V, GND and control signal input. They have large power consumption. 9V battery can not last for few minutes.
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.[/vc_column_text][/vc_tab][vc_tab title=”DC Motor” tab_id=”1393229168450-4-3″][vc_column_text]
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:
1. Make sure the header file include<AFMotor.h>
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>
AF_DCMotor motor(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
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);
}[/vc_column_text][/vc_tab][vc_tab title=”Stepper Motor” tab_id=”1393229568540-5-6″][vc_column_text]
Bipolar four-wire 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 can do background stepping! 🙂 .
#include <AFMotor.h>
AF_Stepper motor(48, 2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“Stepper test!”);
motor.setSpeed(10); // 10 rpm
motor.step(100, FORWARD, SINGLE);
motor.release();
delay(1000);
}
void loop() {
motor.step(100, FORWARD, SINGLE);
motor.step(100, BACKWARD, SINGLE);
motor.step(100, FORWARD, DOUBLE);
motor.step(100, BACKWARD, DOUBLE);
motor.step(100, FORWARD, INTERLEAVE);
motor.step(100, BACKWARD, INTERLEAVE);
motor.step(100, FORWARD, MICROSTEP);
motor.step(100, BACKWARD, MICROSTEP);
} 8 / 8
If you want the stepper motor working immediately, you have to write down the following
codes.
If you want two stepper motors to step at once you’ll need to write something like this:
void doublestep (int steps, int direction, int style) {
while (steps–) {
motor1.step(1, direction, style);
motor2.step(1, direction, style);
}
}[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.