Introduction:
Stepper motors are DC motors that move in discrete steps. They have multiple coils that are organized in groups called “phases”. By energizing each phase in sequence, the motor will rotate, one step at a time.
With a computer controlled stepping you can achieve very precise positioning and/or speed control. For this reason, stepper motors are the motor of choice for many precision motion control applications.
Features:
1.The rotation angle of the motor is proportional to the input pulse.
3.Excellent response to starting/stopping/reversing.
4.Very reliable since there are no contact brushes in the motor. Therefore the life of the motor is simply dependent on the life of the bearing.
5.The motors response to digital input pulses provides open-loop control, making the motor simpler and less costly to control.
6.It is possible to achieve very low-speed synchronous rotation with a load that is directly coupled to the shaft.
Components Required:
- Arduino Uno
- Motor Driver
- Stepper Motor
- Jumper Wires
Usage:
Computer controlled stepper motors are a type of motion-control positioning system. They are typically digitally controlled as part of an open loop system for use in holding or positioning applications.In the field of lasers and optics they are frequently used in precision positioning equipment such as linear actuators, linear stages, rotation stages, and mirror mounts. Other uses are in packaging machinery, and positioning of valve pilot stages for fluid control systems.
Commercially, stepper motors are used in floppy disk drives, flatbed scanners, computer printers, plotters, slot machines, image scanners, compact disc drives, intelligent lighting, camera lenses, CNC machines and, more recently, in 3D printers.
Project for Reference:
Connections:
Code:
const int out1 = 4;
const int out2 = 3;
const int out3 = 5;
const int out4 = 2;
int i=0;
int negative=0;
int positive=0;
char temp_print=0;
char temp_print1=0;
int led=13;
void setup()
{
pinMode(out1, OUTPUT);
pinMode(out2, OUTPUT);
pinMode(out3, OUTPUT);
pinMode(out4, OUTPUT);
pinMode(led,OUTPUT);
digitalWrite(out1,LOW);
digitalWrite(out2,LOW);
digitalWrite(out3,LOW);
digitalWrite(out4,LOW);
digitalWrite(led,LOW);
Serial.begin(9600);
}
void loop()
{
if(temp_print1==1)
{
Serial.println(".");
delay(1000);
Serial.println(".");
delay(1000);
Serial.println(".");
delay(1000);
Serial.println(".");
delay(1000);
Serial.println(".");
delay(1000);
Serial.println(".");
delay(1000);
Serial.println(".");
Serial.println("calibration completed......");
Serial.println("Stepper Motor Ready");
temp_print1=temp_print1+1;
}
if(temp_print==0)
{
Serial.println("Enter the dummy DIRECTION & STEPS for calibration");
temp_print=temp_print+1;
temp_print1=temp_print1+1;
}
abc:
Serial.print("Direction = ");
while(Serial.available()==false);
char temp = Serial.read();
if(temp=='+')
{
Serial.println(temp);
Serial.print("Steps = ");
while(Serial.available()==false)
{
digitalWrite(led,HIGH);
delay(50);
digitalWrite(led,LOW);
delay(50);
}
int val = Serial.parseInt();
Serial.println(val);
if(val>=0 && val<=400)
{
for(int a=val;a>0;a--)
{
if(negative==1)
{
if(i==7)
i=0;
else
a=a+1;
i=i+1;
negative=0;
}
positive=1;
if(i==0) { digitalWrite(out1,HIGH);digitalWrite(out2,LOW);digitalWrite(out3,LOW);digitalWrite(out4,LOW);delay(60); }
else if(i==1) { digitalWrite(out1,HIGH);digitalWrite(out2,HIGH);digitalWrite(out3,LOW);digitalWrite(out4,LOW);delay(60); }
else if(i==2) { digitalWrite(out1,LOW);digitalWrite(out2,HIGH);digitalWrite(out3,LOW);digitalWrite(out4,LOW);delay(60); }
else if(i==3) { digitalWrite(out1,LOW);digitalWrite(out2,HIGH);digitalWrite(out3,HIGH);digitalWrite(out4,LOW);delay(60); }
else if(i==4) { digitalWrite(out1,LOW);digitalWrite(out2,LOW);digitalWrite(out3,HIGH);digitalWrite(out4,LOW);delay(60); }
else if(i==5) { digitalWrite(out1,LOW);digitalWrite(out2,LOW);digitalWrite(out3,HIGH);digitalWrite(out4,HIGH);delay(60); }
else if(i==6) { digitalWrite(out1,LOW);digitalWrite(out2,LOW);digitalWrite(out3,LOW);digitalWrite(out4,HIGH);delay(60); }
else if(i==7) { digitalWrite(out1,HIGH);digitalWrite(out2,LOW);digitalWrite(out3,LOW);digitalWrite(out4,HIGH);delay(60); }
if(i==7)
{i=0;continue;}
i++;
}
}
else
{
goto abc;
}
digitalWrite(out1,LOW);digitalWrite(out2,LOW);digitalWrite(out3,LOW);digitalWrite(out4,LOW);delay(50);
val=0;
}
else if(temp=='-')
{
Serial.println(temp);
Serial.print("Steps = ");
while(Serial.available()==false)
{
digitalWrite(led,HIGH);
delay(50);
digitalWrite(led,LOW);
delay(50);
}
int val = Serial.parseInt();
Serial.println(val);
if(val>=0 && val<=400)
{
for(int a=val;a>0;a--)
{
if(positive==1)
{
i=i-1;
positive=0;
a=a+1;
}
negative=1;
if(i==0) { digitalWrite(out1,HIGH);digitalWrite(out2,LOW);digitalWrite(out3,LOW);digitalWrite(out4,LOW);delay(60); }
else if(i==1) { digitalWrite(out1,HIGH);digitalWrite(out2,HIGH);digitalWrite(out3,LOW);digitalWrite(out4,LOW);delay(60); }
else if(i==2) { digitalWrite(out1,LOW);digitalWrite(out2,HIGH);digitalWrite(out3,LOW);digitalWrite(out4,LOW);delay(60); }
else if(i==3) { digitalWrite(out1,LOW);digitalWrite(out2,HIGH);digitalWrite(out3,HIGH);digitalWrite(out4,LOW);delay(60); }
else if(i==4) { digitalWrite(out1,LOW);digitalWrite(out2,LOW);digitalWrite(out3,HIGH);digitalWrite(out4,LOW);delay(60); }
else if(i==5) { digitalWrite(out1,LOW);digitalWrite(out2,LOW);digitalWrite(out3,HIGH);digitalWrite(out4,HIGH);delay(60); }
else if(i==6) { digitalWrite(out1,LOW);digitalWrite(out2,LOW);digitalWrite(out3,LOW);digitalWrite(out4,HIGH);delay(60); }
else if(i==7) { digitalWrite(out1,HIGH);digitalWrite(out2,LOW);digitalWrite(out3,LOW);digitalWrite(out4,HIGH);delay(60); }
if(i==0)
{i=7;continue;}
i--;
}
}
else
{
goto abc;
}
digitalWrite(out1,LOW);digitalWrite(out2,LOW);digitalWrite(out3,LOW);digitalWrite(out4,LOW);delay(50);
val=0;
}
else
goto abc;
}
No comments:
Post a Comment