Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidelines for AI coding assistants working with the StepperD

## Project Overview

**StepperDriver** is an Arduino library for controlling stepper motors via driver boards that use STEP/DIR pins (indexer mode). It supports multiple driver ICs including A4988, DRV8825, DRV8834, and DRV8880.
**StepperDriver** is an Arduino library for controlling stepper motors via driver boards that use STEP/DIR pins (indexer mode). It supports multiple driver ICs including A4988, DRV8825, DRV8834, DRV8880, TMC2100, and TB6600.

- **Language**: C++ (Arduino)
- **License**: MIT
Expand All @@ -22,6 +22,7 @@ StepperDriver/
│ ├── DRV8834.h/cpp # DRV8834-specific driver
│ ├── DRV8880.h/cpp # DRV8880-specific driver
│ ├── TMC2100.h/cpp # TMC2100-specific driver
│ ├── TB6600.h/cpp # TB6600-specific driver
│ ├── MultiDriver.h/cpp # Multi-motor coordination
│ └── SyncDriver.h/cpp # Synchronized multi-motor movement
├── examples/ # Arduino example sketches
Expand All @@ -43,11 +44,13 @@ StepperDriver/
BasicStepperDriver # Base class - generic 2-pin (DIR/STEP) control
├── A4988 # Adds microstepping control (MS1/MS2/MS3)
│ └── DRV8825 # Extends A4988 with M0/M1/M2 and 1:32 support
└── DRV8834 # Low-voltage variant, M0/M1 only
└── DRV8880 # Adds current/torque control
├── DRV8834 # Low-voltage variant, M0/M1 only
├── DRV8880 # Adds current/torque control
├── TMC2100 # SilentStepStick-specific driver
└── MultiDriver # Coordinates multiple motors
└── SyncDriver # Synchronized movement for multiple motors
└── TB6600 # Toshiba TB6600 (microstepping via DIP switches)

