for_20211114

Dependencies:   HEPTA_SENSOR mbed HEPTA_EPS HEPTA_COM HEPTA_CDH

Committer:
MEXT1
Date:
Wed Jul 22 02:27:10 2020 +0000
Revision:
27:ecdf196153cd
Parent:
26:220e5f95168a
Child:
28:80d6576011e1
202007

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:bdbd3d6fc5d5 1 #include "mbed.h"
HeptaSatTraining2019 25:ccc5ff675e0c 2 #include "HEPTA_CDH.h"
HeptaSatTraining2019 25:ccc5ff675e0c 3 #include "HEPTA_EPS.h"
MEXT1 27:ecdf196153cd 4 DigitalOut cond[]={LED1,LED2,LED3,LED4};
MEXT1 27:ecdf196153cd 5 Serial gs(USBTX,USBRX); // for ground station
HeptaSatTraining2019 26:220e5f95168a 6 HEPTA_CDH cdh(p5, p6, p7, p8, "sd");
HeptaSatTraining2019 26:220e5f95168a 7 HEPTA_EPS eps(p16,p26);
MEXT1 27:ecdf196153cd 8 int rcmd = 0,cmdflag = 0; //command variable
HeptaSatTraining2019 24:3659e0c223c8 9
MEXT1 27:ecdf196153cd 10 //getting command and flag
HeptaSatTraining2019 26:220e5f95168a 11 void commandget()
HeptaSatTraining2019 26:220e5f95168a 12 {
MEXT1 27:ecdf196153cd 13 rcmd=gs.getc();
HeptaSatTraining2019 26:220e5f95168a 14 cmdflag = 1;
HeptaSatTraining2019 26:220e5f95168a 15 }
MEXT1 27:ecdf196153cd 16 //interrupting
MEXT1 27:ecdf196153cd 17 void receive(int rcmd, int cmdflag)
HeptaSatTraining2019 26:220e5f95168a 18 {
MEXT1 27:ecdf196153cd 19 gs.attach(commandget,Serial::RxIrq);
HeptaSatTraining2019 26:220e5f95168a 20 }
MEXT1 27:ecdf196153cd 21 //initialzing
HeptaSatTraining2019 26:220e5f95168a 22 void initialize()
HeptaSatTraining2019 26:220e5f95168a 23 {
HeptaSatTraining2019 26:220e5f95168a 24 rcmd = 0;
HeptaSatTraining2019 26:220e5f95168a 25 cmdflag = 0;
MEXT1 27:ecdf196153cd 26 cond[0] = 0;
HeptaSatTraining2019 26:220e5f95168a 27 }
MEXT1 27:ecdf196153cd 28
MEXT1 27:ecdf196153cd 29 int main() {
MEXT1 27:ecdf196153cd 30 gs.baud(9600);
MEXT1 27:ecdf196153cd 31 gs.printf("From Sat : Operation Start...\r\n");
MEXT1 27:ecdf196153cd 32 int flag = 0; // condition
MEXT1 27:ecdf196153cd 33 float sattime=0.0,btvol,temp; //Voltage, Temerature
MEXT1 27:ecdf196153cd 34 receive(rcmd,cmdflag); //interupting by ground station command
MEXT1 27:ecdf196153cd 35
MEXT1 27:ecdf196153cd 36 for(int i = 0; i < 100; i++) {
MEXT1 27:ecdf196153cd 37 //Sensing and Transmitting HK data
MEXT1 27:ecdf196153cd 38 eps.vol(&btvol);
MEXT1 27:ecdf196153cd 39 temp = 28.5;
MEXT1 27:ecdf196153cd 40 gs.printf("HEPTASAT::Condition = %d, Time = %f [s], batVol = %.2f [V],Temp = %.2f [C]\r\n",flag,sattime,btvol,temp);
MEXT1 27:ecdf196153cd 41 //Condition
MEXT1 27:ecdf196153cd 42 cond[0] = 1;
MEXT1 27:ecdf196153cd 43 //Power Saving Mode
MEXT1 27:ecdf196153cd 44 if(btvol <= 3.5) {
HeptaSatTraining2019 26:220e5f95168a 45 eps.shut_down_regulator();
HeptaSatTraining2019 26:220e5f95168a 46 flag = 1;
HeptaSatTraining2019 26:220e5f95168a 47 } else {
HeptaSatTraining2019 26:220e5f95168a 48 eps.turn_on_regulator();
HeptaSatTraining2019 26:220e5f95168a 49 flag = 0;
HeptaSatTraining2019 26:220e5f95168a 50 }
HeptaSatTraining2019 26:220e5f95168a 51 if(flag == 1) {
MEXT1 27:ecdf196153cd 52 gs.printf("Power saving mode ON\r\n");
HeptaSatTraining2019 26:220e5f95168a 53 }
MEXT1 27:ecdf196153cd 54 //Contents of command
HeptaSatTraining2019 26:220e5f95168a 55 if (cmdflag == 1) {
HeptaSatTraining2019 26:220e5f95168a 56 if (rcmd == 'a') {
MEXT1 27:ecdf196153cd 57 for(int j=0;j<5;j++){
MEXT1 27:ecdf196153cd 58 gs.printf("HEPTASAT::Hello World!\r\n");
MEXT1 27:ecdf196153cd 59 cond[0] = 0;
MEXT1 27:ecdf196153cd 60 wait(1);
MEXT1 27:ecdf196153cd 61 cond[0] = 1;
MEXT1 27:ecdf196153cd 62 }
HeptaSatTraining2019 26:220e5f95168a 63 }
HeptaSatTraining2019 26:220e5f95168a 64 initialize();
HeptaSatTraining2019 26:220e5f95168a 65 }
MEXT1 27:ecdf196153cd 66
MEXT1 27:ecdf196153cd 67 //Operation Interval
MEXT1 27:ecdf196153cd 68 wait(1.0);
MEXT1 27:ecdf196153cd 69 sattime = sattime+1.0;
HeptaSatTraining2019 24:3659e0c223c8 70 }
MEXT1 27:ecdf196153cd 71 gs.printf("From Sat : Operation Stop...\r\n");
umeume 2:1c5cdb2c3e0f 72 }