long variables / numbers in arrays to control a stepper motor steps?

hello, so i’m trying to make a stepper motor move more than 100000 steps.

still new to this… so i was trying “long” variables but the stepper moves about a 1/10 of the steps and stops. i also set up an array

long moveArray[]={144000,100,1600,1600,1600,1600,1600,1600,1600,1600};

and tried calling it with

rotate(moveArray[0], .5);

and

rotate((long) moveArray[0], .5);

but again the stepper didn’t move the right amount of steps on any large number.

i’m basing all of my code on this:

//////////////////////////////////////////////////////////////////
//©2011 bildr http://bildr.org/2011/06/easydriver/
//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 3

void setup() {
  pinMode(DIR_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
} 

void loop(){ 

  //rotate a specific number of degrees 
  rotateDeg(360, 1);
  delay(1000);

  rotateDeg(-360, .1);  //reverse
  delay(1000); 

  //rotate a specific number of microsteps (8 microsteps per step)
  //a 200 step stepper would take 1600 micro steps for one full revolution
  rotate(144000, .5);
  delay(1000); 

  rotate(-144000, .25); //reverse
  delay(1000);
}

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);
  }
} 

void rotateDeg(float deg, float speed){
  //rotate a specific number of degrees (negitive for reverse movement)
  //speed is any number from .01 -> 1 with 1 being fastest - Slower is stronger
  int dir = (deg > 0)? HIGH:LOW;
  digitalWrite(DIR_PIN,dir); 

  int steps = abs(deg)*(1/0.225);
  float usDelay = (1/speed) * 70;

  for(int i=0; i < steps; i++){
    digitalWrite(STEP_PIN, HIGH);
    delayMicroseconds(usDelay); 

    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(usDelay);
  }
}

any ideas to how i can call a larger number and make it move that amount of steps?

many thanks!

You have to change the rotate() function so that it accepts a long and uses a long for the stepping loop counter. You can't cram a long value into an int.

hey john,

right on. i tried that before, thought it didn't work and after reading your comment realized i missed an int. thanks so much. works like a charm now.