·
“The Case of the Intermittent Miss-Step” of the JGB37-520 Encoder Motor
—A 72-hour root-cause drill-down
Author: University RoboMaster ECU Team
Date: July 14, 2025
- Symptom
20 Dec 2024, during tuning of our 2025 RoboMaster infantry robot:
• At 1.5 m/s straight-line sprint the robot drifted 3–5 cm right every 3–5 m.
• When drifting, the right JGB37-520 (12 V, 30:1, AB encoder) speed dropped 15 %; left wheel normal.
• Restarting the STM32F407 master masked the issue for ~30 s, then it returned.
• Motor temperature 35 °C, supply 12.1 V steady, no over-current or under-voltage alarms. - Initial Checks
| Step | Action | Result | Conclusion |
|---|---|---|---|
| ① | Swap left/right motors | Drift direction follows motor | Motor-specific issue |
| ② | Scope A/B waveforms | Clean 0–3.3 V square waves | Encoder hardware OK |
| ③ | Run open-loop (encoder unplugged) | No drift | Issue in closed-loop path |
| ④ | Logic-analyze PID output | PID saturates at 100 % instantly | False “target not reached” | - Root-Cause Analysis
- Ground-bounce in shared wiring
Motor power and encoder GND share a 30 cm ribbon cable (motor AWG20, encoder AWG28). At >1 A current, a 60 mV ground spike appears. - MCU filter too narrow
STM32 TIM input filter set to 0.1 µs → spike edges counted as valid → 2–3 extra pulses → PID reduces PWM → real stall. - Trigger condition
Occurs only when PWM >80 % and motor current >1.2 A; low-speed tests never reproduced it. - Fixes
- Rewire
• Separate 24 AWG twisted pair for encoder 5 V & GND, physically routed away from power.
• 100 µF + 0.1 µF decoupling at motor terminal to kill ground bounce. - MCU parameters
• TIM filter widened to 1 µs.
• Enable 3-clock digital deglitch. - Software safeguard
• Every 1 ms verify “pulse increment × gear ratio” speed; deviation >5 % → flag “encoder fault” → revert to open-loop for 50 ms then resync. - Verification
• 100 m round-trip at 2 m/s under full load: zero drift.
• 48-hour burn-in (random 80–100 % PWM): no miscounts.
• Seven competition matches, 3.6 km total: no sprint drift. - Lessons Learned
- “Encoder looks good” ≠ “signal chain is good”; ground bounce is the silent killer.
- At PWM >80 % the JGB37-520 can draw 1.5 A; treat its ground wiring like a power line.
- Always add software escape: closed-loop systems need “sensor lost → open-loop safe” logic.
The ECU team turned this drill-down into “JGB-Series Wiring Checklist V2.1”, now mandatory for every future bot.