Integration Complete! ✅¶
Date: November 2025
Test Environment: single_device_battery_bemf_test
✅ Files Created/Modified¶
Test Implementation¶
- ✅
test/single_device_battery_bemf_test.c(1,067 lines) - Integrated motor control, battery monitoring, and back-EMF sensing
- 4 research modes (1Hz/0.5Hz @ 50%/25% duty)
- Dual back-EMF readings (immediate + 10ms settled)
- Battery LVO protection and 10-second polling
- Full 20-minute session with auto-sleep
Documentation¶
- ✅
test/SINGLE_DEVICE_BATTERY_BEMF_TEST_QUICK_GUIDE.md - Quick reference guide with all key information
- Expected serial outputs
- Circuit requirements
- Troubleshooting tips
Build Configuration¶
- ✅
platformio.ini- Added new test environment - ✅
scripts/select_source.py- Added source file mapping - ✅
BUILD_COMMANDS.md- Updated with new test commands
🚀 Ready to Use!¶
Build and Run¶
Quick Alias (Optional)¶
Add to your shell profile:
# Linux/Mac
alias pio-bemf='pio run -e single_device_battery_bemf_test -t upload && pio device monitor'
# Then just run:
pio-bemf
📊 What You'll See¶
Back-EMF Readings (First 10 Seconds Per Mode)¶
FWD: Immediate: GPIO0=800mV → BEMF=-1700mV | Settled: GPIO0=1200mV → BEMF=-900mV
REV: Immediate: GPIO0=2700mV → BEMF=+2100mV | Settled: GPIO0=2300mV → BEMF=+1300mV
Key Points: - Immediate: Captures peak back-EMF before motor spin-down - Settled: Shows filtered/decayed value after 10ms - Forward: Negative BEMF (motor spinning one way) - Reverse: Positive BEMF (motor spinning opposite way)
Battery Monitoring (Every 10 Seconds)¶
Mode Changes (Button Press)¶
🎯 Test Objectives¶
This test will help you determine:
- Optimal Sampling Timing
- Is immediate or settled reading better for stall detection?
- How fast does the motor spin down during coast?
-
Is 10ms settling time appropriate?
-
Back-EMF Characteristics
- Normal operation magnitude range
- Forward vs reverse symmetry
-
Filter performance (PWM noise removal)
-
Battery Efficiency
- Voltage drop per mode
- 50% vs 25% duty cycle power consumption
-
Validate 10-second polling adequacy
-
Integrated System Performance
- Motor + battery + LED coordination
- Power efficiency with all subsystems active
- 20-minute session battery impact
🔧 Circuit Requirements¶
Back-EMF Summing Network (GPIO0)¶
CRITICAL: R_load must be NOT POPULATED! Note: Production BOM uses 22nF (prototypes may have 12nF or 15nF)Battery Voltage Divider (GPIO2)¶
GPIO21 enables measurement (HIGH = enabled)📝 Next Steps¶
- Build and flash the test
- Run all 4 modes and collect data
- Analyze immediate vs settled readings
- Compare battery consumption across modes
- Determine optimal stall detection threshold
💡 Key Design Decisions Explained¶
Why TWO Back-EMF Readings?¶
You asked a great question: should we read immediately or wait for settling? Answer: BOTH!
- Immediate: Captures motor's true back-EMF before decay
- Settled: Shows filtered value after capacitor charging
- Your tests will reveal which is better for stall detection!
Why 10ms Settling Time?¶
- Filter RC time constant: ~0.5ms
- 10ms = 20× time constant = very well settled
- Also gives motor time to start coasting
- But your data will show if we need less/more!
Why 10-Second Battery Polling?¶
- 90% reduction in ADC activity vs 1-second polling
- Battery voltage changes slowly (minutes, not seconds)
- Still fast enough to catch issues
- Frees CPU cycles for other tasks
🛠️ Troubleshooting Quick Reference¶
| Issue | Solution |
|---|---|
| No back-EMF readings | Check summing network, verify R_load NOT POPULATED |
| GPIO0 always ~1650mV | Motor may not be running, check H-bridge |
| Battery warning persists | Battery genuinely low (3.0-3.2V), charge to >3.2V |
| Motor not running | Test with hbridge_pwm_test first |
| LED not blinking | Check GPIO16 enable (should be LOW) |
📚 Documentation References¶
- Full Test Guide:
test/SINGLE_DEVICE_BATTERY_BEMF_TEST_QUICK_GUIDE.md - AD021: Motor Stall Detection via Back-EMF Sensing
- AD023: Deep Sleep Wake State Machine
- Build Commands:
BUILD_COMMANDS.md(updated)
✨ What Makes This Test Special¶
- Dual Sampling Strategy: Immediate + settled readings reveal motor behavior
- Integrated Subsystems: Motor + battery + LED working together
- Power Efficiency: 10s battery polling, first-10s back-EMF sampling
- Research Ready: 4 modes × 20 minutes = comprehensive characterization
- Production Path: Everything you learn feeds into final implementation
Status: ✅ Ready for hardware testing!
Test Duration: 20 minutes per mode × 4 modes = 80 minutes full characterization
Quick Test: Press button to cycle through modes rapidly
Good luck with your characterization tests! The dual-reading approach should give you excellent insight into motor behavior. Let me know what you discover! 🚀