lorzangas porafor
/
motorpaso
control simple de motor paso a paso unipolar
Diff: main.cpp
- Revision:
- 1:26c2fd1ea036
- Parent:
- 0:414bd7c6b901
- Child:
- 2:42e4a5fcc99f
diff -r 414bd7c6b901 -r 26c2fd1ea036 main.cpp --- a/main.cpp Mon Oct 22 04:47:24 2012 +0000 +++ b/main.cpp Mon Oct 22 04:59:01 2012 +0000 @@ -3,34 +3,34 @@ BusOut myleds(LED1, LED2, LED3, LED4); BusOut motor(p10, p11, p12, p13); -/* Step C0 C1 C2 C3 - 1 1 0 1 0 - 2 0 1 1 0 - 3 0 1 0 1 - 4 1 0 0 1 +/* Paso p10 p11 p12 p13 + 1 1 0 1 0 + 2 0 1 1 0 + 3 0 1 0 1 + 4 1 0 0 1 */ -int tiempo = 12000; +int tiempo = 12000;//tiempo en us (tiempo entre pasos) nos da la velocidad int main() { while(1) { - for (int s = 0; s < 120 ; s +=1) { - motor = (0xA); + for (int s = 0; s < 120 ; s +=1) {//el 120 indica 120*4 pasos, en mi motor de 48 pasos 10 vueltas + motor = (0xA); //1010 wait_us(tiempo); - motor = (0x6); + motor = (0x6);//0110 wait_us(tiempo); - motor = (0x5); + motor = (0x5);//0101 wait_us(tiempo); - motor = (0x9); + motor = (0x9);//1001 wait_us(tiempo); } wait(2); - for (int s = 0; s < 120 ; s +=1) { - motor = (0x9); + for (int s = 0; s < 120 ; s +=1) {//ahora en sentido contrario + motor = (0x9);//1010 wait_us(tiempo); - motor = (0x5); + motor = (0x5);//0101 wait_us(tiempo); - motor = (0x6); + motor = (0x6);//0110 wait_us(tiempo); - motor = (0xA); + motor = (0xA);//1010 wait_us(tiempo); } wait(2);