Stepper motor control in micropython

Hello guys, i am a new member of this forum. I recently bought an esp32 board and installed on it micropython. Since i know some of the basics of python i was thinking about making diy projects witsh this fantastic language and platform.

I have benn all day long trying to figure out how to drive a stepper motor (nema23) with an external driver such as a DM556. I cannot understand how to do it.
so i am now asking for your prescious help.

Hi @peter22,

For testing, try running this setup with an Arduino nano/ Arduino.

// 200 Steps
S1 ON
S2 ON
S3 OFF

// Ampere Rating 2.8
S4 OFF
S5 ON
S6 ON

With the code


/*
NEMA23 Stepper Motor Code Testing
*/

#include <AccelStepper.h>

const int stepPin = 3;
const int dirPin = 6;
const int relayPin = 8;
const int enablePin = 7;

AccelStepper stepper(1, stepPin, dirPin);

void setup() {
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  pinMode(relayPin, OUTPUT);

  digitalWrite(enablePin, LOW);  // Enable the motor driver

  // Setting up some default values for maximum speed and maximum acceleration
  stepper.setMaxSpeed(1000);      // Speed in steps per second
  stepper.setAcceleration(100);   // Acceleration in steps per second^2
  stepper.setSpeed(600);          // Initial speed in steps per second

  delay(1000);
  digitalWrite(relayPin, LOW);
}

void loop() {
  stepper.runSpeed();             // Continuous motor operation at set speed
}

If there is a brake, activate/release the brake as well of the motor.