Handle a stepper motor as both a PWM-controlled spindle and a positional axis. This board provides a versatile solution for applications requiring both high-precision positioning and speed control via PWM signals.
The Stepper Spindle Board is designed to handle a stepper motor in two distinct modes:
- PWM-Controlled Spindle Mode – Uses PWM signals (clockwise and counter-clockwise) to control the motor speed, acting as a spindle.
- Positional Axis (Motion Mode) – Provides direct positional control via a set of passthrough inputs, ideal for precise positioning tasks.
The board leverages the FastAccelStepper Library for high-performance stepper control and utilizes a web interface for remote control and monitoring.
- Dual Operation Modes:
- Spindle Mode: Map a 10-bit PWM input to RPM control.
- Motion Mode: Directly drive the stepper motor as a positional axis.
- Real-Time Control:
- Fast, interrupt-based PWM measurements and signal passthrough.
- Web API:
- Remotely control and monitor motor operations via a built-in web server.
- Persistent Settings:
- Save and load configuration parameters using non-volatile memory.
-
Stepper Motor and Driver Connections:
Connect the stepper motor and the corresponding driver to the board. Refer to the schematic for specific pin assignments. -
PWM Inputs for Spindle Control:
Connect the PWM signals (clockwise and counter-clockwise) and the spindle enable signal as specified in the schematic. -
MKS Board Integration:
The board is designed to accept directional, enable, and step signals from an MKS board. Ensure that the input pins are connected correctly:- Direction: Pin 7
- Enable: Pin 8
- Step: Pin 9
-
Install Required Libraries:
-
Upload the Firmware:
Use the Arduino IDE or your preferred toolchain to upload the provided firmware to your microcontroller (e.g., ESP32). -
Configure WiFi:
Update the WiFi credentials in the main code before uploading:const char* ssid = "SSID"; const char* password = "PASSWORD";
Below is the main program that demonstrates how to initialize and run the Stepper Spindle Board. This code sets up the board, starts the web interface for remote control, and prints status messages to the Serial monitor every second.
#include <Arduino.h>
#include "StepperController.h"
#include "StepperApi.h"
// Global instances
StepperController sc;
StepperApi stepperApi(&sc);
unsigned long previousMillis = 0;
const long interval = 1000; // Interval at which to print status to Serial (1 second)
// WiFi credentials (update these with your network details)
const char* ssid = "SSID";
const char* password = "PASSWORD";
void setup() {
Serial.begin(115200);
delay(1000);
// Setup the stepper controller
sc.setup();
// Start the web interface (this serves the dashboard and REST endpoints)
stepperApi.begin(ssid, password);
}
void loop() {
// Run the stepper controller's loop for real-time control and PWM measurement
sc.loop();
// Print status to Serial every second for debugging purposes
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
String mode = sc.getMode();
String spindleInfo = sc.getSpindleInfo();
if (mode == "Spindle") {
Serial.printf("Current Mode: %s, Spindle Info: %s\n", mode.c_str(), spindleInfo.c_str());
} else {
Serial.printf("Current Mode: %s\n", mode.c_str());
}
}
}- FastAccelStepper Library:
FastAccelStepper
Special thanks to all contributors and the community that supports the development of advanced stepper motor control solutions.
MIT License,