driving a stepper motor really slowly... what am I missing?

hello there

I’m trying to use a stepper as a laser turret for 3d laser scanning. so the goal would be to

turn the stepper as slow as possible.

I’m using an easy stepper driver board and an arduino pro mini 3.3v. fast turns work

ok and turn smoothly (I switch HIGH/LOW at a rate of 500 microseconds), but if I try

increase that rate the motor just stalls and doesn’t move at all.

what am I missing here? as I said, the motor should turn as slow as possible…

thank you in advance for your help, I’d be really glad for some help.

I don’t understand what you mean by “increase that rate”.

What happens when you command the driver board to step once every second?

sorry, I wasn’t very clear about that. by increasing the rate I mean increase the delay, or

as you have suggested, I did try to have a delay of once second which didn’t work at all (stalling

or moving back and forth). but: I managed to make it work now, it seems this problem is more

software related. If I only execute the following code the stepper works:

int stepPin = 2;
int dirPin = 3;

void setup(){

  Serial.begin(9600);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
 
  digitalWrite(dirPin, LOW);     // Set the direction.
  digitalWrite(stepPin, LOW);     // Set the direction.
}



void loop()
{

  digitalWrite(stepPin, LOW);
  delay(200);
  digitalWrite(stepPin, HIGH);
  delay(200);

}

the problem is I have some switches that I’d like to use… as soon as the code gets a bit more complex,

the stepper doesn’t work anymore, and I have not been able to understand why… maybe you can find

an error within the code…

int stepPin = 2;
int dirPin = 3;
int turnSwitch = 4;
int dirSwitch = 5;
int laserSwitch = 6;
int ledPin = 7;

boolean isTurning = false;
boolean clockWise = false;
boolean LaserOn = false;

void setup()
{

  Serial.begin(9600);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(turnSwitch, INPUT);
  pinMode(dirSwitch, INPUT);
  pinMode(laserSwitch, INPUT);
  pinMode(ledPin, OUTPUT);


  digitalWrite(dirPin, LOW);     // Set the direction.
  digitalWrite(stepPin, LOW);     // Set the direction.
}


void loop()
{



  //////////////////////////////////////////// STEPPER ON/OFF
  if(digitalRead(turnSwitch) == HIGH){

    if(isTurning == false){
      isTurning = true;
      digitalWrite(ledPin, HIGH);
      delay(500);
    }
    else{
      isTurning = false;
      digitalWrite(ledPin, LOW);
      delay(500);
    }
  } 
  //////////////////////////////////////////// STEPPER ON/OFF



  //////////////////////////////////////////// DIRECTION CHANGE
  if(digitalRead(dirSwitch) == HIGH){

    if(clockWise == false){
      clockWise = true;
      delay(500);
    }
    else{
      clockWise = false;
      delay(500);
    }
    
    dirChange();
  }
  //////////////////////////////////////////// DIRECTION CHANGE

  
  stepper();
}

//////////////////////////////////////////// STEPPER METHOD
void stepper(){

  if(isTurning == true){

      digitalWrite(stepPin, LOW);
      delay(500);
      digitalWrite(stepPin, HIGH);
      delay(500);
    
  }
}
//////////////////////////////////////////// STEPPER METHOD



//////////////////////////////////////////// DIRECTION METHOD
void dirChange(){

  if(clockWise == false){
    digitalWrite(dirPin, LOW);     // Set the direction.
    delay(100);
  }
  else{
    digitalWrite(dirPin, HIGH);
    delay(100);  
  }

}
//////////////////////////////////////////// DIRECTION METHOD

I haven’t had so much time to spend on arduino, so maybe I’m doing something

wrong terribly here… I’m glad for any help!

On a side note, while executing the first code example… it works, but

3 steps of 4 the motor vibrates quite a bit and the laser line is thus

quite blurry. is that because of the mircostepping?

It will be difficult for anyone to help if you don’t take the time to describe your setup fully, which includes posting a wiring diagram.

But first, solve the problem of stepping the motor at reasonable rates (slow and fast), in either direction, and make sure that every step is taken and is smooth. If that doesn’t happen something is wrong with your easydriver/motor wiring.

Then add the switches, first making sure that they are doing what you think they should. Ignore the motor, have a switch light an LED as a test.

let me see… the wiring is set up exactly as in this example:

http://bildr.org/2011/06/easydriver/

I don’t think wiring is my problem, really. the buttons are

connected with 3v on one side and digital pins on the other

side with digital pins connected to ground via 10k resistor.

As I said the stepper is working now. I was only asking if some

vibration in substeps is normal, or how this could get resolved.

Also I was hoping there was an obvious error in my 2nd code that was

causing the stepper to not step correctly… buttons/switches have been

working from the start (and were tested with LEDs obviously).

after carefully analyzing everything I have finally found

the culprit… I’ve been using the easy stepper board as

power source for my arduino mini 3.3v.

I thought I remembered that by default the easy stepper’s

output is 3.3v and optionally able to output 5v.

well… it’s the other way around. after resolving that everything

works as expected.

thanks for listening : )