Pin Functions
Pin | Function |
---|
. | Power Supply |
GND | Ground |
VM | Motor Supply Voltage (5.5-28V) |
VIO | Logic Supply Voltage (3.3-5V) |
. | Motor Outputs |
M1A | Motor Coil 1 |
M1B | Motor Coil 1 |
M2A | Motor Coil 2 |
M2B | Motor Coil 2 |
. | Control Inputs |
STEP | Step-Signal Input |
DIR | Direction-Signal Input |
EN | Enable Motor Outputs (GND=on, VIO=off) |
. | Configuration |
MS1 | Step-Configuration or Slave-Address on UART, pd |
MS2 | Step-Configuration or Slave-Address on UART, pd |
SPREAD | Chopper, pd (GND=stealthChop, VIO=spreadCycle) |
PDN_UART | UART and Auto Power Down Control, pd (GND=on, VIO=off) |
DIAG | Diagnostics Output (VIO=error) |
INDEX | Index Output (one pulse per each four fullsteps) |
VREF | Analog Reference Voltage |
How to Use It?
This is a simple setup that doesn’t use all the fancier features of the stepper driver.
Step Configuration
CFG2/MS2 | CFG1/MS1 | SPREAD/MS3 | Steps | Interpolation | Mode |
---|
GND | GND | GND | 1/8 | 1/256 | stealthChop |
GND | VIO | GND | 1/32 | 1/256 | stealthChop |
VIO | GND | GND | 1/64 | 1/256 | stealthChop |
VIO | VIO | GND | 1/16 | 1/256 | stealthChop |
GND | GND | VIO | 1/8 | 1/256 | spreadCycle |
GND | VIO | VIO | 1/32 | 1/256 | spreadCycle |
VIO | GND | VIO | 1/64 | 1/256 | spreadCycle |
VIO | VIO | VIO | 1/16 | 1/256 | spreadCycle |
int enPin = 4;
int dirPin = 2;
int stepPin = 3;
int stepAmount = 400;
int microSteps = 16; // 16 means 1/16, 32 means 1/32 etc.
void setup() {
// put your setup code here, to run once:
pinMode(dirPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(enPin, OUTPUT);
digitalWrite(dirPin, HIGH);
digitalWrite(enPin, LOW);
}
void loop() {
oneFullRotation();
delay(1000);
}
void oneStep() {
digitalWrite(stepPin, HIGH);
delayMicroseconds(100);
digitalWrite(stepPin, LOW);
delayMicroseconds(100);
}
void oneFullRotation() {
for (int i = 0; i < stepAmount * microSteps; i++) {
oneStep();
}
}