3 phase stepper motor turns randomly

Hello everyone,
I'm trying to control a 3 phase stepper motor with an Arduino Uno, but it randomly changes directions while turning.

I'm using Moons stepping motor type 24HC2016-03, a 3 phase driver (3DM80S) from Cloudray and an Arduino Uno.

That is sadly the only datasheet i could find from the motor.

The information about the driver can be found here: Cloudray 3DM580S 3 Phase Stepper Motor Driver – Cloudray Laser. I can't attach the datasheet because of my account age, I'm sorry for that.

I tried connectiong the motor via the common cathode methode.
Screenshot 2024-06-11 210951

Here is the schematic:

And thats my code:

const int stepPin = 8;
const int dirPin = 9;
const int enablePin = 10;
const int spinDelay = 1000;

void setup()
{
  Serial.begin(9600);

  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enablePin, OUTPUT);
}

void loop() 
{
  Serial.println("Spinning one!");

  digitalWrite(enablePin, LOW);
  digitalWrite(dirPin, HIGH);

  for (int x = 0; x < 100; x++) 
  {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(spinDelay);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(spinDelay);
  }

  delay(1000);
}

The code should turn the motorshaft in one direction then stop for a second and then resume the rotation, but sometimes in changes directions while doing that. The driver is connected to a 25V 1A supply. I'm not quite sure how i configure the microsteps and the current via the dip switches. The second problem i have, are the connections from the u,v,w pins to the motor phases. How do i connect those the right way?

Thank you in advance.

Try this:

Your code might be stepping too fast.

Look at your posted data and check the current requirement. It is almost 2X what your supply can source. Start there and see what happens. Also post an annotated schematic showing allconnections, power, ground and power sources.

Your 1000 microseconds delay may be too short. I have seen step delays of about 10 mSec. for other stepper motors.

Reading your question again, I see you want a 1 second pause between steps. You should use the delay() funtion instead of delayMicros() funtion

Three phase motors are reversed by interchanging two leads. If the motor turns the opposite of the desired direction swap two leads.

Thanks for your answers everyone. I think my problem was that i connected the phases in the wrong order.
I also varied the spinDelay and the optimal value looks like to be around 600, but i still dont know why. If I use values below that number the delay is to fast and the motor doesn't spin, values higher than that (around 1000 - 2000) and the motor runs slower and produces a lot of vibration.

Connecting the phases in the wrong order will only either have no effect, or make the motor run backwards.

That shouldn't be your problem - the circuit doesn't suddenly get rewired during operation, does it?

Yes that makes sense, the motor is of course not rewired while in use. I changed the stepPin from 8 to 11 because of the PWM symbol "~" in front of it, maybe that was the problem?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.