Here is the part that corrects for the length of longitude, as latitude increases. This was written for the PIC16, and was used in addition to above code.
Code:do_cordic: Z_ = lathome_hi 'input whole # latitude 37.xxx for longitude 'correction (lon smaller at higher latitude) in Z_ for calcs i = Z_ * 128 / 45 '256 / 90 'changes Z_ to the right format if (Z_*128)//45 >= 23 then i = i +1 'round number if remainder is =>0.5 Z_ = i 'put result in Z_ call sincos 'get cos(Z_) and sin(Z_) i = X_ * lon_dif ' lon_ratio = cos(lat_current) lon_dif = div32 10000 'get lon_dif * the fraction for lon correction X_ = lon_dif 'load new lon_dif into X_ , prepare for ATAN function Y_ = lat_dif 'load lat_dif into Y_ , prepare for ATAN function call atan 'perform ATAN assembly function get angle of coordinates. b2dest = Z_ * 225 '*900 / 256 = 225/64 b2dest = div32 64 'puts angle in degrees into the variable in dd.d




Bookmarks