Skip to content

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

pio run -e single_device_battery_bemf_test -t upload && pio device monitor

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)

Battery: 3.85V [85%]

Mode Changes (Button Press)

=== Mode Change ===
New mode: 1Hz@25%
Restarting 10-second sampling window

🎯 Test Objectives

This test will help you determine:

  1. Optimal Sampling Timing
  2. Is immediate or settled reading better for stall detection?
  3. How fast does the motor spin down during coast?
  4. Is 10ms settling time appropriate?

  5. Back-EMF Characteristics

  6. Normal operation magnitude range
  7. Forward vs reverse symmetry
  8. Filter performance (PWM noise removal)

  9. Battery Efficiency

  10. Voltage drop per mode
  11. 50% vs 25% duty cycle power consumption
  12. Validate 10-second polling adequacy

  13. Integrated System Performance

  14. Motor + battery + LED coordination
  15. Power efficiency with all subsystems active
  16. 20-minute session battery impact

🔧 Circuit Requirements

Back-EMF Summing Network (GPIO0)

3.3V ─[10kΩ]─┬─ GPIO0 (ADC)
OUTA ─[10kΩ]─┤
           [22nF]
             GND
CRITICAL: R_load must be NOT POPULATED! Note: Production BOM uses 22nF (prototypes may have 12nF or 15nF)

Battery Voltage Divider (GPIO2)

VBAT ─[3.3kΩ]─┬─ GPIO2 (ADC)
           [10kΩ]
              GND
GPIO21 enables measurement (HIGH = enabled)

📝 Next Steps

  1. Build and flash the test
  2. Run all 4 modes and collect data
  3. Analyze immediate vs settled readings
  4. Compare battery consumption across modes
  5. 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

  1. Dual Sampling Strategy: Immediate + settled readings reveal motor behavior
  2. Integrated Subsystems: Motor + battery + LED working together
  3. Power Efficiency: 10s battery polling, first-10s back-EMF sampling
  4. Research Ready: 4 modes × 20 minutes = comprehensive characterization
  5. 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! 🚀