Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

NMEA Parser from GPS for 16f877A

Status
Not open for further replies.

r0nd0m

Newbie level 2
Joined
Oct 5, 2008
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Brazil - SC - Joinville
Activity points
1,299
Hello guys, I confess I should been here before cause now Im in a hurry...

I have a bunch of code for parsing NMEA sentences from a GPS module and calculate the distance between two points.

The problem is that I need accuracy of at least 5 meters and Im having 1,4km error...

I've been through this problem for about 4 months, and I noticed its all about float rounding. Im so stuck on this and cant avoid PIC of rounding my formula which causes that error.

Look, its not that hard, Im using the big circles method (spherical trigonometry but the formula is simple):

Code:
( acos( (cos(90-lat1)*cos(90-lat2)*cos(lon1-lon2)) + (sin(90-lat1)*sin(90-lat2) ) )*40.030/360;

I found the problem is when I try to take sin() and cos() at the very beginning. The numbers get rounded and the results are catastrophic.

I had to broke this formula in many pieces in a way PIC can process all of the variables without running dry of RAM. it's now like this:

Code:
(Ive already added some values extracted and converted into DEGREES from my NMEA sentence, the final result is supposed to be: 7.766,9078Km and it IS when I jump over the sin() cos() steps and make flutuante2 = 0.3444832 in fact, as I said, the problem seems to be on sin() cos() step.)

lat1 = 40.816667;
lat2 = -22.9;
lon1 = -73.966667;
lon2 = -43.166667;

dist_part1 = cos(lat1)*cos(lat2)*cos(lon2-lon1);
dist_part2 = sin(lat1)*sin(lat2);

flutuante2 = acos(dist_part1+dist_part2);
flutuante2 = (flutuante2*180)/pi;
distancia = (flutuante2*40.030)/360;

printf("\r\n\r\nDistancia ate o objetivo: %.4f",distancia*1000);

Can you guys help me?
Thanks in advance.
 

Hey there.
Its now working fine, I've fixed the errors and its accuracy is now about 5 meters.

But that isnt enough... The GPS module that I got already has a lack of precision of 5 meters, so it could result in 10 meters diference from the real position, what is very unreliable for my needs.

Im now looking for high precision floating point libraries. I've found some as the PICFLOAT or PICFLOW but both are for unix and I cant even open it (they are .tar and .tgz files).

Do you guys know any precision float.h for pic16f877a ?
Thanks
 

hi sir,
i have to read from the gps by the 16f877
could you help me in the code that will get the data from the gps
i need some help since i can not read from the gps
regards,
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top