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.
Diff: main.cpp
- Revision:
- 2:735bdcc06386
- Parent:
- 1:ab43ae956815
- Child:
- 3:e7cebcde3db7
--- a/main.cpp Sun Jan 19 08:44:45 2014 +0000 +++ b/main.cpp Mon Jan 20 10:02:57 2014 +0000 @@ -9,6 +9,18 @@ #define ONEPPM 1.0e-6 #define ONEPPTM 1.0e-7 +char *astra2f_tle = + "ASTRA 2F" + "1 38778U 12051A 14010.00000000 .00000143 00000-0 00000+0 0 2381" + "2 38778 000.0670 267.2510 0004011 341.2500 249.1500 01.00276604 4755"; + +void target_tle(int year, char *tle, struct Target *t); + +void calculate(Plan13& p, GPS& g, struct Target *t); + +void target_data(int yr, float epoch, float inc, float raan, + float ecc, float arg, float anom, float mmotion, + float tmotion, float epoch_orbit, struct Target *t); struct Target{ int YEAR; float EPOCH; @@ -24,30 +36,22 @@ float elevation; }; -void target_tle(int yr, float epoch, float inc, float raan, - float ecc, float arg, float anom, float mmotion, - float tmotion, float epoch_orbit, struct Target *t); - -void calculate(Plan13& p, GPS& g, struct Target *t); - +Plan13 p; +GPS gps(p9,p10); Serial pc(USBTX, USBRX); -GPS gps(p9,p10); -Plan13 p; int main() { - // ASTRA 2F - //1 38778U 12051A 14010.00000000 .00000143 00000-0 00000+0 0 2381 - //2 38778 000.0670 267.2510 0004011 341.2500 249.1500 01.00276604 4755 - struct Target ASTRA2F; - target_tle(2014, 10.00000000, 000.0670, 267.2510, 0, - 341.2500, 249.1500, 1.0027660, 0.00000143, 4755, &ASTRA2F); + struct Target ASTRA2F; // Create a target object for ASTRA2F + target_tle(2014, astra2f_tle, &ASTRA2F); // Parse a string TLE into the object, or set the object manually (below) + // NOAA 19 //1 33591U 09005A 14018.50690348 .00000100 00000-0 79451-4 0 929 //2 33591 098.9294 324.1290 0014157 178.0460 233.2637 14.11623746254876 struct Target NOAA19; - target_tle(2014, 18.50690348, 98.9294, 324.1290, 79451, - 178.0460, 233.2637, 14.1162376, 0.00000100, 25487, &NOAA19); + target_data(2014, 18.50690348, 98.9294, 324.1290, 79451, + 178.0460, 233.2637, 14.1162376, 0.00000100, 25487, &NOAA19); + gps.Init(); pc.baud(115200); while (1) @@ -55,12 +59,12 @@ wait(1); if(gps.parseData()) { calculate(p, gps, &ASTRA2F); - pc.printf("GPS Position = %f, %f\n\n", gps.latitude, gps.longitude); - pc.printf("ASTRA2F Azimuth = %f\n", ASTRA2F.azimuth); - pc.printf("ASTRA2F Elevation = %f\n", ASTRA2F.elevation); + pc.printf("GPS Position--------[ %f, %f ]\n\n", gps.latitude, gps.longitude); + pc.printf("ASTRA2F Azimuth-----[ %f ]\n", ASTRA2F.azimuth); + pc.printf("ASTRA2F Elevation---[ %f ]\n\n", ASTRA2F.elevation); calculate(p, gps, &NOAA19); - pc.printf("NOAA19 Azimuth = %f\n", NOAA19.azimuth); - pc.printf("NOAA19 Elevation = %f\n\n", NOAA19.elevation); + pc.printf("NOAA19 Azimuth -----[ %f ]\n", NOAA19.azimuth); + pc.printf("NOAA19 Elevation----[ %f ]\n\n", NOAA19.elevation); }else { pc.printf("Aquiring Satellites...\n"); } @@ -88,7 +92,16 @@ t->elevation = p.EL; } -void target_tle(int yr, float epoch, float inc, float raan, +void target_tle(int year, char *tle, struct Target *t){ + t->YEAR = year; + sscanf(tle, + "%*s %*s %*s %*s %*c%*c%*c%f %f %*s %f%*c%*c %*c %*s %*s %f %f " + "%*s %f %f %f%*c%f", + &t->EPOCH, &t->TIME_MOTION_D, &t->ECCENTRICITY, &t->INCLINATION, &t->RAAN, + &t->ARGUMENT_PEDIGREE, &t->MEAN_ANOMALY, &t->MEAN_MOTION, &t->EPOCH_ORBIT); +} + +void target_data(int yr, float epoch, float inc, float raan, float ecc, float arg, float anom, float mmotion, float tmotion, float epoch_orbit, struct Target *t) {