Hardware Setup Guide - Fatigue Test ESP-NOW Unit
Overview
This guide covers the hardware setup for the Fatigue Test ESP-NOW Unit, including motor connections, encoder setup, and ESP32 configuration.
Hardware Requirements
Required Components
- ESP32 Development Board (ESP32-C6 recommended)
- TMC5160 Stepper Motor Driver (SPI interface)
- Stepper Motor (compatible with TMC5160)
- ABN Encoder (optional, for encoder-based bounds detection)
- Reference Switches (optional, for homing)
- Power Supply (appropriate for motor and ESP32)
Pin Configuration
SPI Interface (TMC5160)
The TMC5160 communicates via SPI. Default pin configuration (from test config):
- MOSI: GPIO 23
- MISO: GPIO 19
- SCK: GPIO 18
- CS: GPIO 5
Note: Pin configuration is managed by tmc51x0_test_config::GetDefaultPinConfig(). Modify test config if needed.
UART Interface (Debug/Control)
- TX: GPIO 1 (UART0)
- RX: GPIO 3 (UART0)
- Baud Rate: 115200
ESP-NOW
- WiFi Channel: 1 (configured in code)
- MAC Address: Auto-detected, can be read from serial output
Motor Configuration
Test Rig Selection
The system uses a test rig configuration system. Edit main.cpp:
1
2
static constexpr tmc51x0_test_config::TestRigType SELECTED_TEST_RIG =
tmc51x0_test_config::TestRigType::TEST_RIG_FATIGUE;
Motor Parameters
Motor parameters are configured via tmc51x0_test_config::ConfigureDriverFromTestRig(). Key parameters:
- Sense Resistor: Typically 50mΩ
- Supply Voltage: Motor supply voltage (e.g., 24V)
- Rated Current: Motor rated current
- Microsteps: Typically 256 microsteps
Motor Wiring
- Power Supply:
- Connect motor power supply to TMC5160 VM/GND
- Ensure adequate current capacity
- Use appropriate voltage for your motor
- Motor Phases:
- Connect motor phases to TMC5160 motor outputs
- Verify phase wiring (swap if motor runs backwards)
- TMC5160 Configuration:
- SPI interface to ESP32
- Enable pin (if used)
- DIAG pin (for diagnostics)
Encoder Setup (Optional)
ABN Encoder Wiring
If using encoder-based bounds detection:
- A Phase: Connect to encoder A input
- B Phase: Connect to encoder B input
- Index: Optional, for homing
Note: Encoder configuration is managed by test rig config:
GetTestRigEncoderConfig<SELECTED_TEST_RIG>()GetTestRigEncoderPulsesPerRev<SELECTED_TEST_RIG>()GetTestRigEncoderInvertDirection<SELECTED_TEST_RIG>()
Encoder Requirements
- Resolution: Sufficient for position monitoring
- Interface: Quadrature encoder (A/B phases)
- Mounting: Properly aligned with motor shaft
Reference Switches (Optional)
For homing and position reference:
- Min Switch: Physical limit switch at minimum position
- Max Switch: Physical limit switch at maximum position
Note: Current implementation uses bounds finding (StallGuard or encoder) rather than limit switches.
Power Supply
Requirements
- Motor Power:
- Voltage: As specified for your motor (typically 12V-48V)
- Current: Sufficient for motor operation (check motor specs)
- Regulation: Stable voltage under load
- ESP32 Power:
- Voltage: 3.3V or 5V (depending on board)
- Current: ~200-500mA typical
- Can share supply with TMC5160 logic supply
Power Sequencing
- Power on motor supply first
- Power on ESP32
- Allow initialization time (~1-2 seconds)
Mechanical Setup
Motor Mounting
- Secure motor to test fixture
- Ensure proper alignment
- Check for mechanical binding
Load Configuration
- Attach test load to motor shaft
- Verify load is within motor specifications
- Check for excessive friction or binding
Bounds Detection
- StallGuard Method: No additional hardware needed
- Encoder Method: Requires encoder properly mounted
Initial Testing
1. Serial Connection
Connect to ESP32 via USB/UART:
1
2
3
4
5
6
# Find serial port
ls /dev/ttyUSB* # Linux
ls /dev/tty.* # macOS
# Connect with serial monitor
screen /dev/ttyUSB0 115200
2. Verify Initialization
Look for startup messages:
1
2
3
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Fatigue Test Unit with ESP-NOW Communication ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
3. Test UART Commands
Try basic commands:
1
2
-s # Show status
-h # Show help
4. Test ESP-NOW Communication
- Power on test unit
- Note MAC address from serial output
- Configure MAC in remote controller
- Power on remote controller
- Verify communication
Troubleshooting
Motor Not Moving
- Check Power Supply:
- Verify motor power is connected
- Check voltage levels
- Verify current capacity
- Check SPI Communication:
- Verify SPI wiring
- Check CS pin connection
- Verify SPI clock speed
- Check Motor Wiring:
- Verify phase connections
- Check for shorts
- Try swapping phases
- Check TMC5160 Configuration:
- Verify driver is enabled
- Check current settings
- Verify microstep configuration
ESP-NOW Not Working
- Check MAC Address:
- Verify MAC is correct in remote controller
- Check both devices are on same WiFi channel
- Check Range:
- Ensure devices are within range (~100-200m)
- Check for interference
- Check Serial Output:
- Look for ESP-NOW initialization messages
- Check for error messages
Bounds Finding Fails
- StallGuard Method:
- Check SGT threshold setting
- Verify motor can actually stall
- Check for false stall detection
- Encoder Method:
- Verify encoder wiring
- Check encoder pulses per revolution setting
- Verify encoder is properly mounted
Serial Communication Issues
- Check Baud Rate: Must be 115200
- Check Wiring: Verify TX/RX connections
- Check USB Driver: Ensure drivers are installed
Safety Considerations
- Motor Power: Use appropriate safety measures for high-voltage motor supplies
- Mechanical Safety: Ensure proper mechanical stops to prevent over-travel
- Emergency Stop: Consider adding emergency stop functionality
- Current Limits: Set appropriate current limits in TMC5160 configuration
Calibration
StallGuard Calibration
If using StallGuard method:
- Run stallguard tuning tool (separate example)
- Determine optimal SGT threshold
- Configure in test rig settings
Encoder Calibration
If using encoder method:
- Verify encoder pulses per revolution
- Check encoder direction (invert if needed)
- Verify encoder mounting alignment
Maintenance
- Regular Checks:
- Motor connections
- Encoder alignment (if used)
- Power supply stability
- Software Updates:
- Keep firmware updated
- Check for configuration changes
- Mechanical Maintenance:
- Lubricate moving parts
- Check for wear
- Verify alignment