Arc Gauge

Lab 9: Real Arc Gauge (Roll Angle)

1. เน‚เธ„เธฃเธ‡เธชเธฃเน‰เธฒเธ‡เธ เธฒเธžเธฃเธงเธกเธ‚เธญเธ‡ Lab

Why? - เธ—เธณเน„เธกเธ•เน‰เธญเธ‡เน€เธฃเธตเธขเธ™เธฃเธนเน‰เน€เธฃเธทเนˆเธญเธ‡เธ™เธตเน‰

  • Sensor Fusion: เธฃเธงเธก Accelerometer + Gyroscope เธ”เน‰เธงเธข Complementary Filter

  • Tilt Measurement: เธงเธฑเธ”เธเธฒเธฃเน€เธญเธตเธขเธ‡เธ‚เธญเธ‡เธšเธญเธฃเนŒเธ” (Roll = เน€เธญเธตเธขเธ‡เธ‹เน‰เธฒเธข/เธ‚เธงเธฒ)

  • Real Application: เนƒเธŠเน‰เนƒเธ™เธซเธธเนˆเธ™เธขเธ™เธ•เนŒเธ—เธฃเธ‡เธ•เธฑเธง, flight controller, gesture recognition

What? - เธˆเธฐเน„เธ”เน‰เน€เธฃเธตเธขเธ™เธฃเธนเน‰เธญเธฐเน„เธฃ

  1. Complementary Filter: เธชเธนเธ•เธฃ angle = 0.98*(angle+gyro*dt) + 0.02*accel_angle

  2. Tilt API: aic_tilt_init(), aic_tilt_update_from_imu(), aic_tilt_get_roll()

  3. Angle to Percentage: เนเธ›เธฅเธ‡ -180ยฐ...+180ยฐ เน€เธ›เน‡เธ™ 0%...100%

  4. Visual Feedback: Arc gauge เนเธชเธ”เธ‡ Roll angle

How? - เธˆเธฐเธ—เธณเธญเธขเนˆเธฒเธ‡เน„เธฃ

  1. Initialize Tilt Analysis เธ”เน‰เธงเธข aic_tilt_init()

  2. Timer callback เน€เธฃเธตเธขเธ aic_tilt_update_from_imu()

  3. เธญเนˆเธฒเธ™ Roll angle เนเธฅเธฐเนเธชเธ”เธ‡เธšเธ™ Arc


2. เธซเธฅเธฑเธเธเธฒเธฃเธ—เธณเธ‡เธฒเธ™เนเธฅเธฐ Flowchart

2.1 Why Complementary Filter?

2.2 Complementary Filter Formula

2.3 Roll Angle Measurement

2.4 UI Layout


3. เธŸเธฑเธ‡เธเนŒเธŠเธฑเธ™เธชเธณเธ„เธฑเธ

3.1 Tilt API Functions

Function
Description

aic_tilt_init(NULL)

Initialize tilt analysis with defaults

aic_tilt_update_from_imu()

Update tilt from sensor data

aic_tilt_get_roll()

Get roll angle (-180ยฐ to +180ยฐ)

aic_tilt_get_pitch()

Get pitch angle (-90ยฐ to +90ยฐ)

aic_tilt_get_roll_percent()

Get roll as 0-100%

aic_tilt_get_pitch_percent()

Get pitch as 0-100%

3.2 Angle to Percentage Mapping


4. Code Example

4.1 Timer Callback

4.2 Main Function


5. เธญเธ‡เธ„เนŒเธ„เธงเธฒเธกเธฃเธนเน‰เนเธฅเธฐเน€เธ—เธ„เธ™เธดเธ„

5.1 Filter Alpha Value

5.2 Understanding Roll vs Pitch

5.3 Why Read-Only Arc?


6. เนเธšเธšเธเธถเธเธซเธฑเธ”

Exercise 1: Color by Tilt

เน€เธ›เธฅเธตเนˆเธขเธ™เธชเธต Arc เธ•เธฒเธก Roll angle:

  • Green: -30ยฐ to +30ยฐ (level)

  • Yellow: ยฑ30ยฐ to ยฑ60ยฐ (tilting)

  • Red: > ยฑ60ยฐ (extreme tilt)

Exercise 2: Dual Arc (Roll + Pitch)

เนเธชเธ”เธ‡ Arc 2 เธญเธฑเธ™เธชเธณเธซเธฃเธฑเธš Roll เนเธฅเธฐ Pitch เธžเธฃเน‰เธญเธกเธเธฑเธ™


7. References


Previous Lab: Lab 8: Real Sensor Dashboard Next Lab: Lab 10: Real Scale Gauge

Last updated

Was this helpful?