From cd1a76acdc627b083997e96fdf927dda64e1deca Mon Sep 17 00:00:00 2001 From: "claude-opus-4-8 (Claude Code)" Date: Mon, 6 Jul 2026 21:30:44 -0700 Subject: [PATCH 1/2] Add Toshiba TB6600 stepper driver support (fixes #105) TB6600 modules expose opto-isolated PUL(STEP)/DIR/ENA inputs and set microstepping via on-board DIP switches, so there are no microstep control pins. The new TB6600 class inherits BasicStepperDriver directly and only sets its datasheet timing (min PUL clock HIGH/LOW 2.2us -> 3us, wakeup 10us) in its constructors, and overrides getMaxMicrostep() to 16 (TB6600HG supports 1:16). Header documents that common boards use active-LOW ENA, so users wiring ENABLE may need setEnableActiveState(LOW). Also adds an example sketch, keywords.txt entry, and updates the AGENTS.md class hierarchy / repository structure, README supported-hardware list, and library.properties / library.json metadata. Verified: TB6600 example builds clean for arduino:avr:uno with --warnings all, library links and sim-test verdicts match baseline. Agent: claude-opus-4-8 (Claude Code 2.1.153), amended and verified by claude-fable-5; max context and thinking level not exposed to the agent Co-Authored-By: Claude Opus 4.8 --- AGENTS.md | 13 +++++--- README.md | 1 + examples/TB6600/TB6600.ino | 63 ++++++++++++++++++++++++++++++++++++++ keywords.txt | 1 + library.json | 5 +-- library.properties | 2 +- src/TB6600.cpp | 29 ++++++++++++++++++ src/TB6600.h | 43 ++++++++++++++++++++++++++ 8 files changed, 149 insertions(+), 8 deletions(-) create mode 100644 examples/TB6600/TB6600.ino create mode 100644 src/TB6600.cpp create mode 100644 src/TB6600.h diff --git a/AGENTS.md b/AGENTS.md index 9679ec6..38c08a7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 @@ -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 @@ -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 diff --git a/README.md b/README.md index 383e738..0e6fe35 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Hardware currently supported: - DRV8825 up to 1:32 - DRV8880 up to 1:16, with current/torque control - TMC2100 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 diff --git a/examples/TB6600/TB6600.ino b/examples/TB6600/TB6600.ino new file mode 100644 index 0000000..5c851bc --- /dev/null +++ b/examples/TB6600/TB6600.ino @@ -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 +#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); +} diff --git a/keywords.txt b/keywords.txt index f5be7f9..524a4e4 100644 --- a/keywords.txt +++ b/keywords.txt @@ -9,6 +9,7 @@ A4988 KEYWORD1 MultiDriver KEYWORD1 SyncDriver KEYWORD1 TMC2100 KEYWORD1 +TB6600 KEYWORD1 setMicrostep KEYWORD2 setSpeedProfile KEYWORD2 diff --git a/library.json b/library.json index 13f9ef0..482e7b7 100644 --- a/library.json +++ b/library.json @@ -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" @@ -13,7 +13,8 @@ "DRV8824", "DRV8825", "DRV8880", - "TMC2100" + "TMC2100", + "TB6600" ], "authors": [ { diff --git a/library.properties b/library.properties index e6ae610..a7fd8c5 100644 --- a/library.properties +++ b/library.properties @@ -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=* diff --git a/src/TB6600.cpp b/src/TB6600.cpp new file mode 100644 index 0000000..169336f --- /dev/null +++ b/src/TB6600.cpp @@ -0,0 +1,29 @@ +/* + * 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" + +// TB6600 datasheet timing: min PUL clock HIGH/LOW 2.2us -> 3, wakeup 10us +#define TB6600_SET_TIMING() do { step_high_min = 3; step_low_min = 3; wakeup_time = 10; } while (0) + +/* + * 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) +{ TB6600_SET_TIMING(); } + +TB6600::TB6600(short steps, short dir_pin, short step_pin, short enable_pin) +:BasicStepperDriver(steps, dir_pin, step_pin, enable_pin) +{ TB6600_SET_TIMING(); } + +short TB6600::getMaxMicrostep(){ + return TB6600::MAX_MICROSTEP; +} diff --git a/src/TB6600.h b/src/TB6600.h new file mode 100644 index 0000000..aeece8e --- /dev/null +++ b/src/TB6600.h @@ -0,0 +1,43 @@ +/* + * 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 +#include "BasicStepperDriver.h" + +class TB6600 : public BasicStepperDriver { +protected: + // Timing (set in constructors): min clock (PUL) HIGH/LOW 2.2us -> 3, + // wakeup time after ENA released 10us. + + // 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 From 8ba98c22d0d53a7b5ede0f1be05cb51dceb82961 Mon Sep 17 00:00:00 2001 From: "claude-fable-5 (Claude Code)" Date: Fri, 17 Jul 2026 18:50:47 -0700 Subject: [PATCH 2/2] Convert TB6600 timing setup to initTiming() pattern from #140 Replace the TB6600_SET_TIMING() macro in the .cpp with a protected inline initTiming() method in the header, matching the pattern the other drivers adopted in PR #140. Agent: claude-fable-5 (Claude Code 2.1.212) Co-Authored-By: Claude Fable 5 --- src/TB6600.cpp | 7 ++----- src/TB6600.h | 11 +++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/TB6600.cpp b/src/TB6600.cpp index 169336f..b213836 100644 --- a/src/TB6600.cpp +++ b/src/TB6600.cpp @@ -9,20 +9,17 @@ */ #include "TB6600.h" -// TB6600 datasheet timing: min PUL clock HIGH/LOW 2.2us -> 3, wakeup 10us -#define TB6600_SET_TIMING() do { step_high_min = 3; step_low_min = 3; wakeup_time = 10; } while (0) - /* * 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) -{ TB6600_SET_TIMING(); } +{ initTiming(); } TB6600::TB6600(short steps, short dir_pin, short step_pin, short enable_pin) :BasicStepperDriver(steps, dir_pin, step_pin, enable_pin) -{ TB6600_SET_TIMING(); } +{ initTiming(); } short TB6600::getMaxMicrostep(){ return TB6600::MAX_MICROSTEP; diff --git a/src/TB6600.h b/src/TB6600.h index aeece8e..3f78bbf 100644 --- a/src/TB6600.h +++ b/src/TB6600.h @@ -22,8 +22,15 @@ class TB6600 : public BasicStepperDriver { protected: - // Timing (set in constructors): min clock (PUL) HIGH/LOW 2.2us -> 3, - // wakeup time after ENA released 10us. + // 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;