Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 2_MPU9250 mbed 2_GPS_GMS6-CR6 2_LPS33HW 2_EEPROM 2_P7100
Revision 0:842b08cc6af5, committed 2020-07-13
- Comitter:
- rary
- Date:
- Mon Jul 13 11:51:24 2020 +0000
- Commit message:
- add flight mode
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2_EEPROM.lib Mon Jul 13 11:51:24 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/SSLM1/code/2_EEPROM/#9badac067403
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2_GPS_GMS6-CR6.lib Mon Jul 13 11:51:24 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/SSLM1/code/2_GPS_GMS6-CR6/#98e44a8cca1d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2_LPS33HW.lib Mon Jul 13 11:51:24 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/SSLM1/code/2_LPS33HW/#efb4130c9550
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2_MPU9250.lib Mon Jul 13 11:51:24 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/SSLM1/code/2_MPU9250/#d1941b046909
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2_P7100.lib Mon Jul 13 11:51:24 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/SSLM1/code/2_P7100/#7cc5b6bdf3a0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jul 13 11:51:24 2020 +0000
@@ -0,0 +1,152 @@
+#include "mbed.h"
+#include "EEPROM.h"
+#include "LPS33HW.h"
+#include "P7100.h"
+#include "MPU9250.h"
+#include "GMS6_CR6.h"
+
+
+Timer t; //時間計測
+Serial pc(USBTX, USBRX);
+LPS33HW lps(p9, p10);
+EEPROM rom(p9, p10);
+MPU9250 mpu(p9, p10);
+P7100 p7100(p5, p6, p7, p8);
+Serial twe(p13, p14);
+GMS6_CR6 gps(p28, p27);
+
+DigitalIn Flight_Pin(p30);
+
+void get_save_low(); //自作関数プロトタイプ宣言
+void get_save_high(); //自作関数プロトタイプ宣言
+
+int pointer_high = 0; //EEPROM保存アドレス(high)
+int pointer_low = 0; //EEPROM保存アドレス(low)
+
+
+//main
+int main()
+{
+ pc.baud(460800); //ボーレート変更
+ twe.baud(230400); //tweボーレート変更
+
+ float lat_north; //GPS緯度
+ float lon_east; //GPS経度
+ float GPS[2]; //GPSデータ格納配列
+
+ t.start(); //timer Start
+
+ //sensor Setup
+ lps.start(1); //気圧センサスタート
+ lps.start(1); //気圧センサスタート
+ wait(0.1);
+ mpu.start(); //MPU9250 start&setup
+ mpu.accelsetup(3);
+ mpu.gyrosetup(3);
+ mpu.AKsetup(1);
+ wait(0.2);
+
+
+ //Wait mode
+ pc.printf("waitmode Start!\r\n");
+ while(Flight_Pin == 0)
+ {
+ get_save_low(); //data get&save
+ wait_ms(1000);
+ }
+ pc.printf("waitmode Finish!\r\n");
+
+
+ //Flight mode
+ pc.printf("Flightmode Start!\r\n");
+ while(1)
+ {
+ for(int k = 0; k < 200; k++) //2回に一回送信
+ {
+ for(int n = 0; n < 2;n++)
+ {
+ get_save_high(); //data get&save
+ }
+ twe.printf("^"); //送信トリガー
+ }
+
+ gps.read(GPS); //測位データ取得
+ lat_north = GPS[0];
+ lon_east = GPS[1];
+
+ if(lat_north > 20 && lat_north < 90 && lon_east > 90 && lon_east < 180) //緯度が正常な値のときのみ送信
+ {
+ twe.printf("%f,%f\r\n^", lat_north, lon_east); //送信トリガー
+ pc.printf("%f,%f\r\n", lat_north, lon_east); //check用
+ }
+ memset(GPS,'\0', 2); //送信トリガー
+ }
+ pc.printf("Flightmode Finish!\r\n");
+
+}
+
+
+void get_save_low()
+{
+ char s[64]; //データ取得配列
+
+ float accel[3], gyro[3]; //MPU9250data
+ float AX, AY, AZ, GX, GY, GZ; //MPU9250data
+
+ float T = t.read(); //時刻データ取得
+ float P = lps.data_read(); //気圧データ取得
+ float V = p7100.v_read(); //電圧取得
+ float TP = 0.25 * V - 0.125; //タンク圧力換算
+
+ mpu.accel_read(3, accel);
+ mpu.gyro_read(3, gyro);
+ AX = accel[0];
+ AY = accel[1];
+ AZ = accel[2];
+ GX = gyro[0];
+ GY = gyro[1];
+ GZ = gyro[2];
+
+ sprintf(s, "%8.3f %8.3f %6.3f %5.3f %5.2f %5.2f %5.2f %5.2f %5.2f\r\n", T, P, TP, AX, AY, AZ, GX, GY, GZ); //floatからchar*へ変換
+
+ rom.write_low(pointer_low, s, 64); // write tha data
+ pointer_low = pointer_low + 64; //アドレスずらし
+
+ pc.printf("%s\r\n", s); //check用
+
+ memset(s, '\0', 64 ); //初期化
+}
+
+void get_save_high()
+{
+ char s[64]; //データ取得配列
+
+ float accel[3], gyro[3]; //MPU9250data
+ float AX, AY, AZ, GX, GY, GZ; //MPU9250data
+
+ float T = t.read(); //時刻データ取得
+ float P = lps.data_read(); //気圧データ取得
+ float V = p7100.v_read(); //電圧取得
+ float TP = 0.25 * V - 0.125; //タンク圧力換算
+
+ mpu.accel_read(3, accel);
+ mpu.gyro_read(3, gyro);
+ AX = accel[0];
+ AY = accel[1];
+ AZ = accel[2];
+ GX = gyro[0];
+ GY = gyro[1];
+ GZ = gyro[2];
+
+ sprintf(s, "%8.3f %8.3f %6.3f %5.3f %5.2f %5.2f %5.2f %5.2f %5.2f\r\n", T, P, TP, AX, AY, AZ, GX, GY, GZ); //floatからchar*へ変換
+
+ rom.write_high(pointer_high, s, 64); // write tha data
+
+ twe.printf("%s", s); //無線機送信
+
+ pointer_high = pointer_high + 64; //アドレスずらし
+
+ pc.printf("%s\r\n", s); //check用
+
+ memset(s, '\0', 64 ); //初期化
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jul 13 11:51:24 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file