Motion page2

影片1 - 實際操作三方向的加速度g感測

影片2 - 電腦顯示三方向的加速度g感測

  • 主題 - 震動感測器 earthquake warning system based on LaunchPad

到目前為止,已介紹過許多感測器模組,例如:內建的溫度計,那麼要如何其他做出好玩的應用呢,接下來介紹加速度計。

三軸加速度感測器是一種可以對物體運動過程中的加速度進行測量的電子設備,典型互動應用中的加速度傳感器可以用來對物體的姿態或者運動方向進行檢測,可量測三方向重力加速度來量測微小的重直向與水平向震動訊號 ,量測各軸的加速度信號在不運動或不被重力作用的狀態下(0g),其輸出為1.65V。如果沿著某一個方向活動,或者受到重力作用,輸出電壓就會根據其運動方向以及設定的感測器靈敏度而改變其輸出電壓。用Launchpad內建的A/D轉換器讀取此輸出信號,就可以檢測其震動,應用在Wii遊戲機搖桿和iPhone手機中的翻轉顯示摩托車和汽車防盜報警器,遙控模型,跌倒探測,硬碟衝擊保護,傾斜角度測量,電梯安全監控等。

地震擴充模組,此感測模組輸出電壓必須有連接類比取樣功能的LaunchPad,請先確定核心晶片型號,而使用上得到的精準度需要校正,溫度補償技術,並且提供2種模式(1.5g與6g)可選,玩家可在2種靈敏度中選擇適合應用的範圍。有關於如何選用加速度計的建議,玩家可以參考這裡,而本例子使用Freescale MMA7361當作感測器,除了取得價錢較低之外,它本身帶有低通濾波並已做零g補償。具有休眠模式,可以製作出較省電的裝置。這裡有關地震擴充模組製作說明,這裡

  • 重力加速度g與感應器擺放方向

  • 準備材料- 加速度模組實體圖

MMA7361 封裝為14-LGA

  • 腳位定義

x P1.5

y P1.6

z P1.7

注意!! SL 接線 Sleep腳需要接至高準位 VCC

  • 組裝 - LaunchPad + Sensor Booster Pack + MMA7361

  • 基板核心程式

這裡我們套用了LILPv2核心程式即可運作,請查看詳細安裝LILP步驟

  • 電腦界面程式

這裡ADC 3CH關於,在這裡連結,簡化玩家開發人機介面。

http://msp430-launchpad-diy.googlecode.com/files/Installer%20ADC%203ch%20Example%20LaunchPad%20with%20LILPv2.zip

  • 加速度規格備註 - 最小有效位元計算方式

1.5g setting: Sensitivity: 800 mV/g -1g = 850mV 0g = 1650mV 1g = 2450mV

800mV = 1000mg => mV/analogRead unit = Aref V / 1024

g = [mV/analogRead unit] * ([units] - ([Aref/2]) / [mvPerG]

0-60 Time = 26.8224 / (g * 9.81) [60MPH = 26.8224 m/s, g = 9.81 m/s/s]

  • 進階應用 - 3D動作互動模型

https://msp430-launchpad-diy.googlecode.com/files/3D%20Motion%20Model%20LaunchPad%20Installer.zip

https://msp430-launchpad-diy.googlecode.com/files/3D_Motion_Model_LaunchPad_project_directory_full_with_LILPv2.7z

http://www.nuclearprojects.com/ins/arduino_program.shtml

Accelerometer

I'm going to show two different ways of calculating angle of rotation from the accelerometer data. Although the common way of doing it is using force vectors, I wont show that here.

First method: The first part of the calculation is exactly the same as for the gyro. I need to zero the ADC readings, convert any remaining ADC values into quids, then convert that into voltage. The voltage can then be divided by the accelerometer sensitivity, like we did with the gyro.

    • Accel_X = (Accel_ADC_Value - Zero_Voltage_Value) * (3.3V/1023) / Accel_Sensitivity

It should be noted that the zero_voltage_value in this case is with respect to the x-axis accelerometer. Now for a worked example:

    • Accel_X = (558 - 504) * (3.3/1023) / 0.33 ----> (0.33 is 330mV) Accel_X = 54 * 0.0032258 / 0.33 Accel_X = 0.528 G's

Now to convert this value into an angle, we can take the Arcsin of the value. The result will be in radians. Since 1 radian = 180/PI or 57.2957795 degrees, we can just multiply the result accordingly to get degrees.

    • Accel_Angle_X = asin(Accel_X) * 57.2957795 Accel_Angle_X = asin(0.528) * 57.2957795 Accel_Angle_X = 0.556 * 57.2957795 Accel_Angle_X = 31.87 degrees