2017年3月,伊豆大島共同打上実験 CORE_缶ロケチーム電装

Dependencies:   MPU6050 MS5607 mbed SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
mikawataru
Date:
Fri Mar 10 04:28:18 2017 +0000
Parent:
14:cbee1bfdfca7
Child:
16:0a239047eb29
Commit message:
fixed a power shortage for servo

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Mar 08 15:50:06 2017 +0000
+++ b/main.cpp	Fri Mar 10 04:28:18 2017 +0000
@@ -44,7 +44,7 @@
 #include "MPU6050.h"
 #include "SDFileSystem.h"
 
-#define ACC_LAUNCH      4
+#define ACC_LAUNCH      0//FIXME:本番は4g
 #define TOP_DROP_AMOUNT 1.5
 #define ALT_UAV_DROP    150
 #define TIME_REACH_TOP  15
@@ -121,11 +121,13 @@
    fp = fopen("/sd/log.txt", "w");
    fprintf(fp, "pressure,temperature,ax,ay,az,gx,gy,gz\r\n");
    device.attach(&_Input,Serial::RxIrq);
+   loop_open.attach(&_Open,1.0/RATE_OPEN);
    while(1);
 }
 /*開放用関数 RATE_OPEN[Hz]で判定を行う*/
 void _Open(){
    myled = 1 << (Phase-1);
+//   device.printf("%f,%f,%f\r\n",alt_buff[col_open],alt_launch,alt_max);
    switch (Phase) {
       case SETUP://セットアップモード(発射判定不可)
                   break;
@@ -196,6 +198,7 @@
     }
 }
 /*サーボ動作用関数 _Servo(int8_t 扉番号,float pwm波長)*/
+// TODO:サーボ回転量の調整
 void _Servo(int8_t door_num, float motion){
    if(door_num==0){//全扉
       Door_1_1.pulsewidth(motion);
@@ -204,9 +207,11 @@
       Door_2_2.pulsewidth(motion);
    }else if(door_num==1){//扉1
       Door_1_1.pulsewidth(motion);
+      wait(0.1);
       Door_1_2.pulsewidth(motion);
    }else if(door_num==2){//扉2
       Door_2_1.pulsewidth(motion);
+      wait(0.1);
       Door_2_2.pulsewidth(motion);
    }else{
       device.printf("servo error:%d\r\n",door_num);
@@ -214,13 +219,14 @@
 }
 
 /*入力用*/
-//TODO :テストモード実装
-//FIXME:android端末だと入力崩れが起こる
+// TODO:テストモード実装
+// FIXME:android端末だと入力崩れが起こる
+// FIXME:サーボ入力がたぶん逆
 void _Input(){
    input_buff[input_cnt] = device.getc();
    device.printf("\r\n");
    device.printf("input_cnt:%d\r\n",input_cnt);
-   device.printf("input_buff:%s\r\n",input_buff);   
+   device.printf("input_buff:%s\r\n",input_buff);
    switch (Mode) {
       case STANDBY:
                   if(input_cnt==0){
@@ -260,8 +266,12 @@
                            device.printf("-->>");
                         }else if(input_buff[1]=='T'){
                            Mode = TEST;
+                           Phase = RISE;
+                           alt_launch = _Measure_Alt(ms5607.getPressure()/100,ms5607.getTemperature());
                         }else if(input_buff[1]=='F'){
                            Mode = FLIGHT;
+                           Phase = LAUNCH;
+                           loop_log.attach(&_Log,1.0/RATE_LOG);
                            device.printf("FLIGHT-Mode ON!\r\n");
                            device.printf("***alert***\r\n");
                            device.printf("You will be able to reset only!\r\n");