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: mbed mbedTimer SDFileSystem MU2 GPS
Diff: main.cpp
- Revision:
- 14:a07d2a958617
- Parent:
- 11:a273a8decf90
- Child:
- 15:bc013c313ef5
--- a/main.cpp Sun Aug 18 05:43:34 2019 +0000
+++ b/main.cpp Tue Aug 20 22:11:17 2019 +0000
@@ -5,12 +5,12 @@
//#include "GPS.h"
#define FIRETIME 5 //溶断時間を設定
-#define FALLTIME 10 //シェンロン展開してインレットを閉鎖するまでの時間を設定
+#define FALLTIME 90 //シェンロン展開してインレットを閉鎖するまでの時間を設定
#define CLOSETIME 10 //インレット閉鎖機構の稼働時間を設定
////////////////フライトピンが抜ける→シェンロン展開→インレット閉鎖→待機
//シーケンス番号//1//////////////////2///////////3///////////4///
-//mbedのLEDが各シーケンス番号を2進数で示す:ex 0011 インレット閉鎖中
+//mbedのLEDが各シーケンス番号を2進数で示す:ex 0011 インレット閉鎖中
MU2 MuPort(p28,p27);
SDFileSystem sd(p11, p12, p13, p14, "sd");
@@ -19,19 +19,43 @@
Inlet inlet(p26,p17,p15);//モーター出力,感圧センサー1入力,感圧センサー2入力
-DigitalOut FIRE(p16); //溶断
+DigitalOut FIRE(p24); //溶断
DigitalOut myled(LED1);
DigitalOut myled2(LED2);
DigitalOut myled3(LED3);
DigitalOut myled4(LED4);
+
+/*******************************************************************************
+メイン関数
+*******************************************************************************/
+
int main()
{
- wait(0.1);//起動してからちょっと待つ
+ wait(10);//起動してからちょっと待つ
inlet.Stop();
//FILE* fp1= fopen("/sd/cansat/log3.txt", "w");
- FILE* fp2= fopen("/sd/cansat/gpsdata0808_2.csv", "w");
+ FILE* fp= fopen("/sd/cansat/log0820_1.csv", "w");
+ if(fp == NULL) {
+
+ myled=1;
+ myled2=1;
+ myled3=1;
+ myled4=1;
+
+ fp = fopen("/sd/cansat/log0820_1.csv", "w");
+ wait(0.5);
+ myled=0;
+ myled2=0;
+ myled3=0;
+ myled4=0;
+
+ }
+
+
+ fprintf(fp, "CanSatStart!\r\n");
+ MuPort.send("CanSat Start!\r\n");
/*if(fp1 == NULL || fp2 == NULL)
{
@@ -42,14 +66,21 @@
//溶断機構部分
- //fprintf(fp1, "CanSat start!\r\n");
- //fprintf(fp1, "Fire!!\r\n");
+ fprintf(fp, "FireStart!\r\n");
+ MuPort.send("Fire Start!\r\n");
myled=1;//テストようにLED光らせてる
-
+
FIRE=1;
wait(FIRETIME);//溶断にかかる時間TBD秒
FIRE=0;
-
+ wait(10);
+ FIRE=1;
+ wait(3);//溶断にかかる時間TBD秒
+ FIRE=0;
+
+ fprintf(fp, "FireFinish!\r\n");
+ MuPort.send("Fire Finish!\r\n");
+
//溶断機構終わり
gps.baud(9600);
@@ -58,32 +89,33 @@
int i=0;
int timer=0;
- //fprintf(fp1, "GPS start!\r\n");
+ /*******************************************************************************
+ シェンロン展開
+ *******************************************************************************/
- while(1)
- {
+ fprintf(fp, "GPSstart!\r\n");
+ MuPort.send("GPS start!\r\n");
+
+ while(1) {
myled=0;
myled2=1;
- if(gps.readable())
- {
+ if(gps.readable()) {
recvGPS=gps.getc();
getGPS[i]=recvGPS;
- if(getGPS[i]=='\n')
- {
+ if(getGPS[i]=='\n') {
- if((getGPS[5]=='G')&&(getGPS[6]=='A'))
- {
-
+ if((getGPS[5]=='G')&&(getGPS[6]=='A')) {
+
MuPort.send(getGPS);
myled=1;
/*if(fp == NULL) {
error("Could not open file for write\n");
}*/
- fprintf(fp2, "%s\n",getGPS);
+ fprintf(fp, "%s\n",getGPS);
//fclose(fp);
-
+
wait(1.0);
timer++;
}
@@ -91,8 +123,7 @@
i=0;
}
i++;
- if(timer>FALLTIME)//落下開始してからTBD秒後whileを抜ける.
- {
+ if(timer>FALLTIME) { //落下開始してからTBD秒後whileを抜ける.
break;
}
}
@@ -100,30 +131,34 @@
// wait(1);
//fclose(fp);
}
-
- timer=0;//モーター時間で止めるよう
-
- while(1)
- {
+
+
+ /*******************************************************************************
+ インレット閉鎖
+ *******************************************************************************/
+
+ fprintf(fp, "InletStart!\r\n");
+ MuPort.send("Inlet start!\r\n");
+
+ timer=0;//モーター時間で止める用
+
+ while(1) {
myled2=0;
myled3=1;
- if(gps.readable())
- {
+ if(gps.readable()) {
recvGPS=gps.getc();
getGPS[i]=recvGPS;
- if(getGPS[i]=='\n')
- {
+ if(getGPS[i]=='\n') {
- if((getGPS[5]=='G')&&(getGPS[6]=='A'))
- {
+ 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);
+ fprintf(fp, "%s\n",getGPS);
//fclose(fp);
wait(1.0);
timer++;
@@ -132,10 +167,9 @@
i=0;
}
i++;
- if(timer>CLOSETIME)
- {
- inlet.Stop();//
- break;
+ if(timer>CLOSETIME) {
+ inlet.Stop();//
+ break;
}
inlet.Close(1.1);//1より大きい引数にしておけばモーターはずっと回ってる.
}
@@ -143,30 +177,33 @@
// wait(1);
//fclose(fp);
}
-
- //何もせずGPS信号を発する
-
- while(1)
- {
+
+
+ /*******************************************************************************
+ 待機モード(何もせずGPS信号を発する)
+ *******************************************************************************/
+
+ fprintf(fp, "StandbyModeStart!\r\n");
+ MuPort.send("Standby mode start!\r\n");
+
+
+ while(1) {
myled4=1;
myled3=0;
- if(gps.readable())
- {
+ if(gps.readable()) {
recvGPS=gps.getc();
getGPS[i]=recvGPS;
- if(getGPS[i]=='\n')
- {
+ if(getGPS[i]=='\n') {
- if((getGPS[5]=='G')&&(getGPS[6]=='A'))
- {
+ if((getGPS[5]=='G')&&(getGPS[6]=='A')) {
MuPort.send(getGPS);
myled3=1;
/*if(fp == NULL) {
error("Could not open file for write\n");
}*/
- fprintf(fp2, "%s\n",getGPS);
+ fprintf(fp, "%s\n",getGPS);
//fclose(fp);
wait(0.1);
timer++;
@@ -180,10 +217,10 @@
// wait(1);
//fclose(fp);
}
-
+
//fclose(fp1);
- fclose(fp2);
+ fclose(fp);
}