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: