After some testing of the navigation code I had (a more accurate version of 18beta). I found a couple things. It was pretty accurate (within about two or three degrees 95% of the time). But there were some areas that confused my approximation routine. Some of these areas could be off by as much as 18 degrees. This bugged me enough to buy a C assembler program, which can do higher math, but it turns out I don't think I need to use it.
I have found an application note that describes how to perform trig on a PIC16 device. It uses a cordic formula to determine the angle to a waypoint! This is from microchip, and located at: http://ww1.microchip...otes/01061A.pdf
I have been able to port it to assembly that PicBasic can handle (at least for the ATAN function, I am still working on getting the Cos(x) part of it working). This is a very cool function! It takes a value of x and y, and spits out the angle to the waypoint. To solve for longitude being different lengths at different latitudes, you use Cos(lat_current) * longitude difference (just like my division table attempted, but this time I will do it with higher precision). This will give you a certain percentage of the longitude difference. x= the new fraction of longitude difference (about 80% of its original value for 37 degrees north lat) and y = latitude difference between waypoints. So, just plug these into the assembly routine, and you get the angle to the location. You do need to tweak the angle depending on which quadrant the destination point lies, just like my earlier code did.
Anyway, the cordic function simplifies the way the pic determines the angle, and is performed very, very fast. I counted over 2000 times a second for waypoints located about 80 miles apart. And the code space is minimal. So I am going to integrate this new code with the RCAP to get results within a degree ... ahem ... for 100 percent of the time.
Edited by radiohound, 17 November 2007 - 08:38 AM.