2 steppermotors apparantly running in half speed

I have written a very simple program to run 2 steppermotors with a different speed. When I started writing code for 1 steppermotor the speed of the motor seems to be higher whilst running 2 steppermotors the speed seems to be half. I use an Arduino Mini Pro.

Here is the code:

#include <SoftwareSerial.h>

int motor1Puls = 2;
int motor1Dir = 3;
int motor2Puls = 4;
int motor2Dir = 5;

long puls;
int motorsnelheid_1 = 900; /* let op omgekeerd evenredig /
int motorsnelheid_2 = 700; /
let op omgekeerd evenredig */

void setup()

{
Serial.begin(9600);

pinMode(motor1Puls, OUTPUT); // sets the digital pin as output
pinMode(motor1Dir, OUTPUT); // sets the digital pin as output
pinMode(motor2Puls, OUTPUT); // sets the digital pin as output
pinMode(motor2Dir, OUTPUT); // sets the digital pin as output

digitalWrite(motor1Dir, LOW); /* motor penarmen draait linksom /
digitalWrite(motor2Dir, LOW); /
motor draaitafel draait linksom */
}

void loop(){

digitalWrite(motor1Puls, HIGH);
delayMicroseconds(motorsnelheid_1);
digitalWrite(motor1Puls, LOW);
delayMicroseconds(motorsnelheid_1);
digitalWrite(motor2Puls, HIGH);
delayMicroseconds(motorsnelheid_2);
digitalWrite(motor2Puls, LOW);
delayMicroseconds(motorsnelheid_2);
}

I think the problem is in the code of void loop, but I don’t know how to rewrite the code in order to get the speed as it should have been when running 1 motor only.

ANy help is welcome. Just use 2 Arduino Mini’s?

try motor 1 on, motor 2 on, motor 1 off, motor 2 off.

if running only 1 motor times the delay by 2

lambordina: I have written a very simple program to run 2 steppermotors with a different speed. When I started writing code for 1 steppermotor the speed of the motor seems to be higher whilst running 2 steppermotors the speed seems to be half.

You can't achieve what you want using delay() or delayMicroseconds() because they block the Arduino until they finish. Have a look at the second example in this Simple Stepper Code which uses millis() and micros() for non-blocking timing.

Also note that the step pulse is short and all the timing is concentrated into the interval between steps.

...R Stepper Motor Basics

I just changed the variables for the motorspeed from 900 and 700 to 450 and 350. Now I have the required speeds.

Thanks joeblogs for the simple solution.