Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 // Note!!!! This software is under a beerware license, 00002 // please send a beer to clarke.sam1@gmail.com 00003 // via paypal if you find this code useful. 00004 00005 00006 #include "Plan13.h" 00007 #include "GPS.h" 00008 #include "mbed.h" 00009 00010 #define ONEPPM 1.0e-6 00011 #define ONEPPTM 1.0e-7 00012 00013 struct Target{ 00014 int YEAR; 00015 float EPOCH; 00016 float INCLINATION; 00017 float RAAN; 00018 float ECCENTRICITY; 00019 float ARGUMENT_PEDIGREE; 00020 float MEAN_ANOMALY; 00021 float MEAN_MOTION; 00022 float TIME_MOTION_D; 00023 float EPOCH_ORBIT; 00024 float azimuth; 00025 float elevation; 00026 }; 00027 00028 char *astra2f_tle = 00029 "ASTRA 2F" 00030 "1 38778U 12051A 14010.00000000 .00000143 00000-0 00000+0 0 2381" 00031 "2 38778 000.0670 267.2510 0004011 341.2500 249.1500 01.00276604 4755"; 00032 00033 void target_tle(int year, char *tle, struct Target *t); 00034 00035 void calculate(Plan13& p, GPS& g, struct Target *t); 00036 00037 void target_data(int yr, float epoch, float inc, float raan, 00038 float ecc, float arg, float anom, float mmotion, 00039 float tmotion, float epoch_orbit, struct Target *t); 00040 00041 Plan13 p; 00042 GPS gps(p9,p10); 00043 Serial pc(USBTX, USBRX); 00044 00045 int main() 00046 { 00047 struct Target ASTRA2F; // Create a target object for ASTRA2F 00048 target_tle(2014, astra2f_tle, &ASTRA2F); // Parse a string TLE into the object, or set the object manually (below) 00049 00050 // NOAA 19 00051 //1 33591U 09005A 14018.50690348 .00000100 00000-0 79451-4 0 929 00052 //2 33591 098.9294 324.1290 0014157 178.0460 233.2637 14.11623746254876 00053 struct Target NOAA19; 00054 target_data(2014, 18.50690348, 98.9294, 324.1290, 79451, 00055 178.0460, 233.2637, 14.1162376, 0.00000100, 25487, &NOAA19); 00056 00057 gps.Init(); 00058 pc.baud(115200); 00059 while (1) 00060 { 00061 wait(1); 00062 if(gps.parseData()) { 00063 calculate(p, gps, &ASTRA2F); 00064 pc.printf("GPS Position--------[ %f, %f ]\n\n", gps.latitude, gps.longitude); 00065 pc.printf("ASTRA2F Azimuth-----[ %f ]\n", ASTRA2F.azimuth); 00066 pc.printf("ASTRA2F Elevation---[ %f ]\n\n", ASTRA2F.elevation); 00067 calculate(p, gps, &NOAA19); 00068 pc.printf("NOAA19 Azimuth -----[ %f ]\n", NOAA19.azimuth); 00069 pc.printf("NOAA19 Elevation----[ %f ]\n\n", NOAA19.elevation); 00070 }else { 00071 pc.printf("Aquiring Satellites...\n"); 00072 } 00073 } 00074 00075 } 00076 00077 void calculate(Plan13& p, GPS& g, struct Target *t ) 00078 { 00079 p.setTime(g.year,g.month,g.day,g.hours, g.minutes, g.seconds); //YMDHMS 00080 p.setElements(t->YEAR, 00081 t->EPOCH, 00082 t->INCLINATION, 00083 t->RAAN, 00084 t->ECCENTRICITY*ONEPPTM, 00085 t->ARGUMENT_PEDIGREE, 00086 t->MEAN_ANOMALY, 00087 t->MEAN_MOTION, 00088 t->TIME_MOTION_D, 00089 t->EPOCH_ORBIT+ONEPPM, 00090 0); 00091 p.setLocation(g.longitude,g.latitude,g.altitude); 00092 p.calculate(); 00093 t->azimuth = p.AZ; 00094 t->elevation = p.EL; 00095 } 00096 00097 void target_data(int yr, float epoch, float inc, float raan, 00098 float ecc, float arg, float anom, float mmotion, 00099 float tmotion, float epoch_orbit, struct Target *t) 00100 { 00101 t->YEAR = yr; 00102 t->EPOCH = epoch; 00103 t->INCLINATION = inc; 00104 t->RAAN = raan; 00105 t->ECCENTRICITY = ecc; 00106 t->ARGUMENT_PEDIGREE = arg; 00107 t->MEAN_ANOMALY = anom; 00108 t->MEAN_MOTION = mmotion; 00109 t->TIME_MOTION_D = tmotion; 00110 t->EPOCH_ORBIT = epoch_orbit; 00111 } 00112 00113 void target_tle(int year, char *tle, struct Target *t){ 00114 t->YEAR = year; 00115 sscanf(tle, 00116 "%*s %*s %*s %*s %*c%*c%*c%f %f %*s %f%*c%*c %*c %*s %*s %f %f " 00117 "%*s %f %f %f%*c%f", 00118 &t->EPOCH, &t->TIME_MOTION_D, &t->ECCENTRICITY, &t->INCLINATION, &t->RAAN, 00119 &t->ARGUMENT_PEDIGREE, &t->MEAN_ANOMALY, &t->MEAN_MOTION, &t->EPOCH_ORBIT); 00120 }
Generated on Wed Jul 13 2022 20:23:11 by
1.7.2