Offline
Newbie
Karma: 0
Posts: 8
|
 |
« on: March 28, 2011, 07:36:52 am » |
Hi guys
Im currently trying write my own stepper motor library. Whilst I can move individual steps, I am unable to get the smooth movement at high speeds (100-120 rpm) that I get when I use the Arduino Stepper Library. I get a juddery motion at a slow speed, changing the speed tends to work up to slow rpms. Its all very obviously step, step, step, step, which is not the case with the Arduino Stepper Library. Basically Im trying to get computer control from a program like OF or SuperCollider, which you need to upload firmata or SMS onto the board, without buying drivers but just using a transistor array. I have tried it in Processing, OF and Supercollider and get the same results.
Any ideas what could be causing this? I know its not the equipment/wiring as it works perfectly with the Arduino librarys. I thought it could be to do with data transfer/frame rate of the environment with Processing but I get the same issues with OF and SuperCollider (code implemented in the same way) which should be pretty quick?
Kit: Astrosyn y129-5 Stepper Motor, Darlington ULN2003 transistor array
Code (Processing):
import processing.serial.*;
import cc.arduino.*;
Arduino arduino; int in1; int in2; int in3; int in4; int stepNo=0; float steps=200; float speed=120; float nextTime; float gap;
void setup() { arduino = new Arduino(this, Arduino.list()[0], 57600); for (int i = 0; i <= 13; i++) { arduino.pinMode(i, Arduino.OUTPUT); } nextTime=millis(); in1=8; in2=9; in3=10; in4=11; gap=(1000*60)/(speed*steps); frameRate=300; }
void draw() { if(millis()>=nextTime) { stepForward(stepNo); stepNo++; nextTime=millis()+gap; } System.out.println(frameRate); }
void stepForward (int step) { if(step%4==0) { arduino.digitalWrite(in1,Arduino.HIGH); arduino.digitalWrite(in2,Arduino.LOW); arduino.digitalWrite(in3,Arduino.HIGH); arduino.digitalWrite(in4,Arduino.LOW); } else if(step%4==1) { arduino.digitalWrite(in1,Arduino.LOW); arduino.digitalWrite(in2,Arduino.HIGH); arduino.digitalWrite(in3,Arduino.HIGH); arduino.digitalWrite(in4,Arduino.LOW); } else if(step%4==2) { arduino.digitalWrite(in1,Arduino.LOW); arduino.digitalWrite(in2,Arduino.HIGH); arduino.digitalWrite(in3,Arduino.LOW); arduino.digitalWrite(in4,Arduino.HIGH); } else if(step%4==3) { arduino.digitalWrite(in1,Arduino.HIGH); arduino.digitalWrite(in2,Arduino.LOW); arduino.digitalWrite(in3,Arduino.LOW); arduino.digitalWrite(in4,Arduino.HIGH); } }
|