Overview
The robot uses four DC geared motors with quadrature encoders. The recommended motor is the JGA25-370 12V 333RPM with built-in Hall-effect encoder, providing good balance of speed, torque, and position feedback.Key Features: 12V operation, 333 RPM no-load speed, 1:19 gearbox ratio, 209 PPR encoder output, affordable ($15-20 each).
Motor Specifications
JGA25-370 (Recommended)
Base motor: RS-370 series brushed DC motor| Parameter | Value | Notes |
|---|---|---|
| Rated Voltage | 12V DC | Matches 3S LiPo (11.1V nominal) |
| Operating Voltage | 6-12V | Lower voltage = lower speed/torque |
| No-Load Speed | 333 RPM | At gearbox output shaft |
| No-Load Current | 80-150 mA | Depends on voltage |
| Rated Speed | 250-280 RPM | Under nominal load |
| Rated Torque | 0.6-0.8 Nm | At rated speed |
| Stall Torque | 0.8-1.0 Nm | Maximum torque (don’t sustain!) |
| Stall Current | 2-3A | Dangerous if sustained >1 second |
| Gearbox Ratio | 1:19 | 19:1 reduction |
| Motor Diameter | 25mm | JGA25 series |
| Motor Length | 37mm | Body only |
| Total Length | 70mm | Including gearbox |
| Shaft Diameter | 4mm or 6mm | Match to wheel bore |
| Shaft Length | 10-15mm | Protruding from gearbox |
| Weight | ~100g | Per motor |
Encoder Specifications
Hall-effect quadrature encoder (built-in):| Parameter | Value | Notes |
|---|---|---|
| Type | Hall-effect | Non-contact, reliable |
| Channels | 2 (A, B) | Quadrature encoding |
| PPR (motor shaft) | 11 pulses per revolution | At motor shaft (before gearbox) |
| PPR (output shaft) | 209 pulses per revolution | 11 × 19 (gearbox ratio) |
| Voltage | 5V | Requires 5V supply |
| Current | ~10 mA | Low power |
| Output | Digital (HIGH/LOW) | 0V/5V logic levels |
| Cable | 6-wire | 2× motor power, 3× encoder (VCC, A, B, GND) |
Motor Performance Curves
Speed vs. Torque
At 12V:- Speed drops linearly with load
- At stall (0 RPM): Maximum torque but dangerous current
- Operating range: 0.2-0.6 Nm for efficiency
Efficiency vs. Load
| Torque (Nm) | Efficiency | Notes |
|---|---|---|
| 0.1 | 40% | Light load, wasted energy |
| 0.3 | 70% | Good efficiency |
| 0.5 | 75% | Peak efficiency |
| 0.7 | 70% | Starting to drop |
| 1.0 | 0% | Stall (no output, all heat) |
Wiring Diagram
Motor + Encoder Connections
6-wire cable:| Wire Color | Function | Connection |
|---|---|---|
| Red | Motor + | To H-bridge OUT1 |
| Black | Motor - | To H-bridge OUT2 |
| Yellow | Encoder VCC | To 5V (ESP32 VIN or buck converter) |
| Green | Encoder A | To ESP32 GPIO (e.g., 34) |
| Blue | Encoder B | To ESP32 GPIO (e.g., 35) |
| White | Encoder GND | To GND |
Complete Motor Wiring (4 motors)
H-Bridge Driver (IBT-2 / BTS7960)
One IBT-2 module controls 2 motors (need 2 total for 4 motors)IBT-2 Specifications
| Parameter | Value | Notes |
|---|---|---|
| Chip | BTS7960 | Infineon high-power H-bridge |
| Max Current | 43A | Per channel |
| Continuous Current | 30A | With heatsinking |
| Operating Voltage | 5.5-27V | Matches 3S LiPo perfectly |
| Logic Voltage | 3.3V or 5V compatible | ESP32 3.3V works |
| PWM Frequency | Up to 25 kHz | Recommended: 20 kHz |
| Efficiency | >95% | Very low losses |
| Size | 50mm × 30mm | Compact |
| Price | $5-10 | Per module |
IBT-2 Pinout
Per motor (2 motors per IBT-2):| Pin | Function | Connection |
|---|---|---|
| VCC | Logic power | 5V or 3.3V |
| GND | Ground | Common GND |
| RPWM | Forward PWM | ESP32 GPIO (e.g., 4) |
| LPWM | Reverse PWM | ESP32 GPIO (e.g., 23) or GND |
| R_EN | Right enable | 5V or 3.3V (always on) |
| L_EN | Left enable | 5V or 3.3V (always on) |
| VMS | Motor power | 12V (from battery) |
| GND | Motor power GND | Battery GND |
| OUT1/OUT2 | Motor outputs | To motor red/black |
Motor Calculations
Wheel Speed to Motor RPM
Given:- Wheel diameter: 60mm = 0.06m
- Desired robot speed: 0.5 m/s
Torque Requirements
Estimate required torque per motor: Given:- Robot mass: 3 kg
- Wheel radius: 0.03 m
- Desired acceleration: 1 m/s²
Current Draw
Per motor:| Condition | Current (A) | Total (4 motors) | Notes |
|---|---|---|---|
| No-load | 0.15 | 0.6 A | Idling |
| Light load | 0.5 | 2.0 A | Slow motion |
| Normal operation | 1.0 | 4.0 A | Typical navigation |
| Heavy acceleration | 1.5 | 6.0 A | Max acceleration |
| Stall (DANGER) | 2.5-3.0 | 10-12 A | Emergency stop required |
Encoder Decoding
Quadrature Encoding Explained
Two channels (A and B) 90° out of phase:- 1× resolution: Count rising edges of A only = 11 PPR × 19 = 209 counts/rev
- 2× resolution: Count both edges of A = 418 counts/rev
- 4× resolution: Count both edges of A and B = 836 counts/rev (full quadrature)
ESP32 Encoder Interrupt Code
Example implementation:Motor Calibration
Direction Calibration
Verify all motors rotate correct direction:- Positive PWM: Forward (robot moves forward)
- Negative PWM: Backward
Encoder Direction Calibration
Verify encoder counts increase when motor goes forward:Velocity Measurement
Calculate motor velocity (rad/s):Troubleshooting
Motor doesn't spin
Motor doesn't spin
Check:
- Motor power connected (12V to H-bridge)
- PWM signal generated (oscilloscope or LED test)
- H-bridge enable pins HIGH
- Motor not stalled (remove load, test)
- Connect motor directly to 12V battery (bypass H-bridge)
- Should spin → H-bridge issue
- Doesn’t spin → motor faulty
Motor spins wrong direction
Motor spins wrong direction
Fix:
- Hardware: Swap motor red/black wires
- Software: Invert PWM sign:
Encoder not counting
Encoder not counting
Debug:Common issues:
- Encoder not powered (check 5V supply)
- Interrupt not attached
- Wrong pins (use interrupt-capable GPIOs)
- Encoder damaged
Encoder counts erratically
Encoder counts erratically
Causes:
- Electrical noise (PWM interference)
- Loose connections
- Motor generates EMI
- Add 100nF capacitor between encoder A/B and GND (close to ESP32)
- Twist encoder wires together (reduces EMI pickup)
- Route encoder wires away from motor power wires
- Add RC filter: 1kΩ resistor + 100nF capacitor on each encoder line
Motor overheating
Motor overheating
Causes:
- Sustained stall current
- Motor overloaded (too much weight)
- PWM frequency too low (<1 kHz)
- Reduce load (lighter robot)
- Increase PWM frequency (20 kHz)
- Add current limiting in software
- Check motor not mechanically jammed
H-bridge overheating
H-bridge overheating
Solutions:
- Add heatsink to BTS7960 chip
- Improve airflow
- Reduce motor current (lighter load, lower acceleration)
- Check for short circuit
Alternative Motors
Other Options
| Motor Model | RPM | Torque | PPR | Price | Notes |
|---|---|---|---|---|---|
| JGA25-370 (333 RPM) | 333 | 0.8 Nm | 209 | $15-20 | Recommended |
| JGA25-370 (200 RPM) | 200 | 1.2 Nm | 209 | $18-22 | Slower, more torque |
| JGA25-370 (500 RPM) | 500 | 0.5 Nm | 209 | $15-20 | Faster, less torque |
| 37mm Gearmotor | 200 | 1.5 Nm | 200 | $20-25 | Larger, heavier |
| N20 Micro Motor | 300 | 0.15 Nm | 100 | $8-12 | Weaker (for small robots) |
- RPM: Match to desired robot speed (0.4-0.6 m/s → 250-350 RPM with 60mm wheels)
- Torque: At least 2× calculated requirement for safety margin
- Encoder: Higher PPR = better position accuracy (>100 PPR recommended)
- Voltage: Match to battery (12V for 3S LiPo)
Next Steps
Motor Driver Setup
IBT-2 H-bridge wiring and control
Motor Control Code
Complete motor control implementation
LiDAR Specifications
RPLIDAR A1M8 details
Power System
Complete power system design