NEMA 23 stepper on a TB6600 drive
Run a NEMA 23 stepper from a 24 V supply through an opto-isolated TB6600 drive, set by its DIP switches.
Motors · Intermediate
In a real product: Laser cutter (Industrial): Large steppers move the gantry.
Hobby drivers like the A4988 top out around 2 A. Bigger stepper motors, like the NEMA 23s in CNC routers and the axes of a machine, use a boxed drive like the TB6600. It takes a 9–42 V supply and up to 4 A peak. Its inputs are opto-isolated: the board only lights an LED inside the drive, so the noisy motor supply never shares a wire with your microcontroller.
What you'll learn
- How opto-isolated PUL/DIR/ENA inputs work, and the two ways to wire them
- Setting microsteps and current with DIP switches
- Why the motor supply is separate from the logic supply
How it works
Each input is a pair of terminals, + and −, with an optocoupler LED between them. The input is on while current flows from + to −. Here the − terminals go to the Arduino's GND and the pins drive the + terminals (common cathode), so a pin HIGH turns its input on:
- PUL (pin 3): each time it turns on, the motor moves one microstep.
- DIR (pin 4): on is one direction, off the other.
- ENA (pin 5): on disables the drive and frees the motor. Leaving it off (pin LOW) keeps the drive running.
The other common wiring is common anode: the + terminals go to 5 V and the pins pull the − terminals low. An input is then on while its pin is LOW. Both wirings work in the simulator.
The DIP switches S1–S3 set the microsteps: OFF ON OFF is 1/8, so 1600 pulses make one turn. S4–S6 set the motor current. Click the drive to change them, and the drawing shows the switch positions. The 24 V supply (V+ and V−) only powers the drive. Its V− is not wired to the Arduino's GND, which is what isolation means. The drive does nothing until its supply is between 9 and 42 V.
Try this
- Set the microstep to 16 in the part's settings: the same sketch now turns half as far. Change
STEPS_PER_TURNto match. - Rewire as common anode (PUL+, DIR+, ENA+ to 5V; pins to PUL−, DIR−, ENA−). What do you have to invert in the sketch?
- Set the supply to 48 V: the TB6600 is out of range and stops.
sketch.ino
// A NEMA 23 stepper on a TB6600 drive (1/8 microstep: 1600 pulses a turn), wired common cathode:
// PUL+ pin 3, DIR+ pin 4, ENA+ pin 5, and PUL-, DIR-, ENA- to GND. One turn forward, a pause, one turn back.
#include <AccelStepper.h>
const int PUL = 3, DIR = 4, ENA = 5;
const long STEPS_PER_TURN = 1600;
AccelStepper stepper(AccelStepper::DRIVER, PUL, DIR);
void setup() {
Serial.begin(115200);
pinMode(ENA, OUTPUT);
digitalWrite(ENA, LOW); // ENA off: the drive is enabled
stepper.setMinPulseWidth(5); // the TB6600 needs pulses of at least 2.2 us
stepper.setMaxSpeed(1600); // pulses per second: one turn a second
stepper.setAcceleration(1600);
stepper.moveTo(STEPS_PER_TURN);
Serial.println("Turning forward");
}
void loop() {
if (stepper.distanceToGo() == 0) {
delay(500);
long target = stepper.currentPosition() == 0 ? STEPS_PER_TURN : 0;
Serial.println(target ? "Turning forward" : "Turning back");
stepper.moveTo(target);
}
stepper.run();
}