stepper motor control

hi there

i’m building a projector robot using arduino to control 2 stepper motors to move the projector in the x and y fields
accelstepper library

it’s controlled through maxmsp jitter using the serial interface
it works fine but after a minute for no reason the the stepper motors ‘relax’ and go slack

i’ve no idea why. it works perfectly initially
(it also turns on and off 2 35mm slide projectors)

any help appreciated as i’ve gone through it so many times it needs a fresh set of eyes

thanks

juz

here’s the arduino code

// pjr control 1.1
// march 2013
// justin@overcast.net.au

#include <AccelStepper.h>

AccelStepper stepper_Y(1, 3, 2); // pin 3 = step, pin 2 = direction
AccelStepper stepper_X(2, 5, 4); // pin 5 = step, pin 4 = direction
const int pin13 = 13;
const int pin12 = 12;
const int pin6 = 6;
const int pin7 = 7;
int moveUP;
int moveDOWN;
int moveLEFT;
int moveRIGHT;
int Slide1;
int Slide2;
int incomingByte; // a variable to read incoming serial data into
int X_POS;
int X_SPEED;
int Y_POS;
int Y_SPEED;


void setup() {  
      
  Serial.begin(9600);  // initialize serial communication
  
  pinMode(pin13, OUTPUT);    // initialize these  pins as an output
  pinMode(pin12, OUTPUT);
  pinMode(pin6, OUTPUT);
  pinMode(pin7, OUTPUT);
  
  moveUP = 0;
  moveDOWN = 0;
  moveLEFT = 0;
  moveRIGHT = 0;
  Slide1 = 0;
  Slide2 = 0;
  X_SPEED=1000;
  X_POS=0;
  Y_SPEED=500;
  Y_POS=0;
  
  digitalWrite (pin6, LOW);
  digitalWrite (pin7, LOW);
  
  stepper_X.setMaxSpeed(1000);
  stepper_X.setAcceleration(20);
  stepper_X.setCurrentPosition(0); 


  stepper_Y.setMaxSpeed(500);
  stepper_Y.setAcceleration(20);
  stepper_Y.setCurrentPosition(0); 
}

void loop(){ 
  
        // see if there's incoming serial data:
       if (Serial.available() > 0) {
          // read the oldest byte in the serial buffer:
          incomingByte = Serial.read();
          if (incomingByte == 'A') {
            moveUP = 0;
            } 
          if (incomingByte == 'B') {
            moveUP = 1;
            } 
          if (incomingByte == 'C') {
            moveDOWN = 0;
            } 
          if (incomingByte == 'D') {
            moveDOWN = 1;
            } 
          if (incomingByte == 'E') {
            moveLEFT = 0;
            } 
          if (incomingByte == 'F') {
            moveLEFT = 1;
            } 
          if (incomingByte == 'G') {
            moveRIGHT = 0;
            } 
          if (incomingByte == 'H') {
            moveRIGHT = 1;
            }
          if (incomingByte == 'I') {
            digitalWrite(pin13, LOW);
            }
          if (incomingByte == 'J') {
            digitalWrite(pin13, HIGH);
            }
          if (incomingByte == 'K') {
             Slide1 = 0;
            }
          if (incomingByte == 'L') {
             Slide1 = 1;
            }
          if (incomingByte == 'M') {
             Slide2 = 0;
            }
           if (incomingByte == 'N') {
             Slide2 = 1;
             }
       }
      
if (moveUP == 0) {
    Y_POS = Y_POS;
       } 
    
if (moveUP == 1) {
    Y_POS = Y_POS + 1;
    stepper_Y.move(Y_POS); 
    stepper_Y.setSpeed(Y_SPEED);
    stepper_Y.run();
        }   
       

if (moveDOWN == 0) {
     Y_POS = Y_POS;
     }    
  
if (moveDOWN == 1) {
      Y_POS = Y_POS - 1;
      stepper_Y.move(Y_POS); 
      stepper_Y.setSpeed(-Y_SPEED);
      stepper_Y.run();
      }
    
       
if (moveLEFT == 0) {
       X_POS = X_POS;
       }  
       
if (moveLEFT == 1) {
       X_POS = X_POS - 1;
       stepper_X.move(X_POS); 
       stepper_X.setSpeed(-X_SPEED); 
       stepper_X.run();  
       }

if (moveRIGHT == 0) {
       X_POS = X_POS;
       }  
       
if (moveRIGHT == 1) {
       X_POS = X_POS + 1; 
       stepper_X.move(X_POS); 
       stepper_X.setSpeed(X_SPEED); 
       stepper_X.run();       
       }
       
if (Slide1 == 1) {
       digitalWrite(pin6, LOW);
       }
       
if (Slide1 == 0) {
       digitalWrite(pin6, HIGH);
       }
if (Slide2 == 1) {
       digitalWrite(pin7, LOW);
       }
       
if (Slide2 == 0) {
       digitalWrite(pin7, HIGH);
       }
    
       
}

it works fine but after a minute for no reason the the stepper motors ‘relax’ and go slack

Sounds like a hardware problem.
Measure the voltage when this happens. Is anything overheating? Can the supply drive the current that is asked of it.
Describe the hardware setup you have.

the stepper motors are driven by easydriver boards

24 volt 6amp power supply (with 3amp fuse)
the boards get pretty hot (but i think that is normal)
i've got the pots turned right up give the motors more current

i just want to clarify when the stepper motors go 'slack'
they will move in the specified direction but it's stilted and every 5-10 seconds the motor relaxes the projectors falls to a balanced position then move again

the boards are wired up with controller cable

i will do voltage tests later tonight

visit this site..

the boards get pretty hot (but i think that is normal)

If it is too hot to keep your fingers on then it is too hot.
To me it sounds like some thermal protection is kicking in when the motors "relax" and at this point they are not being powered.
Try backing off the current.

i just want to clarify when the stepper motors go 'slack'
they will move in the specified direction but it's stilted and every 5-10 seconds the motor relaxes the projectors falls to a balanced position then move again

I agree with grumpy_mike, the symptoms look like thermal cycling. The motor controller overheats and protects itself. After the temperature falls, it restarts.

If you reduce duty cycle do the motors return to normal?

Joe