Stepper Motor Interfacing with MSP-EXP430G2 TI Launchpad
Introduction
Stepper Motor
Stepper motor is a brushless DC motor that divides the full rotation angle of 360° into a number of equal steps.
The motor is rotated by applying certain sequence of control signals. The speed of rotation can be changed by changing the rate at which the control signals are applied.
For more information about Stepper Motor and how to use it, refer the topic Stepper Motor in the sensors and modules section.
Interfacing Diagram
Interfacing Stepper Motor With MSP-EXP430G2 TI Launchpad
Example
Rotating stepper motor in clockwise and counter clockwise directions alternately.
Here, we are using six wire unipolar stepper motor. Only four wires are required to control this stepper motor. The two centre tap wires of the stepper motor are connected to 5V supply.
ULN2003 driver is used to drive the stepper motor.
Note : To find winding coils and their centre tap leads, measure resistance in between the leads. From centre leads we will get half the resistance value as compared to the resistance between winding ends.
Tread Carefully : MSP-EXP430G2 TI Launchpad board has a RAM of 512 bytes which is easily filled, especially while using different libraries. There are times when you need the Serial buffer to be large enough to contain the data you want and you will have to modify the buffer size for the Serial library. While doing such things, we must ensure that the code does not utilize more than 70% RAM. This could lead to the code working in an erratic manner, working well at times and failing miserably at others.
There are times when the RAM usage may exceed 70% and the codes will work absolutely fine, and times when the code will not work even when the RAM usage is 65%.
In such cases, a bit of trial and error with the buffer size and/or variables may be necessary.
Sketch For Stepper Motor
void setup() {
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(14, OUTPUT);
}
void loop() {
/* Rotation in one direction */
for(int i = 0; i<12; i++)
{
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
digitalWrite(14, HIGH);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, HIGH);
delay(100);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, HIGH);
delay(100);
}
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
delay(100);
/* Rotation in opposite direction */
for(int j = 0; j<12; j++)
{
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, HIGH);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
digitalWrite(14, HIGH);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
delay(100);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, HIGH);
delay(100);
}
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, HIGH);
delay(100);
}
No comments:
Post a Comment