for_20211114
Dependencies: HEPTA_SENSOR mbed HEPTA_EPS HEPTA_COM HEPTA_CDH
main.cpp
00001 #include "mbed.h" 00002 #include "HEPTA_CDH.h" 00003 #include "HEPTA_EPS.h" 00004 HEPTA_CDH cdh(p5, p6, p7, p8, "sd"); 00005 HEPTA_EPS eps(p16,p26); 00006 DigitalOut condition(LED1); 00007 Serial gs(USBTX,USBRX,9600); 00008 Timer sattime; 00009 int rcmd = 0, cmdflag = 0; //command variable 00010 00011 //getting command and flag 00012 void commandget() 00013 { 00014 rcmd = gs.getc(); 00015 cmdflag = 1; 00016 } 00017 //interrupting 00018 void receive(int rcmd, int cmdflag) 00019 { 00020 gs.attach(commandget,Serial::RxIrq); 00021 } 00022 //initialzing 00023 void initialize() 00024 { 00025 rcmd = 0; 00026 cmdflag = 0; 00027 condition = 0; 00028 } 00029 00030 int main() 00031 { 00032 gs.printf("From Sat : Operation Start...\r\n"); 00033 int flag = 0; // condition 00034 float batvol,temp; //Voltage, Temerature 00035 sattime.start(); 00036 receive(rcmd,cmdflag); //interupting by ground station command 00037 eps.turn_on_regulator();//turn on 3.3V conveter 00038 for(int i = 0; i < 100; i++) { 00039 //satellite condition led 00040 condition = !condition; 00041 00042 //senssing HK data(dummy data) 00043 eps.vol(&batvol); 00044 temp = 28.5; 00045 00046 //Transmitting HK data to Ground Station(GS) 00047 gs.printf("HEPTASAT::Condition = %d, Time = %f [s], batVol = %.2f [V],Temp = %.2f [C]\r\n",flag,sattime.read(),batvol,temp); 00048 wait_ms(1000); 00049 00050 //Power Saving Mode 00051 if(batvol <= 3.5){ 00052 eps.shut_down_regulator(); 00053 gs.printf("Power saving mode ON\r\n"); 00054 flag = 1; 00055 } else if((flag == 1) & (batvol > 3.7)) { 00056 eps.turn_on_regulator(); 00057 gs.printf("Power saving mode OFF\r\n"); 00058 flag = 0; 00059 } 00060 00061 if (cmdflag == 1) { 00062 if (rcmd == 'a') { 00063 for(int j=0;j<5;j++){ 00064 gs.printf("HEPTASAT::Hello World!\r\n"); 00065 condition = 1; 00066 wait_ms(1000); 00067 } 00068 }else if(rcmd == 'b') { 00069 00070 00071 00072 00073 } 00074 initialize(); 00075 } 00076 } 00077 sattime.stop(); 00078 gs.printf("From Sat : Operation Stop...\r\n"); 00079 }
Generated on Thu Jul 21 2022 00:19:44 by 1.7.2