6軸センサ(ジャイロ、加速度)を100Hz, GPSの数値を10Hzでロギングする。結果は全てシリアルモニタに出力される。 It enables us to log 6axis sensor datas (gyro,acceleration ) in 100Hz,ans GPS datas in 10Hz. All results will be outputted in serial moniter.
Dependencies: mbed MPU6050_alter
Revision 1:9e0eb043ecdb, committed 2019-02-27
- Comitter:
- Joeatsumi
- Date:
- Wed Feb 27 03:26:21 2019 +0000
- Parent:
- 0:847c925d2821
- Commit message:
- It enables us to log 6axis sensor datas (gyro,acceleration ) in 100Hz,ans GPS datas in 5Hz. All results will be outputted in serial moniter.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Feb 23 06:25:15 2019 +0000
+++ b/main.cpp Wed Feb 27 03:26:21 2019 +0000
@@ -1,4 +1,7 @@
-/*シリアルモニタに6軸センサを100Hz,
+/*Atsumi Toda 2/20/2019
+Shibaura Institute of Technology
+
+シリアルモニタに6軸センサを100Hz,
GPSからの経度、緯度、アンテナ高度、対地速度を10HZで出力する
gpsからの文字列を読み取ってから6軸の値を読みだす為、出力するデータを
GPGGAとGPRMCに限定しgpsモジュールを10Hz出力に設定する必要あり。
@@ -28,7 +31,8 @@
/*-------------------------------------------*/
/*------サンプリング間隔[s]--------*/
-//#define PERIOD 0.020
+#define PERIOD 0.010
+#define GPS_UPDATE_RATE 5
/*------------------------------*/
/*---------ピン指定-------------*/
@@ -96,14 +100,15 @@
/*--------------------------------------*/
double val=passed_time.read();
- //pc.printf("%f,%f,%f,%f,%f,%f,%f,%4.6f,%3.6f,%f,%f\r\n",val,dpsX,dpsY,dpsZ,a[0],a[1],a[2],g_tokei,g_hokui,a_altitude,speed_to_ground);
- //pc.printf("%7.3f,%f,%f,%f,%4.6f,%3.6f,%7.3f,%f\r\n",val,dpsX,dpsY,dpsZ,g_tokei,g_hokui,a_altitude,speed_to_ground);
- pc.printf("A,%7.3f,%f,%f,%f,%f,%f,%f,%f\r\n",val,dpsX,dpsY,dpsZ,a[0],a[1],a[2],tempreture_current);
+ pc.printf("A,%7.3f,%f,%f,%f,%f,%f,%f,%f\r\n",val,dpsX,dpsY,dpsZ,a[0],a[1],a[2],tempreture_current,g_tokei,g_hokui,a_altitude,speed_to_ground);
+ //pc.printf("G,%7.3f,%4.6f,%3.6f,%7.3f,%f\r\n",val,g_tokei,g_hokui,a_altitude,speed_to_ground);
//pc.printf("pased time is %f\r\n",val);
}
void gps_rx(){
-
+
+ __disable_irq(); // 割り込み禁止
+
/*=============GPS信号受信に用いる変数群===============*/
//char c;
int i,rlock,stn;
@@ -120,7 +125,6 @@
//speed_to_ground
float speed_knot,azi;
-
/*===============================================*/
i=0;
@@ -208,24 +212,27 @@
double val=passed_time.read();
pc.printf("G,%7.3f,%4.6f,%3.6f,%7.3f,%f\r\n",val,g_tokei,g_hokui,a_altitude,speed_to_ground);
+ __enable_irq(); // 割り込み許可
+
}//void gps_rx
int main() {
//wait(20);
- pc.baud(230400);//シリアルポートの通信レート設定
+ pc.baud(460800);//シリアルポートの通信レート設定
gps.baud(115200);
tempreture_initiation=mpu.getTemp();//初期温度取得
passed_time.start();//タイマー開始
- //flipper.attach(&scan_update, PERIOD);//scan_update関数をPERIOD間隔で呼び出し
+ //flipper.attach(&scan_update, PERIOD);//scan_update関数をPERIOD間隔で呼び出し
while(1) {
gps_rx();//4ms passed
+ wait_ms(4.0);
scan_update();
- for(int update_period=0;update_period<9;update_period++){
- wait_ms(6.0);
+ for(int update_period=0;update_period< int((100/GPS_UPDATE_RATE)-1);update_period++){
+ wait_ms(7.6);
scan_update();
//このfor文1周で約10msとなる。
}