Go Down

### Topic: I am trying to get higher speed for a stepper motor (Read 364 times)previous topic - next topic

#### ksshhs

##### Jul 04, 2012, 11:02 am
I am trying to get higher speed for a stepper motor with this code below.

is there any other way I can get higher speed.

also I want to make speed decreasing gradually.

Code: [Select]
`////////////////////////////////////////////////////////////////////©2011 bildr//Released under the MIT License - Please reuse change and share//Using the easy stepper with your arduino//use rotate and/or rotateDeg to controll stepper motor//speed is any number from .01 -> 1 with 1 being fastest - //Slower Speed == Stronger movement/////////////////////////////////////////////////////////////////#define DIR_PIN 2#define STEP_PIN 3void setup() {  pinMode(DIR_PIN, OUTPUT);  pinMode(STEP_PIN, OUTPUT);} void loop(){   rotate(16000, .900);  delay(0); }void rotate(int steps, float speed){  //rotate a specific number of microsteps (8 microsteps per step) - (negitive for reverse movement)  //speed is any number from .01 -> 1 with 1 being fastest - Slower is stronger  int dir = (steps > 0)? HIGH:LOW;  steps = abs(steps);  digitalWrite(DIR_PIN,dir);   float usDelay = (1/speed) * 70;  for(int i=0; i < steps; i++){    digitalWrite(STEP_PIN, HIGH);    delayMicroseconds(usDelay);     digitalWrite(STEP_PIN, LOW);    delayMicroseconds(usDelay);  }}`

#### PeterH

#1
##### Jul 04, 2012, 11:36 am
I only provide help via the forum - please do not contact me for private consultancy.

#### AWOL

#2
##### Jul 04, 2012, 11:41 am
Specifically here.

DON'T DO IT.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up

Please enter a valid email to subscribe