![](/media/cache/group/gazou_0224.jpg.50x50_q85.jpg)
LowpassFilter(仮)?を使って加速度の値をフィルタリングして角度をもとめてます。ローカルファイルシステムを使って値をグラフ化できるようにしてます。 ローパスフィルタについてアドバイスがあればお願いします。
Dependencies: LIS3DH_Hello mbed
Fork of LocalFileSystem_HelloWorld by
Diff: main.cpp
- Revision:
- 3:edc2c71d87b1
- Parent:
- 2:69e9bf864751
diff -r 69e9bf864751 -r edc2c71d87b1 main.cpp --- a/main.cpp Mon Mar 30 15:33:24 2015 +0000 +++ b/main.cpp Mon Mar 30 16:05:06 2015 +0000 @@ -8,12 +8,16 @@ DigitalOut myled(LED4); //角度を算出する関数(ローパスフィルタを使用) float angle (float nowx,float nowy) { - static float x = 0,y = 0; + static float x = 0,y = 0;//前回の値を入れておく変数 float theta,deg,getx,gety; + //filter getx = filter*x + (1-filter)*nowx; gety = filter*y + (1-filter)*nowy; + //角度を求める[theta] theta = atan(getx/gety); + //変換[deg] deg = theta * 180 / pi; + //今回の値を保存 x = nowx; y = nowy; return deg;