2 stepper don't running together

Hey,

I have two steppers both of them runs perfect with a single control (a code for one stepper, similar to the following code). But they don't run at the same time, because one of them does more steppes (he runs unround). I think the problem is in the code but I can't find it.

FabScan Shield (FabScan-Shield for Schrittmotortreiber - Watterott electronic)

A4988-driver (Motortreiber - Watterott electronic)

  • i limited it to 800mV

Arduino Uno

Stepper Motor: Bipolar, 200 Steps/Rev, 20×30mm, 3.9V, 0.6 A/Phase (https://www.pololu.com/product/1204)

int enPin = 5;
int stepPin = 6;
int dirPin = 7;

int enPinL = 2;
int stepPinL = 3;
int dirPinL = 4;

void setup() {
  pinMode(enPin,OUTPUT);
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  digitalWrite(enPin,LOW); // en muss auf Low= 0-> eingschalten
  
 pinMode(enPinL,OUTPUT);
 pinMode(stepPinL,OUTPUT);
 pinMode(dirPinL,OUTPUT);
 digitalWrite(enPinL,LOW); // en muss auf Low= 0-> eingschalten
}

void loop() {
  digitalWrite(dirPin,HIGH); //Richtung festlegen
  digitalWrite(dirPinL,HIGH);
  for( int i = 0; i < 200;i++){
    digitalWrite(stepPin,HIGH);
    delay(10);
    digitalWrite(stepPinL,HIGH);
    delay(10);
    digitalWrite(stepPin,LOW);
    delay(10);
    digitalWrite(stepPinL,LOW);
    delay(10);
  }
  delay(1000);
  

}

It's probably the delays(). Delays are evil, the Arduino can one do one thing at a time but with a delay you tell the Arduino to just sit and do nothing.

okay, than I will try it first with delayMicroseconds()

Are they using microstepping? Are they set to the same microstep rate?

MarkT:
Are they using microstepping? Are they set to the same microstep rate?

200 is a full step.

Yes, have microstepps 1/16 but I didn't try same.

Try both at 1/16th, less resonance effects, if still not happy one of the motors might be
miswired or there could be a faulty connection. Always power down stepper driver before
tinkering with motor wiring, otherwise you can get sparking and burn out the driver.

Oh, and the obvious simple test, swap motors and see if the malfunction moves with
the motor or stays put with the driver. You can swap connections to the Arduino as
well to debug troubleshoot (power down before rewiring of course).

Okay, it might be a little complex now.

I change the drivers and in the beginning both steppers turn but the left one faster and the right one perfect. After some time(40s) only the right one turns. I reconnected the voltage and first both turns(5s) and then the right one stops and the left one runs perfect. I can not unterstand it:(.

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
What are you using for power supply to the stepper and control assemblies?

Thanks ,, Tom........ :slight_smile:

Do you have enough power?

''Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
What are you using for power supply to the stepper and control assemblies?''

Okay, I did it like this with the fabscan shield. I use 9V batterys.

Small 9V batteries? No chance, they cannot provide enough power for motors at all.

I have 6 times AA batteries each with 1.5V.

I am cooling my driver.

You may be pulling several amps peak from the batteries and AA battery holders
are typically unable to handle that properly, even if the cells are up for it - if the
holder has rivetted construction it is not good for high current.

Measure the voltage under operation, if it drops significantly the power's not adequate.

First of all im not english speaker but i will try to help you anyway.

One of your problem is the Delay and microdelay because during a delay and a microdelay you cant read your inputs, change any output, your code just stop and wait the time pass. But if you use millis for time control, your Arduino is free to do other tasks.

This example use millis instead of the delay

MarkT:
You may be pulling several amps peak from the batteries and AA battery holders
are typically unable to handle that properly, even if the cells are up for it - if the
holder has rivetted construction it is not good for high current.

Measure the voltage under operation, if it drops significantly the power's not adequate.

Thanks, you are right. Have you got some experience about the right choice of batteries? I need at least 9V but how much A I need?

I will try to use millis :slight_smile: