iAccelerate: Vehicle Performance Analyzer with USB Accelerometer
Overview
Windows Forms application developed for Microsoft Imagine Cup 2007-2008 competition. Uses Phidgets USB accelerometer to measure vehicle acceleration and calculate performance metrics including 0-60 time, quarter-mile runs, and horsepower estimates. Provides affordable alternative to professional automotive dynamometers for car enthusiasts.
Architecture
Phidgets Hardware Integration
- Phidgets 3-axis accelerometer connected via USB
- AccelerationChange event handler for real-time data (100-200 Hz sampling)
- Forward axis aligned with vehicle longitudinal direction
- Measures acceleration in g-forces (-3g to +3g typical range)
Kinematic Calculator
- CarCalculator class implements physics equations
- Numerical integration using trapezoidal rule
- Time-step based calculations (Δt from event timestamps)
- Maintains state: current velocity, position, accumulated time
State Machine
- Idle state: Waiting for movement detection
- Armed state: Acceleration threshold exceeded (>0.02g default)
- Running state: Active measurement in progress
- Stopped state: Run complete, displaying final results
Data Logging
- Grid data: Summary statistics (0-60 time, quarter-mile, etc.)
- Trace data: Time-series log of acceleration/velocity/position
- StreamWriter for file output (CSV format)
- Optional logging controlled by user settings
Technical Implementation
Acceleration Integration: Used trapezoidal rule for numerical integration: v(t+Δt) = v(t) + (a(t) + a(t+Δt))/2 × Δt. More accurate than simple Euler method (v(t+Δt) = v(t) + a(t) × Δt) but still accumulates drift over long runs.
Drift Compensation: Accelerometers suffer from integration drift - small measurement errors accumulate when integrating to velocity. Implemented threshold-based reset: when acceleration drops below noise floor (±0.005g) for 2 seconds, assume vehicle at constant speed. Prevents runaway velocity calculations.
Horsepower Estimation: Used simplified formula HP = (m × v × a) / 375, where 375 converts (lb × ft/s × ft/s²) to horsepower. Assumes constant weight (no fuel burn), negligible air resistance, minimal tire slip. Accuracy ±10-15% compared to dyno measurements. More accurate at low speeds (< 60 MPH).
Threshold Detection: Start threshold (default 0.02g = 0.196 m/s²) filters out false positives from road vibrations. Too sensitive = false starts from bumps. Too high = misses gentle acceleration. Calibrated experimentally in parking lot tests.
UI Thread Marshaling: Phidgets events fire on background thread. Used Control.BeginInvoke() to marshal UI updates to main thread. Direct UI manipulation from background thread causes cross-thread exceptions. Alternative: event aggregator pattern with async updates.
Technical Challenges
Road Grade Compensation: Accelerometer measures vehicle acceleration minus gravity component. On uphill slope, gravity adds apparent deceleration. Downhill adds apparent acceleration. Attempted compensation using GPS altitude change rate, but GPS altitude too noisy (±10-20 meters). Professional systems use gyroscopes for pitch angle.
Sensor Mounting Stability: Accelerometer must be rigidly mounted to prevent movement relative to vehicle. Laptop on passenger seat slides/rotates during hard acceleration, corrupting measurements. Secured laptop with bungee cords on floor behind driver seat for stability.
Tire Slip: Calculations assume all measured acceleration translates to forward motion. Tire spin (wheel slippage) causes over-reading. Front-wheel drive cars exhibit more slip during hard launches. AWD vehicles most accurate. No easy correction without wheel speed sensors.
Data Rate vs Battery: Phidgets samples at 8ms intervals (125 Hz). Continuous USB polling drains laptop battery quickly. Reduced effective sample rate to 50 Hz (20ms) by averaging multiple readings. Balanced accuracy vs battery life for extended testing sessions.
Results
Successfully measured 0-60 times within ±0.1 seconds of professional timing equipment (Vbox, RaceLogic). Quarter-mile times within ±0.2 seconds. Horsepower estimates within 10% of manufacturer specifications for naturally aspirated engines. Turbocharged/supercharged engines showed larger variance due to boost lag not captured in simple model.
Demonstrated at Imagine Cup 2008 competition. Judges appreciated practical automotive application of physics principles and affordable hardware approach.
Tech Stack
- Platform: Windows Forms, .NET Framework 2.0/3.5
- Language: C#
- Hardware: Phidgets USB Accelerometer (1059 or similar), USB 2.0
- Libraries: Phidget21.NET.dll
- Physics: Newtonian mechanics, numerical integration
Lessons Learned
This project taught fundamental concepts:
- Sensor integration: Hardware interfacing, event-driven programming
- Signal processing: Noise filtering, drift compensation
- Numerical methods: Trapezoidal integration, time-step calculations
- Physics application: Kinematics equations in real-world scenario
- Error analysis: Understanding measurement limitations and accuracy bounds
Modern implementations would use smartphone accelerometers (iPhone, Android) with GPS fusion for better accuracy and portability. Apps like Dynolicious, Dragy, and RaceChrono provide similar functionality using integrated sensors.
Source Code
Code will be available on GitHub at: https://github.com/tanchunsiong/iaccelerate
Project Created: 2007-2008
Connect:
- Blog: www.tanchunsiong.com
- LinkedIn: linkedin.com/in/tanchunsiong
- X: x.com/tanchunsiong