diff --git a/AGENTS.md b/AGENTS.md index 9a5c7bc..459aba1 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..b213836 --- /dev/null +++ b/src/TB6600.cpp @@ -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; +} diff --git a/src/TB6600.h b/src/TB6600.h new file mode 100644 index 0000000..3f78bbf --- /dev/null +++ b/src/TB6600.h @@ -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 +#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