Skip to content

Commit 8ba98c2

Browse files
laurb9claude
andcommitted
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 <noreply@anthropic.com>
1 parent ef1b0e3 commit 8ba98c2

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/TB6600.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@
99
*/
1010
#include "TB6600.h"
1111

12-
// TB6600 datasheet timing: min PUL clock HIGH/LOW 2.2us -> 3, wakeup 10us
13-
#define TB6600_SET_TIMING() do { step_high_min = 3; step_low_min = 3; wakeup_time = 10; } while (0)
14-
1512
/*
1613
* Basic connection: only DIR, STEP (PUL) are connected.
1714
* Microstepping is configured via the board's DIP switches.
1815
*/
1916
TB6600::TB6600(short steps, short dir_pin, short step_pin)
2017
:BasicStepperDriver(steps, dir_pin, step_pin)
21-
{ TB6600_SET_TIMING(); }
18+
{ initTiming(); }
2219

2320
TB6600::TB6600(short steps, short dir_pin, short step_pin, short enable_pin)
2421
:BasicStepperDriver(steps, dir_pin, step_pin, enable_pin)
25-
{ TB6600_SET_TIMING(); }
22+
{ initTiming(); }
2623

2724
short TB6600::getMaxMicrostep(){
2825
return TB6600::MAX_MICROSTEP;

src/TB6600.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@
2222

2323
class TB6600 : public BasicStepperDriver {
2424
protected:
25-
// Timing (set in constructors): min clock (PUL) HIGH/LOW 2.2us -> 3,
26-
// wakeup time after ENA released 10us.
25+
// Set timing requirements from TB6600 datasheet
26+
void initTiming(){
27+
// min clock (PUL) HIGH pulse duration (2.2us -> 3)
28+
step_high_min = 3;
29+
// min clock (PUL) LOW pulse duration (2.2us -> 3)
30+
step_low_min = 3;
31+
// wakeup time after ENA released (10us)
32+
wakeup_time = 10;
33+
}
2734

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

0 commit comments

Comments
 (0)