Nema34 Motor Not Running

Hi.

I'm trying to get a big 5.6A Nema34 motor running, via a DQ86OMA driver. The motor is: WT86STH118-6004A (http://www.wantmotor.com/ProductsView.asp?id=251&pid=88).

The motor sounds like it wants to move, in that it makes a little glitch sound whenever it receives a pulse, but the shaft doesn't rotate. I'm trying to get a single motor running, so that I can start working on a system with 6 similar motors. Any help, or just a pointer in the right direction, would be appreciated.

I've got digital 9 of the Arduino going to 'Pulse Negative' on the driver and digital 8 to 'Direction Negative', with both 'Pulse' and 'Direction' Positive to Arduino's 5V. Power to the motor, via the driver, comes from a 60V / 5.85A PSU. All as shown in the schematic.

I have the driver's DIP switches set to: SW1, SW2 and SW8 (5.7A Peak, 25600 Pulse/Rev), according to the table printed on the driver.

The hardware came to me, wired as above with (I'm told) one of the Stepper Library examples on the Arduino; the system worked - the shaft rotated back and forth - but whenever I now try any of the Stepper examples, I get the fault described above. I'm currently trying the 'Random' example from the AccelStepper library, but with the same result.

Thanks.

#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(1,9,8); // Edited for Step & Direction only
void setup()
{
}
void loop()
{
if (stepper.distanceToGo() == 0)
{
// Random change to speed, position and acceleration
// Make sure we dont get 0 speed or accelerations
delay(1000);
stepper.moveTo(rand() % 200);
stepper.setMaxSpeed((rand() % 200) + 1);
stepper.setAcceleration((rand() % 200) + 1);
}
stepper.run();
}
Generated by   doxygen 1.8.5

You might try a brute force method - just toggle Step and see if the motor turns. You could use something as simple as the tone() library to do so, just start slow.

If the driver just takes step and direction signals this simple code should make it work - and it will be easy to modify for experimental purposes.

// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at http://forum.arduino.cc/index.php?topic=208905.0

byte directionPin = 6;
byte stepPin = 5;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 25; // milliseconds


void setup() 
{ 

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
  
  delay(2000);

  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
 
  digitalWrite(directionPin, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
  delay(3000);
  

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
}

void loop() 
{ 

}

...R

No! Please don't teach him using delay. Horrible idea. Nonscalable. Can't do anything else while it is delaying.

OK, I'm calmed down. That'll do for testing.

Hi, have you got a manual for the drive?
I'd say you would have to have some connections to the enable terminals to get the drive to work.

Tom...... :slight_smile:

polymorph:
That'll do for testing.

That is its only purpose.

...R

Yes, these drives all have an enable input too, this may well need to be driven
to achieve rotation, but I'm worried by the motor actually making a sound.

Check the drive is programmed to the right current level and for step/direction
mode (not forward/backward pulses). It might just be the drive comes out of
the box configured for minimum current.

Also (when powered down), double check the motor connections for both windings
are correctly wired up and sound.

It's obvious from the picture he hasn't connected the "enable" line. The motor isn't supposed to do anything until you give that enable 5V. These are usually opto-coupler inputs, so what I would do is use the Arduino's 5V to power the "+" term of each input, then the outputs will be low-true. The other way is to connect it so it's high true but we need the manual to make sure they didn't common the 5V terminals.

Hi, this might help.

http://www.wantmotor.com/ProductsView.asp?id=271&pid=82

On the same site, enable + needs to be held +5V and enable - needs to be at GND Along with a connection diagram.

Hope we get to see a circuit diagram that the OP has.

Tom..... :slight_smile:

Thanks for all your replies. Apologies for my slow response; I was battling with this yesterday, trying to get a better understanding of the system before reposting.

I realised that I'd not considered the Pulse per Revolution settings of the driver within the code, and was expecting 200 steps to give me one full rotation, but have now taken that into account and the motor is moving. I'm not sure whether this explains why the motor wasn't moving AT ALL initially though.

A few of you have mentioned the lack of an 'Enable' connection. I took the wiring from this guy: Use Arduino to Control a Large Stepper Motor! Part 1 - YouTube. It's quite a lengthy video, but he describes the wiring at 2:20. The setup seems similar to my own, so I'd left out the Enable connection too (wiring diagram also attached to my original post). Tom, I took a look at the diagram in the link that you posted - Is this still something that I need to worry about now the motor is moving, as it seems to be enabled as default?

I've been unable to find a manual for the driver online. There's a datasheet mentioned on one of the CNC forums, but it is in German. I'll contact Wantai and try and get something from them.

@Robin2 - Your code works perfectly for this setup (with 'numberOfSteps' equal to the PPR setting of the driver).

I adapted one of the Stepper library examples. However, when I make 'stepsPerRevolution' equal to the Pulse per Revolution setting of the driver, I find that the motor only turns one quarter of the specified angle. I found this out when I accidentally had the driver set to 800 PPR with 'stepsPerRevolution' set to 3200; I thought it was working correctly (as I was getting a 1/4 turn from the first motor and 72 turns from the second) until I noticed I'd got the driver set to 800 rather than 3200. I suspect that I may have to abandon the Stepper library but that code is below, in case it sheds any light.

#include <Stepper.h>

const int stepsPerRevolution = 3200;  // change this to fit the number of steps per revolution
                                     // for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper1(stepsPerRevolution, 8,9); 
Stepper myStepper2(stepsPerRevolution, 10,11); 

void setup() {
  // set the speed at 60 rpm:
  myStepper1.setSpeed(10);
  myStepper2.setSpeed(10);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  dualMotor();
}

void dualMotor() {
  Serial.println("clockwise");
  myStepper1.step(stepsPerRevolution*0.25);   // step 1/4 revolution in one direction
  delay(500);
  // step 72 revolutions  in one direction
  for(int i = 0; i < 73; i++) { 
    myStepper2.step(stepsPerRevolution);
    Serial.println(i);
  }
  delay(500);
  Serial.println("counterclockwise");
    // step 72 revolutions  in other direction
    for(int j = 0; j < 73; j++) { 
    myStepper2.step(-stepsPerRevolution);
    Serial.println(-j);
  }
  delay(500);
  myStepper1.step(-stepsPerRevolution*0.25); // step 1/4 revolution in the other direction
  delay(500); 
}

Here's the diagram from Wantai, it doesn't show any more than in the link that Tom shared but it confirms +5 to Enable, which I've wired just to be sure. There's a proprietary 'do not share' warning on the drawing, but screw that :wink:

bngllghr:
@Robin2 - Your code works perfectly for this setup (with 'numberOfSteps' equal to the PPR setting of the driver).

I adapted one of the Stepper library examples. However, when I make 'stepsPerRevolution' equal to the Pulse per Revolution setting of the driver, I find that the motor only turns one quarter of the specified angle

I have no experience of the Stepper library - as I have stepper drivers that take step and direction signals the library does not seem to be any value.

HOWEVER I'm not sure if the Stepper library "knows" that you have a stepper-driver. I ran into this problem with the AccelStepper library which has a special initialization value DRIVER for when you are using a stepper-driver. Otherwise (I think) it assumes the two pins are controlling the stepper coils directly. When I was not using the DRIVER option the Accelstepper library behaved strangely - can't now remember what the symptoms were.

...R

Robin2, I had literally only just gotten Accelstepper working when I read your post. So far, I think this looks the way to go. The documentation takes a bit of research to understand (for me at least), so I'll spend some time on this over the next day or so and post back with results.

You're right to say that Accelstepper defaults to 4 wire motor connections. I am now using the constructor:

AccelStepper stepper(1,9,8);

For anyone who might stumble across this thread with similar issues, the parameters inside the constructor translate as follows:
1 = mode 1 (AccelStepper's driver setting)
9 = stepPin on pin9
8 = directionPin on pin8.

Thanks,

Ben.

bngllghr:
AccelStepper stepper(1,9,8);

I think AccelStepper stepper(DRIVER,9,8); is identical.

...R

Hi, Ben, good to see you are progressing.
I think from what I see of the driver site and googling, that link is as close as you will get to a manual.

Tom..... :slight_smile:

Hi guys,

So, I've been trying to get this code working all weekend and, having tried all sorts of different ways of writing it, I'm struggling to get two motors moving sequentially. That is to say, I want 'motor1' to move 90 deg. clockwise, then 'motor2' to move 3 full rotations clockwise. then 'motor1' to return anticlockwise to 0 deg. then finally 'motor2' to return 3 rotations anticlockwise to 0 deg, with only one motor moving at any one time.

I've written 4 functions, one for each stage, which are a bit clumsy since I am using 'for' loops to call 'run()' for each required step, but which work when I run one motor, so if inside of 'loop()', I say:

void loop(){
motor1Clockwise();
motor1Anticlockwise();
motor1.run();
}

...it runs fine, motor1 turns back and forth as expected. Likewise if I do this for motor2. But if I do:

void loop(){
motor1Clockwise();
motor2Clockwise();
motor1Anticlockwise();
motor2Anticlockwise();
motor1.run();
motor2.run();
}

... I get all sorts of erratic behaviour; either one motor moves back and forth repeatedly, without waiting for the other one to complete its rotation, or one motor will move once or a few times between delays. I only have one motor and so am switching it between pins to test, so it's difficult to know exactly what the sequence looks like, but it's not following the pattern that I expect, and doesn't seem to have a discernible sequence of it's own.

I suspect that it has something to do with the way that I am calling 'run()'. I understand that this' needs to be called each time that a step is required and that it should do nothing when no step is expected, say if I've set a target position via 'moveTo' and this has been reached. But shouldn't the 'for loop' of each function complete before moving onto the next function, say from 'motor1Clockwise()' to 'motor2Clockwise()' for instance, so that one motor doesn't move until the previous one has stopped? I'm also confused why, unless I call run inside of loop() (but outside of my functions), I only get one rotation as if it had happened inside of setup().

What am I missing?

Thanks,

Ben.

#include <AccelStepper.h>

long ppr = 3200; // one rotation in steps set by your driver
int s = 1000; // speed in steps per second

AccelStepper motor1(1,9,8); // step = pin 9; direction = pin 8
AccelStepper motor2(1,7,6); // step = pin 11; direction = pin 10

void setup()
{
  motor1.setMaxSpeed(1500);
  motor2.setMaxSpeed(1500);

}

void loop(){

  motor1Clockwise();
  motor2Clockwise();
  motor1Anticlockwise();
  motor2Anticlockwise();
  motor1.run();
  motor2.run();
  }

void motor1Clockwise(){
   if(motor1.currentPosition() == 0){
    delay(1000);
    motor1.moveTo(ppr*0.25);
    motor1.setSpeed(s);
      for(int i=0; i<ppr*0.25; i++){
       motor1.run(); 
    }
  } 
}

void motor1Anticlockwise(){
  if(motor1.currentPosition() == ppr*0.25){
    delay(1000);
    motor1.moveTo(0);
    motor1.setSpeed(s);
    motor1.runSpeedToPosition();
        for(int j=0; j<ppr*0.25; j++){
         motor1.run(); 
    }
  }
}

void motor2Clockwise(){
   if(motor2.currentPosition() == 0){
    delay(1000);
    motor2.moveTo(ppr*3);
    motor2.setSpeed(s);
        for(int k=0; k<ppr*3; k++){
          motor2.run(); 
    }
  } 
}

void motor2Anticlockwise(){
  if(motor2.currentPosition() == ppr*3){
    delay(1000);
    motor2.moveTo(0);
    motor2.setSpeed(s);
    motor2.runSpeedToPosition();
      for(int m=0; m<ppr*3; m++){
        motor2.run(); 
    }
  }
}

bngllghr:
... I get all sorts of erratic behaviour; either one motor moves back and forth repeatedly, without waiting for the other one to complete its rotation, or one motor will move once or a few times between delays. I only have one motor and so am switching it between pins to test, so it's difficult to know exactly what the sequence looks like, but it's not following the pattern that I expect, and doesn't seem to have a discernible sequence of it's own.

I doubt if you can debug what you are trying to do without 2 motors.

As far as I know the code you have written tells motor1 to start and then tells motor2 to start. The way AccelStepper works it will run those two actions in parallel, not sequentially.

You need to ensure that the action of motor1 is finished before telling motor2 to start - there are functions in the library for that.

...R

You need to call the run functions repeatedly until the motor has finished its move - you
don't decide how many times to call it in advance, you call it in a while loop checking for
completion... Each call to run may step or not, depending on the the elapsed time and the
AccelStepper library's idea of what should be happening.