MultiDriver # Coordinates multiple motors (standalone, wraps drivers)
└── SyncDriver # Synchronized movement for multiple motors
```

## Coding Conventions
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Hardware currently supported:
- <a href="https://www.pololu.com/product/2131">DRV8825</a> up to 1:32
- <a href="https://www.pololu.com/product/2971">DRV8880</a> up to 1:16, with current/torque control
- <a href="https://www.trinamic.com/products/integrated-circuits/details/tmc2100/">TMC2100</a> up to 1:16 native (1:256 interpolated)
- Toshiba TB6600 up to 1:16, microstepping set via DIP switches
- any other 2-pin stepper via DIR and STEP pins, microstepping up to 1:128 externally set

Microstepping
Expand Down
63 changes: 63 additions & 0 deletions examples/TB6600/TB6600.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* TB6600 Stepper Driver demo
*
* TB6600 modules use opto-isolated PUL(STEP)/DIR/ENA inputs and set
* microstepping via on-board DIP switches (no microstep control pins).
* Set MICROSTEPS below to match the DIP switch selection.
*
* NOTE: On common TB6600 boards ENA is active LOW. If you wire ENABLE,
* uncomment stepper.setEnableActiveState(LOW) in setup().
*
* Copyright (C)2026 Laurentiu Badea
*
* This file may be redistributed under the terms of the MIT license.
* A copy of this license has been included with this distribution in the file LICENSE.
*/
#include <Arduino.h>
#include "TB6600.h"

// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define MOTOR_STEPS 200
#define RPM 120

// Microstepping is set on the board's DIP switches - match it here.
// 1=full step, 2=half step etc.
#define MICROSTEPS 1

#define DIR 8
#define STEP 9
// Uncomment to use enable/disable functionality on the ENA pin
//#define ENABLE 13

// Basic 2-wire config: DIR and STEP(PUL), microstepping via DIP switches
TB6600 stepper(MOTOR_STEPS, DIR, STEP);

// Uncomment to also wire ENABLE (ENA)
//TB6600 stepper(MOTOR_STEPS, DIR, STEP, ENABLE);

void setup() {
stepper.begin(RPM, MICROSTEPS);
// Most TB6600 boards use active-LOW ENA - uncomment if using ENABLE:
// stepper.setEnableActiveState(LOW);
}

void loop() {

// energize coils - the motor will hold position
// stepper.enable();

/*
* Moving motor one full revolution using the degree notation
*/
stepper.rotate(360);

/*
* Moving motor to original position using steps
*/
stepper.move(-MOTOR_STEPS*MICROSTEPS);

// pause and allow the motor to be moved by hand
// stepper.disable();

delay(5000);
}
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ A4988 KEYWORD1
MultiDriver KEYWORD1
SyncDriver KEYWORD1
TMC2100 KEYWORD1
TB6600 KEYWORD1

setMicrostep KEYWORD2
setSpeedProfile KEYWORD2
Expand Down
5 changes: 3 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "StepperDriver",
"version": "1.5.1",
"description": "Control steppers via a driver board providing STEP+DIR like the ones from Pololu. Microstepping is supported. Acceleration is supported. Supported drivers are A4988, DRV8824, DRV8825, DRV8834, DRV8880, TMC2100.",
"description": "Control steppers via a driver board providing STEP+DIR like the ones from Pololu. Microstepping is supported. Acceleration is supported. Supported drivers are A4988, DRV8824, DRV8825, DRV8834, DRV8880, TMC2100, TB6600.",
"repository": {
"type": "git",
"url": "https://github.com/laurb9/StepperDriver"
Expand All @@ -13,7 +13,8 @@
"DRV8824",
"DRV8825",
"DRV8880",
"TMC2100"
"TMC2100",
"TB6600"
],
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version=1.5.1
author=Laurentiu Badea
maintainer=Laurentiu Badea
sentence=A4988, DRV8825, TMC2100 and generic two-pin stepper motor driver library.
paragraph=Control steppers via a driver board providing STEP+DIR like the ones from Pololu. Microstepping is supported. Acceleration is supported. Supported drivers are A4988, DRV8824, DRV8825, DRV8834, DRV8880, TMC2100.
paragraph=Control steppers via a driver board providing STEP+DIR like the ones from Pololu. Microstepping is supported. Acceleration is supported. Supported drivers are A4988, DRV8824, DRV8825, DRV8834, DRV8880, TMC2100, TB6600.
category=Device Control
url=https://github.com/laurb9/StepperDriver
architectures=*
26 changes: 26 additions & 0 deletions src/TB6600.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* TB6600 - Toshiba Stepper Motor Driver
* Indexer mode only.
*
* Copyright (C)2026 Laurentiu Badea
*
* This file may be redistributed under the terms of the MIT license.
* A copy of this license has been included with this distribution in the file LICENSE.
*/
#include "TB6600.h"

/*
* Basic connection: only DIR, STEP (PUL) are connected.
* Microstepping is configured via the board's DIP switches.
*/
TB6600::TB6600(short steps, short dir_pin, short step_pin)
:BasicStepperDriver(steps, dir_pin, step_pin)
{ initTiming(); }

TB6600::TB6600(short steps, short dir_pin, short step_pin, short enable_pin)
:BasicStepperDriver(steps, dir_pin, step_pin, enable_pin)
{ initTiming(); }

short TB6600::getMaxMicrostep(){
return TB6600::MAX_MICROSTEP;
}
50 changes: 50 additions & 0 deletions src/TB6600.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* TB6600 - Toshiba Stepper Motor Driver
* Indexer mode only.
*
* TB6600 modules (PUL/DIR/ENA) set microstepping via on-board DIP switches,
* so there are no microstep control pins. Set the same MICROSTEPS value in
* software (begin()/setMicrostep()) as configured on the DIP switches so the
* timing calculations are correct.
*
* NOTE: Common TB6600 boards use opto-isolated PUL/DIR/ENA inputs where ENA is
* typically active LOW. If you wire ENABLE, you may need setEnableActiveState(LOW).
*
* Copyright (C)2026 Laurentiu Badea
*
* This file may be redistributed under the terms of the MIT license.
* A copy of this license has been included with this distribution in the file LICENSE.
*/
#ifndef TB6600_H
#define TB6600_H
#include <Arduino.h>
#include "BasicStepperDriver.h"

class TB6600 : public BasicStepperDriver {
protected:
// Set timing requirements from TB6600 datasheet
void initTiming(){
// min clock (PUL) HIGH pulse duration (2.2us -> 3)
step_high_min = 3;
// min clock (PUL) LOW pulse duration (2.2us -> 3)
step_low_min = 3;
// wakeup time after ENA released (10us)
wakeup_time = 10;
}

// Get max microsteps supported by the device (TB6600HG up to 1:16)
short getMaxMicrostep() override;

private:
// microstep range (1, 2, 4, 8, 16), configured via DIP switches
static const short MAX_MICROSTEP = 16;

public:
/*
* Basic connection: only DIR, STEP (PUL) are connected.
* Microstepping is configured via the board's DIP switches.
*/
TB6600(short steps, short dir_pin, short step_pin);
TB6600(short steps, short dir_pin, short step_pin, short enable_pin);
};
#endif // TB6600_H
Loading