Project note

Automatic Litter Box – Motor Torque Tuning

11 tags
Tags

This post is more of a corrected and working wiring + torque tuning setup for:

  • ESP8266 / ESP32 (3.3V logic)
  • TB6600 stepper driver (optocoupler, common cathode mode)
  • StepperOnline NEMA 23
  • 12–24V motor supply
  • ESPHome running in Docker

This configuration is verified and matches the real-world behavior observed during testing.


✅ 250-Character Description

"Torque tuning session using ESP (3.3V logic) and TB6600 in common-cathode mode. Corrected wiring, optimized motor current and microstepping, and tuned acceleration for maximum stable torque on a NEMA 23 stepper without missed steps."


📊 CORRECT Wiring Diagram (Verified)

This is the proper TB6600 wiring in common cathode mode (optocoupler input mode).
This works correctly with 3.3V logic from ESP8266/ESP32.


🎯 Control Signal Wiring

TB6600Connects ToExplanation
PUL+3.3V (ESP)Constant HIGH
PUL−D5 (GPIO14)STEP signal (pulsed LOW)
DIR+3.3V (ESP)Constant HIGH
DIR−D6 (GPIO12)Direction control
ENA+3.3V (ESP)Driver always enabled
ENA−GND (ESP)Enable active

✔ This is common cathode mode
✔ ESP pulses on the negative side
✔ Fully compatible with 3.3V logic
✔ Standard configuration for TB6600


🔌 Motor Coil Wiring (StepperOnline NEMA 23)

TB6600Motor WireCoil
A+BlackCoil A
A−GreenCoil A
B+RedCoil B
B−BlueCoil B

✔ This is correct order for StepperOnline NEMA 23.


🔋 Motor Power Input

TB6600Connects To
VCC12–24V +
GND12–24V −

✔ 24V gives better torque at speed
✔ 12V works but reduces high-speed torque


🧠 Why This Works (Electrical Explanation)

The TB6600 input stage uses optocouplers.

In common cathode mode:

  • The + side is tied to 3.3V
  • The ESP sinks current on the − side
  • This guarantees proper current flow through the optocoupler LED

This avoids:

  • Weak triggering
  • Random missed steps
  • Direction glitches
  • Inconsistent enable behavior

It matches exactly the symptoms observed before correcting the wiring.


⚙️ Torque Optimization Steps

1️⃣ Set Driver Current Properly

Torque ∝ Current

If your NEMA 23 is rated for 2.8A:

  • Set TB6600 slightly below rated current
  • Monitor temperature
  • Never exceed rating

Heat ∝ I²R

Doubling current quadruples heat.


2️⃣ Microstepping vs Torque

Lower microstepping = stronger incremental torque

SettingSmoothnessIncremental Torque
Full StepRoughMaximum
1/2ModerateHigh
1/8SmoothMedium
1/16Very SmoothLower per microstep

Best balance under load: ✔ 1/4 or 1/8 microstep


3️⃣ Acceleration Tuning (Software)

Back EMF increases with speed:

Back EMF ∝ Speed

Higher speed = lower effective torque.

Tune in ESPHome:

  • Increase acceleration gradually
  • Increase max speed until stall
  • Back off 15–20% for safety margin

🎥 Live Torque Test


✅ Final Summary (The Setup That Actually Works)

ESP 3.3V → PUL+, DIR+, ENA+
ESP D5 → PUL−
ESP D6 → DIR−
ESP GND → ENA− + TB6600 GND
Motor → A/B +/- as above
12–24V → TB6600 VCC/GND

✔ Best practice
✔ Correct for TB6600 optocoupler input
✔ Works with ESP 3.3V
✔ Eliminates skipped-step behavior


The motor now runs with stable torque, correct direction switching, and clean acceleration without missed steps.