Acceleration Magnitude
Lab 2: คำนวณ Acceleration Magnitude
วัตถุประสงค์
Motion Detection: ขนาดของ acceleration บอกระดับการเคลื่อนไหว
Gravity Reference: วางนิ่ง = 1g (9.81 m/s²)
Impact Detection: ตกกระแทก = magnitude spike
จะได้เรียนรู้อะไร
Vector Magnitude: √(x² + y² + z²)
Math Functions: sqrtf()
Physical Meaning: ความหมายของ magnitude
2.1 Concept: Vector Magnitude
โหลด Project Code จาก AIC Github Repo เพื่อเปิดบน VSCode IDE
2.2 เปิดโปรเจกต์ aic-psoc-edge-epc2-imu-magnitude-master
เปิดไฟล์ proj_cm33_ns/sensor_hub_daq_task.c และศึกษาโครงสร้าง:
เพิ่ม Include
Important Macros and Variables
สร้างฟังก์ชัน Raw accelerometer Conversion ชื่อ lsb_to_mp2()
สร้างฟังก์ชัน Magnitude Calcuation ชื่อ calculate_magnitude()
2.3 เขียน Main Task Loop
Create Sensor Hub DAQ Task Function
2.4 Build และ Flash
2.5 Output ที่คาดหวัง
Physical Meaning
สถานะ
Magnitude
ความหมาย
วางนิ่ง
≈ 9.81 m/s²
1g จากแรงโน้มถ่วง
เคลื่อนไหวเบา
9.5-10.5 m/s²
±0.1g deviation
เคลื่อนไหวปานกลาง
8-12 m/s²
±0.3g deviation
ตกกระแทก
> 20 m/s²
> 2g (impact)
ตกอิสระ
≈ 0 m/s²
Weightlessness
Flowchart

✍️ Exercise
1. G-Force Display : แสดงค่า magnitude ในหน่วย g พร้อม visual indicator
Max/Min Tracking : เก็บค่า max และ min magnitude ที่เคยวัดได้
จบ Session 2 | ต่อไป: Session 3: LVGL Display
Last updated
Was this helpful?