Lab3-05_create_satcode_step4_lite_Q
Dependencies: mbed HEPTA_CDH_lite HEPTA_EPS_lite
main.cpp
00001 #include "mbed.h" 00002 #include "HEPTA_EPS.h" 00003 #include "HEPTA_CDH.h" 00004 HEPTA_CDH cdh(PB_5, PB_4, PB_3, PA_8, "sd"); 00005 HEPTA_EPS eps(PA_0,PA_4); 00006 DigitalOut condition(PB_1); 00007 Serial gs(USBTX,USBRX,9600); 00008 Timer sattime; 00009 int rcmd = 0, cmdflag = 0; //command variable 00010 00011 //getting command and command flag 00012 void commandget() 00013 { 00014 rcmd = gs.getc(); 00015 cmdflag = 1; 00016 } 00017 //interrupting process by command receive 00018 void receive(int rcmd, int cmdflag) 00019 { 00020 gs.attach(commandget,Serial::RxIrq); 00021 } 00022 //initializing 00023 void initialize() 00024 { 00025 rcmd = 0; 00026 cmdflag = 0; 00027 condition = 0; 00028 } 00029 00030 int main() 00031 { 00032 gs.printf("From Sat : Nominal Operation\r\n"); 00033 int flag = 0; //condition flag 00034 float batvol, temp; //voltage, temperature 00035 sattime.start(); 00036 receive(rcmd,cmdflag); //interrupting 00037 eps.turn_on_regulator();//turn on 3.3V conveter 00038 for(int i=0;i<50;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 [deg 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("Hello World!\r\n"); 00065 condition = 1; 00066 wait_ms(1000); 00067 } 00068 }else if(rcmd == 'b') { 00069 00070 00071 00072 00073 } 00074 initialize(); //initializing 00075 } 00076 } 00077 sattime.stop(); 00078 gs.printf("From Sat : End of operation\r\n"); 00079 }
Generated on Sat Jul 30 2022 07:44:09 by
1.7.2