ok from now on I'll write in english, I have to learn it.
In this tutorial I will show you how to control a stepper motor with FOUR control wires and a L293D IC. You can use everything you want in order to generate control signals. In this tutorial I used an Arduino board, but a PIC is also ok.
Why "FOUR" control wires? because everyone who writes a tutorial or something else about bipolar stepper motors wants to control them with only TWO wires and a lot of components (NPN transistors, resistors ecc ecc). But controlling a L293D with 4 wires is simpler!
ok, let's see the circuit:
How does the L293D work?
That's simple: you send a signal on the "inputX" and then the IC "opens" the port "outputX" for the current passing.
You can also enable or disable a particular input-output "phase" (pin 1 and 9), but in this tutorial they are always enabled.
This is the result:
and this is a (very) simple sketch of Arduino programming:
//declaration of PINS that connected the wire to motor
int nero = 13;
int marrone = 12;
int arancio = 11;
int giallo = 10;
//this is the time to wait in every single step
int delayTime = 100;
//set the pin for OUTPUT
void setup() {
pinMode(nero, OUTPUT);
pinMode(marrone, OUTPUT);
pinMode(giallo, OUTPUT);
pinMode(arancio, OUTPUT);
}
void loop() {
forward(13);
delay(500);
backward(13);
}
void forward(int steps){
for(int i=0;i<steps;i++){
// in every phase 2 wires is up and 2 is down
digitalWrite(nero, LOW);
digitalWrite(marrone, HIGH);
digitalWrite(arancio, HIGH);
digitalWrite(giallo, LOW);
delay(delayTime);
digitalWrite(nero, LOW);
digitalWrite(marrone, HIGH);
digitalWrite(arancio, LOW);
digitalWrite(giallo, HIGH);
delay(delayTime);
digitalWrite(nero, HIGH);
digitalWrite(marrone, LOW);
digitalWrite(arancio, LOW);
digitalWrite(giallo, HIGH);
delay(delayTime);
digitalWrite(nero, HIGH);
digitalWrite(marrone, LOW);
digitalWrite(arancio, HIGH);
digitalWrite(giallo, LOW);
delay(delayTime);}
}
void backward (int steps){
for(int i=0;i<steps;i++){
digitalWrite(nero, HIGH);
digitalWrite(marrone, LOW);
digitalWrite(arancio, HIGH);
digitalWrite(giallo, LOW);
delay(delayTime);
digitalWrite(nero, HIGH);
digitalWrite(marrone, LOW);
digitalWrite(arancio, LOW);
digitalWrite(giallo, HIGH);
delay(delayTime);
digitalWrite(nero, LOW);
digitalWrite(marrone, HIGH);
digitalWrite(arancio, LOW);
digitalWrite(giallo, HIGH);
delay(delayTime);
digitalWrite(nero, LOW);
digitalWrite(marrone, HIGH);
digitalWrite(arancio, HIGH);
digitalWrite(giallo, LOW);
delay(delayTime);
}
}
PS
this page: http://www.arduino.cc/en/Tutorial/StepperBipolar is for UNIPOLAR stepper motor!
hi
RispondiEliminathank you for the information you've provided, however I would like to ask if we need to define "steps"? Or is it not necessary?
Thanks a lot in advance
where? in the "for" statement is the number of "steps" the motor will do
RispondiElimina