Arduino Uno Nema 23, DM542T Driver, Control

Hello,

I am working on a project which requires precise control of a stepper motor and I am starting to encounter problems as I begin developing the proper code.

I have tried a few example codes and have a few issues but I believe this may be a good starting place:

Upon executing this code my motor does not complete a full revolution.

// Stepper - Version: Latest 
#include <Stepper.h>

/*
 Stepper Motor Control - one revolution

 */
 
void setup() {
  
    // initialize the serial port:
  Serial.begin(9600); 
  
  int numberOfRevs = 1;
  const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
  // for your motor

  
  // initialize the stepper library on pins 8 through 9:
  Stepper myStepper = Stepper(stepsPerRevolution,8,9);
  
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
 
  

  //for(int n = 0; n < numberOfRevs; n++) {
  // step one revolution  in one direction:
  
  Serial.println("clockwise");
 
  myStepper.step(stepsPerRevolution);
 
  //delay(500);

  // step one revolution in the other direction:
  //Serial.println("counterclockwise");
  //myStepper.step(-stepsPerRevolution);
  //delay(500);

}
void loop() { 
}

^this is the specific Nema 23 I am using

^Motor Driver

Second associated problem is that the code seems to run twice when I try to use the serial monitor in Arduino Web Editor.

I would appreciate any and all help!

Need to get this going asap so thank you in advance!

The standard Stepper library is not intended for stepper drivers that take step and direction inputs. Have a look at the AccelStepper library

Or just write your own code.

These links may be of interest
Stepper Motor Basics
Simple Stepper Code

What stepper motor power supply are you using (volts and amps) ?

...R

That vendors page doesn't give a clue about voltage or winding resistance which we need to know, do you have a DMM to measure?
BTW: how many motor leads?

outsider:
That vendors page doesn't give a clue about voltage or winding resistance which we need to know, do you have a DMM to measure?

I think it is sufficient to know the motor current. With a current of 2.5 amps I think it is is safe to assume a low coil resistance.

...R

Robin2:
The standard Stepper library is not intended for stepper drivers that take step and direction inputs. Have a look at the AccelStepper library

Or just write your own code.

These links may be of interest
Stepper Motor Basics
Simple Stepper Code

What stepper motor power supply are you using (volts and amps) ?

...R

Thank you, i will work through that library moving forward.

this is the motor supply I am currently using:

https://us.banggood.com/Wholesale-Warehouse-110-220V-to-36V-400W-Switch-Power-Supply-Transformer-LED-Strip-Light-Driver-wp-Usa-1100516.html?gmcCountry=USD&currency=USD&createTmp=1&utm_source=googleshopping&utm_medium=cpc_elc&utm_content=zouzou&utm_campaign=pla-us-usw-A-M-pc&gclid=CjwKCAiA24PVBRBvEiwAyBxf-eUkmu4jlqIR3iC7EwSRA47h66kND1CkFzbvXY_ZvbkV95nS5sdEVBoCL4YQAvD_BwE

outsider:
That vendors page doesn't give a clue about voltage or winding resistance which we need to know, do you have a DMM to measure?
BTW: how many motor leads?

2 motor leads but unfortunately I do not have a DMM in my possession

Hello,

an update from poster:

I have started my journey into the accelStepper Library and I have successfully written codes to rotate two of my Nema 23 Stepper motors simultaneously.

To further elaborate on the necessary functions I need; I am looking for one motor to be used to traverse an object linearly, i would like for there to be a home position and for the object to return there upon completion of its traversing. The second motor is used to push a liquid out of the object, therefore i would like it to maintain a constant pressure.

Here is my current code:

#include <AccelStepper.h>

AccelStepper mystepper1(1,8,9);
AccelStepper mystepper2(1,4,5);



void setup()
{  
   Serial.begin(9600);           // set up Serial library at 9600 bps
   Serial.println("Stepper test!");
  
  
  mystepper1.setMaxSpeed(2000); //20000 steps/second max
  mystepper1.setSpeed(63.33);	//19 rpm
  
    mystepper2.setMaxSpeed(2000); //20000 steps/second max
    mystepper2.setSpeed(63.33);	//19 rpm
}

void loop()
{  
   mystepper1.runSpeed();
   mystepper2.runSpeed();
}

Unfortunately it still seems like the motors RPM is far less than 19 RPM

What are some possible causes for this?

Secondly, Could someone provide some insight into the kind of code and logic I need to look into to achieve my functionality.

Thank you in advance!!

1 Like

jlebz:
Unfortunately it still seems like the motors RPM is far less than 19 RPM

When you have a problem the first step is to simplify. Get one motor working the way you want.

You almost certainly need to use acceleration if you want to get a high speed. You may also find that a motor that has nothing attached to its shaft gets caught up in oscillations. Maybe add a flywheel or a load on the shaft. Microstepping can alleviate oscillation problems but then you need a higher step rate for the same speed and the AccelStepper library does not have a very high max step rate.

...R

I ran into the problem mentioned early on this page about code seeming to run twice. I was using a cheap clone nano. When I added some second+ delays the problem went away. When I switched to using an Elegoo uno r3 with the same code, the problem also went away, but without needing any delays. I wasted way too much time on this and would have been happier paying more for a quality arduino to begin with.