The DC motor comes with my starter kit is integrated with the LC9110 motor control board. In this exercise, I am going to make the motor moves clockwise then anti-clockwise at the speed read from the serial input.
The controller has four pins:
VCC - connected to 5v
GND - connected to ground
IA - connected to pin 9 to control speed in clockwise direction
IB - connected to pin 8 to control speed in anti-clockwise direction
/*
L9110 motor driver controlling a small DC motor
*/
const int IA = 9; // pin 9 connected to pin IA
const int IB = 8; // pin 8 connected to pin IB
byte speed = 255; // change this (0-255) to control the speed of the motor
void setup() {
pinMode(IA, OUTPUT); // set pins to output
pinMode(IB, OUTPUT);
Serial.begin(9600);
while (!Serial);
Serial.println("Speed 0 to 255");
}
void loop() {
if (Serial.available()) {
speed = Serial.parseInt();
Serial.print("Set speed to ");
Serial.println(speed);
}
forward();
delay(1000);
backward();
delay(1000);
}
void backward()
{
analogWrite(IA, 0);
analogWrite(IB, speed);
}
void forward()
{
analogWrite(IA, speed);
analogWrite(IB, 0);
}
Arduino Projects
2014年8月21日 星期四
Step Motor
My Arduino starter kit comes with a 28BYJ-48 unipolar step motor and a ULN2003 driver board.
According to the data specification, the motor has a Speed Variation Ratio of 1/64 and Stride Angle of 5.625°, that means
Steps in One revolution = 360°/Stride Angle = 360°/5.625° = 64
This value is used in the coding part and is different for different motor.
The voltage of the motor is 5VDC, so I do not need an external power and connect the VCC of the motor board to the VCC of the Arduino card with a wire for this experiment
For the coding part, I am using the Motor Knob example (File->Example->Stepper->Motor Knob). Remember to modify the STEPS to the Steps in One revolution of the motor. In this case, the value is 64
// change this to the number of steps on your motor
#define STEPS 64
After uploading the program, the step motor will rotate slowly and the the four led on the driver broad will blink in sequence.
According to the data specification, the motor has a Speed Variation Ratio of 1/64 and Stride Angle of 5.625°, that means
Steps in One revolution = 360°/Stride Angle = 360°/5.625° = 64
This value is used in the coding part and is different for different motor.
The voltage of the motor is 5VDC, so I do not need an external power and connect the VCC of the motor board to the VCC of the Arduino card with a wire for this experiment
Rated voltage : | 5VDC |
Number of Phase | 4 |
Speed Variation Ratio | 1/64 |
Stride Angle | 5.625°/64 |
Frequency | 100Hz |
DC resistance | 50Ω±7%(25°C) |
Idle In-traction Frequency | > 6000Hz |
Idle Out-traction Frequency | > 1000Hz |
In-traction Torque | >34.3mN.m(120Hz) |
Self-positioning Torque | >34.3mN.m |
Friction torque | 600-1200 gf.cm |
Pull in torque | 300 gf.cm |
Insulated resistance | >10MΩ(500V) |
Insulated electricity power | 600VAC/1mA/1s |
Insulation grade | A |
Rise in Temperature | <40K(120Hz) |
Noise | <35dB(120Hz,No load,10cm) |
Model | 28BYJ-48 – 5V |
For the coding part, I am using the Motor Knob example (File->Example->Stepper->Motor Knob). Remember to modify the STEPS to the Steps in One revolution of the motor. In this case, the value is 64
// change this to the number of steps on your motor
#define STEPS 64
After uploading the program, the step motor will rotate slowly and the the four led on the driver broad will blink in sequence.
2014年8月19日 星期二
Arduino Unbox
Recently, I've bought an Arduino starter kit from taobao.com for RMB148.
It comes with a nice plastic box to hold the tiny parts. The kit consists of an Arduino Uno card, several displays parts, bundles of wire and resistors, different sensors, two bread boards, several motors, which are more than enough for one to perform small scale electronic experiments.
After plugging the Arduino Uno card to my MacBook Air via a USB cable, the card is detected automatically. My card CP2102 USB to UART Bridge Controller is show up in the System Information, although its name is quite different from what is described in the Arduino Tutorial.
After installing the Arduino IDE from arduino.cc , I tried to run the Blink example (File->Examples->01.Basics->Blink)
According to the Arduino Tutorial, Mac can detect the card on the Serial Port automatically. However, the for some reasons, the Serial Port does not show up. I have to install the driver from Silicon Lab to get it working.
http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx
Now the device shows up in the Arduino IDE (Tools->Serial Port->/dev/tty.SLAB_USBtoUART)
After selecting the Serial Port the right Board (Tools->Board->Arduino Uno) I tried to upload the program to the Arduino. However the below error comes up.
avrdude: stk500_recv(): programmer is not responding
After doing some research, I have to workaround this error by connect TX to RX, RX to TX.
Finally, the upload is done and the arduino board is blinking. =)
It comes with a nice plastic box to hold the tiny parts. The kit consists of an Arduino Uno card, several displays parts, bundles of wire and resistors, different sensors, two bread boards, several motors, which are more than enough for one to perform small scale electronic experiments.
After plugging the Arduino Uno card to my MacBook Air via a USB cable, the card is detected automatically. My card CP2102 USB to UART Bridge Controller is show up in the System Information, although its name is quite different from what is described in the Arduino Tutorial.
According to the Arduino Tutorial, Mac can detect the card on the Serial Port automatically. However, the for some reasons, the Serial Port does not show up. I have to install the driver from Silicon Lab to get it working.
http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx
After selecting the Serial Port the right Board (Tools->Board->Arduino Uno) I tried to upload the program to the Arduino. However the below error comes up.
avrdude: stk500_recv(): programmer is not responding
After doing some research, I have to workaround this error by connect TX to RX, RX to TX.
Finally, the upload is done and the arduino board is blinking. =)
訂閱:
文章 (Atom)