I completed the final calibration of both vertical and horizontal stepper motors in motor.py. This involved fine-tuning step timing, direction switching delays, and enable/disable sequencing to eliminate missed steps and reduce audible buzzing.
Using ble/motortest.py , I iteratively adjusted:
- Step pulse width and delay between steps
- Direction settle time before motion
- Enable pin polarity (active-high vs active-low)
- Maximum safe stepping rate under load
I also validated consistent motion across different step ranges (1–50 steps) and ensured that small corrective movements were smooth rather than jittery. The final configuration achieves stable, repeatable positioning without overheating or skipped steps.
Integration and app controls
I polished the full system integration between the Pi, BLE server, and iOS app:
- Added manual control buttons in the app for horizontal and vertical adjustments, allowing override of automatic tracking
- Ensured bidirectional BLE communication is stable, with commands reliably reaching the Pi and status updates returning at ~10 Hz
- Improved JSON payload structure to include clearer motor state and command acknowledgments
- Verified synchronization between app UI state and actual motor state (no drift between displayed and real position)
The integrator loop now cleanly merges:
- Sun telemetry (azimuth/elevation)
- User detection error
- Manual override commands
with priority handling so manual input temporarily overrides automatic behavior.
Testing
- Unit tests
- Sun position outputs verified against known values and edge cases (UTC conversion, sunrise/sunset)
- Motor error → step mapping validated (scaling, clamping, direction)
- BLE JSON structure checked for correct fields and app compatibility
- Integration tests
- used for direction changes, variable stepping, and long-run stability
- Integrator loop confirmed stable at 10 Hz with non-blocking motor control
- BLE tested for reliable command delivery and consistent status updates
- System tests
- End-to-end: app → BLE → Pi → motors → status → app
- Manual override vs automatic tracking behavior verified
- Stress test with rapid commands and reconnect scenarios
Findings
- High step rates caused occasional missed steps → required increasing delay between pulses
- Rapid direction changes introduced small positioning errors → fixed with added direction settle time
- BLE message bursts could temporarily desync UI → improved by adding lightweight acknowledgment logic
- Small error values caused jitter → resolved by enforcing minimum step threshold and smoothing
Design changes
- Adjusted motor stepping profile to prioritize smoothness over speed
- Added minimum step threshold to avoid micro-jitter
- Introduced manual override priority in integrator logic
- Improved BLE protocol with clearer state reporting and synchronization handling
- Refined threading model in motor.py to ensure safe concurrent execution




