This is a test program!!
Dependencies: mbed mbedTimer SDFileSystem MU2 GPS
Diff: main.cpp
- Revision:
- 8:6b835a82b1eb
- Parent:
- 6:b7bf39bc3487
- Child:
- 9:ef9cd32a5db9
- Child:
- 10:87b3d19c8a5e
--- a/main.cpp Wed Aug 07 10:03:17 2019 +0000 +++ b/main.cpp Sun Aug 18 05:08:10 2019 +0000 @@ -4,16 +4,22 @@ #include "inletclose.h" //#include "GPS.h" +#define FIRETIME 5 //溶断時間を設定 +#define FALLTIME 10 //シェンロン展開してインレットを閉鎖するまでの時間を設定 +#define CLOSETIME 10 //インレット閉鎖機構の稼働時間を設定 + +////////////////フライトピンが抜ける→シェンロン展開→インレット閉鎖→待機 +//シーケンス番号//1//////////////////2///////////3///////////4/// +//mbedのLEDが各シーケンス番号を2進数で示す:ex 0011 インレット閉鎖中 + MU2 MuPort(p28,p27); SDFileSystem sd(p11, p12, p13, p14, "sd"); //GPS gps(p13,p14); Serial gps(p9,p10); //tx, rx -Inlet inlet(p26,p15,p16);//モーター出力,感圧センサー1入力,感圧センサー2入力 - +Inlet inlet(p26,p17,p15);//モーター出力,感圧センサー1入力,感圧センサー2入力 -//DigitalIn flight(p21); //フライトピン -DigitalOut FIRE(p24); //溶断 +DigitalOut FIRE(p16); //溶断 DigitalOut myled(LED1); DigitalOut myled2(LED2); @@ -22,11 +28,10 @@ int main() { - wait(0.1);//起動してからちょっと待つ - + inlet.Stop(); //FILE* fp1= fopen("/sd/cansat/log3.txt", "w"); - FILE* fp2= fopen("/sd/cansat/gpsdata1000.csv", "w"); + FILE* fp2= fopen("/sd/cansat/gpsdata0808_2.csv", "w"); /*if(fp1 == NULL || fp2 == NULL) { @@ -38,13 +43,12 @@ //溶断機構部分 //fprintf(fp1, "CanSat start!\r\n"); - //fprintf(fp1, "Fire!!\r\n"); - //FIRE=1; myled=1;//テストようにLED光らせてる - wait(3);//溶断にかかる時間TBD秒 - //FIRE=0; - myled=0; + + FIRE=1; + wait(FIRETIME);//溶断にかかる時間TBD秒 + FIRE=0; //溶断機構終わり @@ -58,8 +62,8 @@ while(1) { - myled3=1; - myled2=0; + myled=0; + myled2=1; if(gps.readable()) { recvGPS=gps.getc(); @@ -72,7 +76,7 @@ { MuPort.send(getGPS); - + myled=1; /*if(fp == NULL) { error("Could not open file for write\n"); }*/ @@ -87,7 +91,7 @@ i=0; } i++; - if(timer>15)//落下開始してからTBD秒後whileを抜ける. + if(timer>FALLTIME)//落下開始してからTBD秒後whileを抜ける. { break; } @@ -101,8 +105,8 @@ while(1) { - myled3=0; - myled2=1; + myled2=0; + myled3=1; if(gps.readable()) { recvGPS=gps.getc(); @@ -114,22 +118,23 @@ if((getGPS[5]=='G')&&(getGPS[6]=='A')) { MuPort.send(getGPS); - + myled2=1; /*if(fp == NULL) { error("Could not open file for write\n"); }*/ fprintf(fp2, "%s\n",getGPS); //fclose(fp); - wait(0.1); + wait(1.0); timer++; } i=0; } i++; - if(timer>30) + if(timer>CLOSETIME) { + inlet.Stop();// break; } inlet.Close(1.1);//1より大きい引数にしておけばモーターはずっと回ってる. @@ -143,8 +148,8 @@ while(1) { - myled3=1; - myled2=1; + myled4=1; + myled3=0; if(gps.readable()) { recvGPS=gps.getc(); @@ -156,7 +161,7 @@ if((getGPS[5]=='G')&&(getGPS[6]=='A')) { MuPort.send(getGPS); - + myled3=1; /*if(fp == NULL) { error("Could not open file for write\n"); }*/