Nema17 nightmare

Hello all

I have been playing with some Nema17 steppers...

https://thepihut.com/products/nema-17-stepper-motor-42mm-x-40mm

I had a couple of A4988 Drivers here (standard red ones).

I drove them off an ESP32 Wroom (I hate those things) because I had a breakout board for one of them.
After faffing for HOURS trying to get a library to work, I finally got it running using the following library...

https://github.com/pkerspe/ESP-FlexyStepper

But... it runs absolutely horrible, very noisy with next to zero torque. The baffling array of Googled results on how to set the current doesn't help.
Using a decent 12v supply for the steppers and the ESP32 is running on 3.3v (as are the A4988's)

I have now ordered a couple of these drivers (same chip)... as these might be a bit suspect.

https://thepihut.com/products/a4988-stepper-motor-driver-carrier-black-edition

Now I am driving them using the examples in the library....

//      ******************************************************************
//      *                                                                *
//      *         Simple example for controlling a stepper motor         *
//      *                                                                *
//      *            Paul Kerspe               4.6.2020                  *
//      *                                                                *
//      ******************************************************************

// This is the simplest example of how to run a stepper motor.  
//
// Documentation for this library can be found at:
//    https://github.com/pkerspe/ESP-FlexyStepper/blob/master/README.md
//
// This library requires that your stepper motor be connected to the ESP 
// using a driver that has a "Step and Direction" interface.  
// Examples of these are:
//
//    Pololu's DRV8825 Stepper Motor Driver Carrier:
//        https://www.pololu.com/product/2133
//
//    Pololu's A4988 Stepper Motor Driver Carrier:
//        https://www.pololu.com/product/2980
//
//    Sparkfun's Big Easy Driver:
//        https://www.sparkfun.com/products/12859
//
//    GeckoDrive G203V industrial controller:
//        https://www.geckodrive.com/g203v.html
//
// For all driver boards, it is VERY important that you set the motor 
// current before running the example.  This is typically done by adjusting
// a potentiometer on the board.  Read the driver board's documentation to 
// learn how.

#include <ESP_FlexyStepper.h>

// IO pin assignments
const int MOTOR_STEP_PIN = 3;
const int MOTOR_DIRECTION_PIN = 4;

// create the stepper motor object
ESP_FlexyStepper stepper;

void setup() 
{
  Serial.begin(115200);
  // connect and configure the stepper motor to its IO pins
  stepper.connectToPins(MOTOR_STEP_PIN, MOTOR_DIRECTION_PIN);
}

void loop() 
{
  //
  // Note 1: It is assumed that you are using a stepper motor with a 
  // 1.8 degree step angle (which is 200 steps/revolution). This is the
  // most common type of stepper.
  //
  // Note 2: It is also assumed that your stepper driver board is  
  // configured for 1x microstepping.
  //
  // It is OK if these assumptions are not correct, your motor will just
  // turn less than a full rotation when commanded to. 
  //
  // Note 3: This example uses "relative" motions.  This means that each
  // command will move the number of steps given, starting from it's 
  // current position.
  //

  // set the speed and acceleration rates for the stepper motor
  stepper.setSpeedInStepsPerSecond(100);
  stepper.setAccelerationInStepsPerSecondPerSecond(100);

  // Rotate the motor in the forward direction one revolution (200 steps). 
  // This function call will not return until the motion is complete.
  stepper.moveRelativeInSteps(200);
  delay(1000);
  // rotate backward 1 rotation, then wait 1 second
  stepper.moveRelativeInSteps(-200);
  delay(1000);

  // This time speedup the motor, turning 10 revolutions.  Note if you
  // tell a stepper motor to go faster than it can, it just stops.
  stepper.setSpeedInStepsPerSecond(800);
  stepper.setAccelerationInStepsPerSecondPerSecond(800);
  stepper.moveRelativeInSteps(200 * 10);
  delay(2000);
}

Can someone explain to me how to correctly set the current. I started at the lowest and rotated clockwise until it started to run OK with no missed steps.
The voltage on the metal part of the potentiometer was 0.71v.

But... I just don't understand the lack of power. They only appear to run in one connection order. Reversing any wires on the stepper just means it fails to rotate.

Thanks

Likely problems include not setting the motor current limit correctly on the driver, using an inadequate motor power supply, and trying to step the motor too fast. Also, the A4988 can handle at most 1 Ampere/winding.

....so, how do you set it correctly? I have read different ways of doing this.
That improved driver board is apparently better amp rated, but it's not particularly doing much load (nothing at the moment).

Baffled. The Nema17's on my CNC are far more powerful. Wonder what drivers are on a Rambo board?

Set the stepper driver to 1 A/winding following the directions in the A4988 data sheet. You will need to know the value of the current sense resistors on the driver board

The motor power supply should be rated for at least 2 A.

NEMA17 specifies NOTHING about the motor's electrical characteristics, only the dimensions of it's front mounting face.
Post a link to the motor's datasheet or, at least, the brand name and exact part number so we can search and (hopefully) find out something about it's voltage, current and torque ratings.
Here, in totality, is what NEMA17 tells us about the motor.
nema-17-stepper-motors-dimension

1 Like

Well the only datasheet I have is the one on the page where I bought it..

https://cdn.shopify.com/s/files/1/0176/3274/files/SL42STH40-1684A.pdf?v=1671113896

Rated voltage 2.8v? Eh?

Very good, TNX

Notice the graph for running at 24 volts. The current limit for each winding is over 1.5 amps, use at least a 5 amp supply and capable driver board.

I understood that I could run these Nema17's on 12v. Is that why they are underpowered?

My CNC at home is 12v running Nema17's on a Rambo board. I can't run these on 24v, I only have 12v DC (10A) in the cabinet.

The graph in the document you linked to should be your guide. Notice how the torque falls off when the PPS, pulse per second exceeds some value. So you need to be sure you are still in the sweet spot for pulses per second.

According to the linked data sheet, each coil requires about 5W of power. Taking into account the losses in the driver and some safety margin, a 20W power source should be sufficient. You can use 12V, but you will lose more torque at higher speeds than with 24V.

OK. I will have to get this wired up (again) and have a play. Not all that impressed so far.
Wish I have gone down the route of a standard geared motor now.

That datasheet says 1.5R per phase. I measured it at 5.5R across each coil. Not sure what gives there and doesn't make me have much faith in that Chinese datasheet.

Thought Thepihut would have been better than that. Might as well use AliExpress

Can I ask... if the datasheet says 24v @ 1.77A (in the box bottom right)...

I thought amps doubled if you halved the voltage. Surely this Nema17 isn't possibly going to pull 3.54A? That's mad.

I also assume that Chinglish 'Half Stap' means that graph is based on half step?

That applies to plain old resistors. You have an active controller that applies the same amps you have set it for for all voltages. The difference is the wattage/power applied to the motor windings.

AAAAHHHH

Can anyone tell me the value of this Vref sensing SMD resistor.... apparently its supposed o be 0.05R, but that isn't what I get when I put it in an SMD value calculator (I get something like 7.7k?)

Looks like 30C to me.

I get a wild odd value if I try measuring it, which I assume is because it's in circuit

a4988-vref-resistor

This is not the sense resistor to calculate the correct Vref value at the pot. The two sense resistors ( one for each coill ) are the bigger ones above.

No, if the amps through the coils is the same, than the wattage is also the same. The difference when using higher Voltages is, that the driver is able reach this amp even when fast switching the coils between +/- current flow - what is needed for high step rates.

THIS IS WHY WE STRUGGLE

https://ardufocus.com/howto/a4988-motor-current-tuning/

This is where I got the image of my board...

Geared motor it is

There is really a lot of crap at the internet. Maybe it's better to follow the pololu instructions. :wink:

The stepper just sits there juddering.... no torque and unable to rotate.

No combination of coil connections makes any difference.

You should not blindly try different combinations. The datasheet shows which wires belong to one coil. If you don't trust the datasheet .. you can measure it. Please show a schematic and y good picture of your actual wiring.

Did you switch power off when you changed the combinations? You can damage your driver if you pull off a coil wire while under power.