Controlling stepper motor nema 34 using AccelStepper library

Hello all,

i have some question about stepper motor that i use now. i try using accelstepper example to try constant speed of this motor. i set the motor about 2000 step/rev. i want to know what maximum speed that i can run using this type of motor. now my coding are like this.

#include <AccelStepper.h>

AccelStepper stepper(1,8,9); 

void setup()
{  
   stepper.setMaxSpeed(4000);
   stepper.setSpeed(3000);	
}

void loop()
{  
   stepper.runSpeed();
}

IIRC the Accelstepper library can only produce about 2000 steps per second on a 16MHz Arduino. But the Arduino could produce a lot more than that if you forego the convenience of the library.

The maximum speed of a stepper motor is hugely affected by its power supply - higher voltages are better.

You need to post a link to the datasheet for your stepper motor - Nema 34 just defines the size of the front face

Also post a link to the datasheet for your stepper driver.

And give details (volts and amps) for your motor power supply.

You probably need to do some experiments with your actual equipment to see how it performs.

...R
Stepper Motor Basics
Simple Stepper Code

i set the motor about 2000 step/rev

That would mean you set microstepping to 1/10, as I assume you have a 200steps/rev stepper.

If you want the maximum speed, besides of what @Robin2 already pointed out, microstepping is slowing your motor speed down. Full step mode is the mode you need to gain maximum speed.

Also post a link to the datasheet for your stepper driver.

And give details (volts and amps) for your motor power supply

Here i attached the driver manual. I used 28K-H296 stepper motor. 2 phase, 1.8degree/step DC 6.0A.

supply i used to driver is 24vdc 1.5A.

How i can program the arduino if i press push button the stepper motor run to position i want. and if i press push button again the stepper motor will move to position i want.

thanks

MC2880DSP.pdf (481 KB)

You have not told us what happens when you try the code in your Original Post? What is the max speed you have achieved?

Have you tried the simple code I linked to? What was the max speed you achieved with that?

You did not post a link to the motor datasheet so I don't know the coil resistance which is necessary to calculate how many watts it requires. Your power supply can provide about 36 watts - that may be on the low side for your motor.

...R

@Robin2:
Motor comes with

  • 2,8Nm Holding torque,
  • 6,0A rated current
  • 0,3 Ohm phase resistance

So the power supply is way too weak for that motor.

@saripdol:
What about your microsteps setting? Did you go with full step setting?
Full step = SW5 .. SW8: -> ALL switches have to be set ON to get full step mode (=200 steps/rev)

SR2 should be set to: SW1=ON, SW2=ON, SW3=OFF (=> sets peak current to 5,6A)

And you will need a power supply of 24V/6A to make the most of your driver and motor.

rpt007:

  • 6,0A rated current
  • 0,3 Ohm phase resistance

So the power supply is way too weak for that motor.

That suggests 10.8 watts per coil (I2R) or about 22 watts total - considerably less than the power supply's 36 watts.

Maybe a very large capacitor across the power supply output would facilitate the supply of 6 amp pulses to the motor.

I would certainly prefer a power supply that could provide more amps.

...R

Steppers running at speed consume a lot more power - or rather they convert it to mechanical work.

But 1.5A is basically too low anyway, the supply will overload on switching transients, I'd suggest at least 3A
for this motor, or run the motor at 3A to see if that helps with the current supply.

AccelStepper does over 4000 steps/second IIRC on 16MHz, still pretty weedy of course.

rpt007:
@Robin2:
Motor comes with

  • 2,8Nm Holding torque,
  • 6,0A rated current
  • 0,3 Ohm phase resistance

So the power supply is way too weak for that motor.

@saripdol:
What about your microsteps setting? Did you go with full step setting?
Full step = SW5 .. SW8: -> ALL switches have to be set ON to get full step mode (=200 steps/rev)

SR2 should be set to: SW1=ON, SW2=ON, SW3=OFF (=> sets peak current to 5,6A)

And you will need a power supply of 24V/6A to make the most of your driver and motor.

Dear @rpt007

the setting i use now is 2000 step/rev sw5 OFF sw6 ON sw7 ON sw8 OFF. when i used setting 200 step/rev the sound of the motor so loud and i worry something not right. the Amp setting is 5.6A. but the original supply from power supply about 24vdc 1.5A. if i want to gain more speed i need increase volt or amp? because the driver state min volt about 24v and max is 80v. does not state the amp that should used in driver.

If you would have read the information which are accessible via @Robin2's links (see his reply #1) then you would know that it is important that you drive a stepper with the highest voltage possible.

This would then allow the driver to deliver the required current as fast as possible, thus gaining speed/ responsiveness of the motor.

Your problems are the following ones:

  1. Your mnicrostepping setting is currently 2000steps/rev. This means that your Arduino has to deliver 2000 pulses to have the motor turn 1 revolution! As long as you stay with 2000steps/rev you won't get that faster, even when all other parameters would be optimal; simple reason: Arduino is clocked at 16MHz and depending what code you are using (convenient libraries have the draw back that they consume some computation time and thus might only deliver between 4000 and maybe 6000 steps/sec); simpler code may go up to 12000 steps/sec, maybe a little bit more.

Let's assume, your Arduino would be able to control your driver with 10000 steps/sec, then it would result in 10000/2000 rev/sec = 5rev/sec. With the setting of 200 steps/rev this would go up to 50 rev/sec (theoretically -> this won't be reached due to the rise of inductance of the motor which will slow the speed down.)

It is quite normal, that your motor is much noisier when being driven at full steps as you have noticed; but this is ok although maybe inconvenient.

  1. As long as you don't change your power supply you will be in trouble and not in the position to drive your motor at its maximum. The noise would go down if your power supply can deliver more current, by the way.

A stepper motor is driven by current; your driver is a current controlling driver especially designed for stepper motors. So the best advice I can give is:
a) have a power supply with at least 48V (60V would be even better, 80V is the maximum -> don't go up to that due to tolerances etc.); it should be able to deliver min. 6A.
b) set the driver to 5.6A current limit (as you did already), so even when you have a power supply which is able to deliver 10A, the driver setting will limit it to 5.6A - thus not killing/burning your motor
c) play with the setting of microstepping to see the effect on the speed.

You can use the simple stepper program of Robin2 and while the stepper is turning you can adjust the microstepping (ONLY that microstep setting, but don't play around with the current limit settings while the motor is powered!).

Thanks @rpt007, I have another question if my input output pin already full can i program the stepper motor using analog pin, because i have read the analog pin can become same as digital pin just put an address 14 to 19.

Yes, you can.
Please read carefully the datasheet and/or description of your board.
You can use (almost) any analogue I/O of an Arduino as digital I/O.

rpt007:
If you would have read the information which are accessible via @Robin2's links (see his reply #1) then you would know that it is important that you drive a stepper with the highest voltage possible.

Higher voltage allows higher top speed, but is more lossy (copper and iron losses). As usual the answer
is to find a voltage that's high enough for the speed you need (which really needs some experimentation
as miss-stepping can be affected by the mechnical load and damping). Stupidly high voltage takes you
to higher speeds but then your wiring is high voltage and safety issues become important.