2017年3月,伊豆大島共同打上実験 CORE_缶ロケチーム電装
Dependencies: MPU6050 MS5607 mbed SDFileSystem
Diff: main.cpp
- Revision:
- 6:15204813ef87
- Parent:
- 5:bcf55d8fe7a7
- Child:
- 7:5f693667d0e9
--- a/main.cpp Mon Feb 20 12:25:06 2017 +0000 +++ b/main.cpp Wed Feb 22 08:49:59 2017 +0000 @@ -16,9 +16,9 @@ VIN--------------------------------------------------------------------4.5~9.0V -----------------------------------VIN------VIN------VIN------VIN------5V Vout-----VCC------VIN-----VDD------------------------------------------3.3V - -ADO -PS + \-ADO \-PS GND------GND------GND-----VSS------GND------GND------GND------GND------0V - -CS + \-CS p9-------SDA------SDA---------------------------------------------------- p10------SCL------SCL---------------------------------------------------- p11-----------------------CLK-------------------------------------------- @@ -40,8 +40,8 @@ #define RATE_LOG 10//ログ用 #define RATE_OPEN 10//開放用 /*サーボ動作*/ -#define LOCK true -#define UNLOCK false +#define LOCK 0.0005 +#define UNLOCK 0.0015 /*フェイズ定義*/ #define STANDBY 0 #define LAUNCH 1 @@ -80,7 +80,7 @@ FILE *fp; void _Open(); -void _Servo(int8_t door_num, bool door_motion); +void _Servo(int8_t door_num, float motion); void _Log(); int main() { @@ -89,6 +89,7 @@ Door_1_2.period_ms(20); Door_2_1.period_ms(20); Door_2_2.period_ms(20); + _Servo(0,LOCK); fp = fopen("/sd/log.txt", "w"); fprintf(fp, "pressure,temperature,ax,ay,az,gx,gy,gz\r\n"); loop_log.attach(&_Log,1.0/RATE_LOG); @@ -96,6 +97,7 @@ while(1); } +/*開放用関数 RATE_OPEN[Hz]で判定を行う*/ void _Open(){ myled = 1 << (Phase-1); switch (Phase) { @@ -127,6 +129,7 @@ } } +/*記録用関数 RATE_LOG[Hz]で記録を行う*/ void _Log(){ t[row][col] = timer.read(); pressure[row][col] = ms5607.getPressure(); @@ -145,6 +148,20 @@ } } -void _Servo(int8_t door_num, bool door_motion){ - +/*サーボ動作用関数 _Servo(int8_t 扉番号,float pwm波長)*/ +void _Servo(int8_t door_num, float motion){ + if(door_num==0){//全扉 + Door_1_1.pulsewidth(motion); + Door_1_2.pulsewidth(motion); + Door_2_1.pulsewidth(motion); + Door_2_2.pulsewidth(motion); + }else if(door_num==1){//扉1 + Door_1_1.pulsewidth(motion); + Door_1_2.pulsewidth(motion); + }else if(door_num==2){//扉2 + Door_2_1.pulsewidth(motion); + Door_2_2.pulsewidth(motion); + }else{ + pc.printf("error\r\n"); + } }