2 Problems getting stepper to work

I have a Nema17 stepper motor and an DRV8825 driver on an adapter board.

I want to send the step signals from my ESP32 Pin 18.
But vor testing purposes I changed it to Pin 2 because of the internal ESP-LED on that pin.

My test-code looks like that:

#include <AccelStepper.h>

const byte StepPin = 18;
const byte DirPin = 5;
const byte ENPin = 19;

// Define a stepper and the pins it will use
//AccelStepper stepper;  // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
AccelStepper stepper(AccelStepper::DRIVER, 2, DirPin);

void setup() {
  Serial.begin(115200);  // Serielle Ausgabe an
  Serial.println("");
  stepper.setMaxSpeed(1000.0);
  stepper.setAcceleration(500.0);
  stepper.setEnablePin(ENPin);
  Serial.println("Enable");
  stepper.enableOutputs();
}

void loop() {

  Serial.println("Start LOOP");

  stepper.runToNewPosition(0);
  stepper.runToNewPosition(500);
  stepper.runToNewPosition(100);
  stepper.runToNewPosition(120);
}

Problem #1:
Once I use the line
"AccelStepper stepper(AccelStepper::DRIVER, 2, DirPin);" or
"AccelStepper stepper(1, 2, DirPin);" (use motor driver)

The output looks like that (mostly GND with some rare random spikes):

Once I use the line:
"AccelStepper stepper;"
I can see the (in my opinion) correct signal on Pin2

Now to problem No2.....

Problem #2:
Even if I got a signal on pin 2 and if I then connect Pin2 to the StepPin of the driver board there seems to be no output at all (Enable Pin is set correctly, checked that).

The motor is connected with a bought cable so I assume thats a standard connection where nothing should be a problem.

I connected the motor driver to 12V by an external lab bench supply (checked) and coneected the GNDs together.

Also the driverboard has theoretically the EN Pin set by the software:
"stepper.enableOutputs();"

But for some reason even that is in the code that pin is on 3,3V.
Anyway its not turning the motor even when I put the EN Pin manually on GND.

Also I just measured the SLP as well as RST Pins are on 1,68V which doesnt make any sense to me.

So did I place the driver board the correct way around on the expansion board? I think so right?

Please help with my two problems so I get the driver/motor working.
I attached some more Pictures of my setup:




Yes I did set the current limit right in the beginning but as you see on my lab supply 12V line the board isn't drawing any amps so its not driving the motor at all.

But why?

And why the heck don't I get a normal output when I use the line of code that I need to use (example 1)?

This is the expected output for step/dir drivers. The step pulse is only a very short spike ( <1µs by default ). The low time between the spikes should be the step time.
[Edit] Because the spikes are so short, your DSO may miss some with a slow timebase, so it looks random. You can increase the high time of the pulses with setMinPulseWidth(pulselen);

The second output looks like an output to a simple H-bridge driver ( there need to be 3 additional outputs that look similar). This is the default mode for accelstepper, but not suitable for step dir drivers.

Did you check the coils? Very much of those steppers need the middle connections crossed. Please post a datasheet of your stepper.

Seems I found the reason for Problem 2!

I had to connect the 3.3V and GND additionally to the 12V. I assumed until now that the voltage for the logic will be generated from the 12V motor voltage.

Will check if there are more spikes with shorter timing but as far as I think I already tried that and didnt see more.

And here is the motor datasheet:

Cloudray Nema 17 Stepper Motor 0,42 N.m 1,7 EIN 2 Phase 40mm.pdf (1.8 MB)

Yeah you seem to be right it now seems to work with that normal code for the driver.

Only the stepper isnt moving correctly as if there really is a coil not connected correctly.

But the print on the board is confusing 1A 1B and 2A 2B

So is it now Connector 1 and 2 of coil A
or is it
Connector A and B of coil 1?

And is it relevant A or B of one coil is this or that way around for example?

These are the 2 cables because of colors in the motor datasheet.

The one with only 1 connector is the one that was sent with the motor.
The other one is the one I use for connection.

Ok thanks I got it working finally!
now I can continue with my original code.

I really needed to swap the middle cable pins against each other!

Thanks again..... This took me 2 days to figure out all the problems.

Ok another last Question.....

The motor is rated for 1,7A and now it runs maybe 10 min back and forth and draws aroung half an Amp. Therefore way less than max rating.

But the motor is maybe at 50°C and the driver cooler also around that.

Is that normal?
Or might that be because of the way the motor is connected now +/- of a coil wrong way maybe?

They get warm, but shouldn't get too warm at 1/3 of max current. Measure temp. Up to 60'C is ok, but with that current I would expect much less. Depends on ambient tmp of course.

The current controlling drivers like the DRV8825 work similar to a buck converter. So the current from the PSU is less then the coil current. And the higher the voltage the less the current. You must look at the power the motor needs, not only at the coil current. That's why you need the data sheet. The rated current AND the coil resistance is important.
And yes, steppers get hot. A good datasheet also tells you the temperature rise at rated current. This may be even 80°C for full coil current.

Ok thanks!

A final advice: The current you adjust at the driver is NOT the rated current at full step mode. In full step mode the current is always the same in both coils. When using microstepping the driver controls the current in such a way, that the sum of the power of the two coils is always the same in every microstep. There are microsteps where one coil has no current at all, but the other even more ( the datasheet of the driver conains a table where you can see the rel. current in the different microsteps). And this max current is what you adjust at the driver. This means, when both coils are engaged with the same current, this is 0.707 of the set current. If you use full step mode and want to reach the full torque acording to the datasheet you must set the current at the driver to 1.41 of the rated current. Then you will get the full torque, but also the max temperature rise. If you don't need the full torque its advisable to set the current to a less value.

Thanks very much for the advice!

Thats my first project involving a stepper motor as you probably have guessed already.
The torque is I think more than enough this way I think.

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