HEPTA-Sat in Bulgaria 0X This is program that sends command to the satellite from the Ground Station to save data to the SD card (measures magnetism and saves the coordinates of the measured area) and later on transmitt the data from the satellite to the Ground Station

Dependencies:   Hepta9axis HeptaBattery HeptaCamera_GPS HeptaTemp HeptaXbee SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
VicZl
Date:
Wed Nov 01 17:47:38 2017 +0000
Commit message:
HeptaSat training

Changed in this revision

Final_Magnetism_GPS/.hg_archival.txt Show annotated file Show diff for this revision Revisions of this file
Final_Magnetism_GPS/Hepta9axis.lib Show annotated file Show diff for this revision Revisions of this file
Final_Magnetism_GPS/HeptaBattery.lib Show annotated file Show diff for this revision Revisions of this file
Final_Magnetism_GPS/HeptaCamera_GPS.lib Show annotated file Show diff for this revision Revisions of this file
Final_Magnetism_GPS/HeptaTemp.lib Show annotated file Show diff for this revision Revisions of this file
Final_Magnetism_GPS/HeptaXbee.lib Show annotated file Show diff for this revision Revisions of this file
Final_Magnetism_GPS/SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
Final_Magnetism_GPS/main.cpp Show annotated file Show diff for this revision Revisions of this file
Final_Magnetism_GPS/mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/.hg_archival.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/.hg_archival.txt	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,5 @@
+repo: bdbd3d6fc5d5308c028049cfbd29473ed0fe6006
+node: 3daf572bcae1d1ecc05796fdba302f37ad4f651b
+branch: default
+latesttag: null
+latesttagdistance: 16
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/Hepta9axis.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/Hepta9axis.lib	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/HEPTA/code/Hepta9axis/#098423fb0371
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/HeptaBattery.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/HeptaBattery.lib	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/HEPTA/code/HeptaBattery/#15a6a4425889
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/HeptaCamera_GPS.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/HeptaCamera_GPS.lib	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/HEPTA/code/HeptaCamera_GPS/#e3ad89e65f66
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/HeptaTemp.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/HeptaTemp.lib	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/HEPTA/code/HeptaTemp/#96c3dd85be15
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/HeptaXbee.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/HeptaXbee.lib	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/HEPTA/code/HeptaXbee/#8e925f198e21
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/SDFileSystem.lib	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/main.cpp	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,91 @@
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "HeptaXbee.h"
+#include "Hepta9axis.h"
+#include "HeptaCamera_GPS.h"
+#include "HeptaTemp.h"
+#include "HeptaBattery.h"
+
+Serial pc(USBTX,USBRX);
+HeptaTemp temp(p17);;
+Hepta9axis n_axis(p28,p27,0xD0,0x18);
+HeptaCamera_GPS cam_gps(p13,p14,p25,p24);
+SDFileSystem sd(p5,p6,p7,p8,"sd");
+HeptaBattery battery(p16,p26);
+DigitalOut camera_switch(p25);
+DigitalOut gps_switch(p24);
+HeptaXbee xbee(p9,p10);
+
+int main(){
+    int rcmd=0,cmdflag=0,mflag;
+    xbee.baud(9600);
+    pc.baud(9600);
+    float bt;
+    float temper;
+    float mx,my,mz;
+    
+    //SD Card
+    char str[100];
+    mkdir("/sd/mydir", 0777);
+    
+    //camera_switch=0;
+    //gps_switch=1;
+    cam_gps.gps_setting();
+    int quality=0,stnum=0,gps_check=0;
+    char ns='A',ew='B',aunit='m';
+    float time=0.0,latitude=0.0,longtitude=0.0,hacu=0.0,altitude=0.0;
+    xbee.printf("Sensor Detection\r\n");
+    while(1){
+        //Detect H.K. Data
+        battery.vol(&bt);
+        temp.temp_sense(&temper);
+        xbee.printf("Vol=%f\r\n",bt);
+        xbee.printf("temp=%f\r\n",temper);
+        xbee.xbee_recieve(&rcmd,&cmdflag);
+        if(cmdflag==1){
+            if(rcmd=='a'){
+                pc.printf("Command Get %d\r\n",rcmd);
+                xbee.printf("HEPTA Uplink OK\r\n");
+                cam_gps.flushSerialBuffer();
+                FILE *fp = fopen("/sd/mydir/test.txt","w");
+                if(fp == NULL) {
+                    error("Could not open file for write\r\n");
+                }
+                mflag = 0;
+                for(int i=0;i<100;i++){
+                    n_axis.sen_mag(&mx,&my,&mz);
+                    cam_gps.gga_sensing(&time,&latitude,&ns,&longtitude,&ew,&quality,&stnum,&hacu,&altitude,&aunit,&gps_check);
+                    if((gps_check==0)|(gps_check==1)){
+                    //if(gps_check==1){
+                        pc.printf("lat=%f,long=%f\r\n",latitude,longtitude);
+                        fprintf(fp,"%d,%f,%f,%f,%f,%f\r\n",mflag,latitude,longtitude,mx,my,mz);
+                        pc.printf("mflag=%d\r\n",mflag);
+                        mflag++;
+                    }
+                    if(mflag==10){
+                        fclose(fp);
+                        break;  
+                    }
+                }
+            }
+            else if(rcmd=='b'){
+                //Transmit Saved Mission Data
+                pc.printf("Command Get %d\r\n",rcmd);
+                xbee.printf("HEPTA Uplink OK\r\n");
+                FILE *fp = fopen("/sd/mydir/test.txt","r");
+                if(fp == NULL) {
+                    error("Could not open file for write\r\n");
+                }
+                for(int i=0;i<10;i++){
+                    fgets(str,100,fp);
+                    xbee.puts(str);
+                }
+                fclose(fp);
+            }
+        xbee.initialize();
+        }
+                
+        wait(1.0);
+
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 03c474eacc58 Final_Magnetism_GPS/mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Final_Magnetism_GPS/mbed.bld	Wed Nov 01 17:47:38 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90
\ No newline at end of file