Go Down

Topic: pd example patch 4 controlling steppers via pduino (Read 801 times) previous topic - next topic

armadillo

Dec 27, 2006, 08:33 am Last Edit: Dec 27, 2006, 08:34 am by armadillo Reason: 1
hiya, im traying to control 1 step motor via pduino (latest from CVS) but i only manage to make the motor tick. I have tested the wiring with the basic arduino step motor unipolar example from the playground and it all works quite well. But, since im not very familiar with coding i've been trying the firmware code named pduino aka firmata.

Im not sure whats the speed and the secuence of values i have to send to the 4 pins where my unipolar is connected.

can someone here share puredata patches to move a stepper? via pduino or not, is the same for me as long as it works.

tx!,
/a

armadillo

okay, it didnt work via pduino, so i began copy pasting form here and there and end up with this code for the arduino:

/* Paso a Paso aka Step motor control desde puredata
* --------------------
*
*
* copy pasted on the 28 December 2006
* kdag-alej00d <http://co.lab.cohete.net>
* http://altred.net
*
*/

int ledPin = 13;
int statusLed = LOW;
int delayTime = 500;
int val = 0;
int serbyte = 0;   // valor que llega via serial
int analogValue = 0;

void setup()
{
 pinMode(ledPin, OUTPUT);
 Serial.begin(9600);        // conecta el puerto serial
 int i;
 for(i=8; i<11; i++) {    
   pinMode(i, OUTPUT);      
 }

 pinMode(13, OUTPUT);        //led pin 13.
 digitalWrite(13, HIGH);
}


void stepforward()            //movimiento hacia adelante
{                            
 digitalWrite(8, HIGH);
 digitalWrite(9, LOW);
 digitalWrite(10, LOW);
 digitalWrite(11, LOW);
 delay(30);
 digitalWrite(8, LOW);
 digitalWrite(9, HIGH);
 digitalWrite(10, LOW);
 digitalWrite(11, LOW);
 delay(30);
 digitalWrite(8, LOW);
 digitalWrite(9, LOW);
 digitalWrite(10, HIGH);
 digitalWrite(11, LOW);
 delay(30);
 digitalWrite(8, LOW);
 digitalWrite(9, LOW);
 digitalWrite(10, LOW);
 digitalWrite(11, HIGH);
 delay(30);
}

void stepbackward()            //movimiento hacia atras
{                    
 digitalWrite(8, LOW);
 digitalWrite(9, LOW);
 digitalWrite(10, LOW);
 digitalWrite(11, HIGH);
 delay(30);
 digitalWrite(8, LOW);
 digitalWrite(9, LOW);
 digitalWrite(10, HIGH);
 digitalWrite(11, LOW);
 delay(30);
 digitalWrite(8, LOW);
 digitalWrite(9, HIGH);
 digitalWrite(10, LOW);
 digitalWrite(11, LOW);
 delay(30);
 digitalWrite(8, HIGH);
 digitalWrite(9, LOW);
 digitalWrite(10, LOW);
 digitalWrite(11, LOW);
 delay(30);
}

void loop()
{
 serbyte = Serial.read();
 val = serbyte; //val = analogRead(0);

//    val = analogRead(0); comentado porque los datos llegan via serial. no via pin analogico
 Serial.print(val);
 if (val > 5) {
   // acelera
   delayTime = 2048 - 1024 * val / 512 + 1;
   stepforward();
 } else if (val < 9) {
   // disminuya la velocidad
   delayTime = 1024 * val / 512 + 1;
   stepbackward();
 } else {
   delayTime = 1024;
 }
}


the pd patch is not yet ready, it does change the rotation direction but it doesnt alter the speed rotation yet..

the stepper is connected according to the schematics in the arduino playground for a ULN2003A driver.

((el patch de pd aun no esta afinado, ya que el motor si cambia el sentido de rotacion pero no acelera o disminuya la velocidad de rotacion...no se porque.))

/a

Go Up