radians to degrees

<< < (4/5) > >>

clive:
Code:

; garmasm.asm
; ml -coff -Fl garmasm.asm \masm32\lib\msvcrt.lib -link /SUBSYSTEM:CONSOLE

        .486
        .MODEL FLAT, C
        .DATA

    c_msvcrt typedef PROTO C :VARARG

    externdef _imp__printf:PTR c_msvcrt
    crt_printf equ <_imp__printf>

Rec33   STRUC

GarminRecord            DB      ?
GarminLength            DB      ?

Altitude                REAL4   ?
ErrorPosition           REAL4   ?
ErrorHoriziontal        REAL4   ?
ErrorVertical           REAL4   ?

FixType                 DW      ?

GPSTimeOfWeek           REAL8   ?

Latitude                REAL8   ?
Longitude               REAL8   ?

VelocityLongitude       REAL4   ?
VelocityLatitude        REAL4   ?
VelocityVertical        REAL4   ?
MeanSeaLevelHeight      REAL4   ?

LeapSeconds             DW      ?
GarminDays              DD      ? ; Since GPS Week 521

Rec33   ENDS

Example db      033h,040h,017h,045h,03Fh,043h,0BFh,0EDh,92h,041h,058h,044h,01Bh,041h,0F8h,07Ch
        db      079h,041h,003h,000h,035h,039h,0FFh,0FFh,43h,049h,014h,041h,06Eh,033h,030h,0EAh
        db      03Fh,058h,0E7h,03Fh,072h,0D7h,044h,046h,60h,0A6h,0F8h,0BFh,0E0h,035h,040h,0BCh
        db      0CEh,02Fh,015h,0BCh,0B8h,028h,04Ah,03Bh,30h,0C6h,008h,042h,00Eh,000h,024h,01Ah
        db      000h,000h

rad2deg REAL8   57.2957795130823208767
answer  REAL8   ?
outdbl  db      "%14.10lf",10,13,0

        .CODE

start:
                lea     esi,Example

                fld     Rec33.Latitude[esi]
                fmul    rad2deg
                fstp    answer

                invoke  crt_printf, addr outdbl, answer

                fld     Rec33.Longitude[esi]
                fmul    rad2deg
                fstp    answer

                invoke  crt_printf, addr outdbl, answer

                ret

        END     start


Code:

41.7985697322
-88.2709756051

This is decimal degrees, not the DDDMM.mmmm format used by NMEA

The 80-bit version codes like this, but the printf doesn't support it (%Lf)
Code:

rad2deg REAL10  57.2957795130823208767
answer  REAL10   ?

                fld     Rec33.Latitude[esi]
                fld     rad2deg
                fmulp   st(1),st(0)
                fstp    answer


Technically that is probably overkill, as the value of PI used by GPS receivers should be 3.1415926535898, as defined in the ICD-200 interface control document. I was thinking more of a general radian/degree conversion when the question was initially posed.

Also 32-bit Microsoft C/C++ has both double and long double as 64-bit. The older DOS versions long double was 80-bit. Some more profession compilers and things like FORTRAN (REAL*10) can support 80-bit. The 80x87 intrinsically supports it.

someone:
ok, the problem here is that i don't have the library msvcrt.lib
what function exactly is crt_printf in the dll, using Dependency Walker i can't find crt_printf or _imp__printf

clive:
MSVCRT.DLL (\WINDOWS\SYSTEM32)

Code:

Exp Addr Hint   Ord Export Name by msvcrt.dll - Sun Apr 13 11:41:06 2008
-------- ---- ----- ---------------------------------------------------------
0003186A  2E5   742 printf

__imp__printf is a linker mechanism for pulling it in. If you have some other method for printing floats/doubles you could use that.

Download MASM32 if you need the libraries. http://www.masm32.com/masmdl.htm

vanjast:
A thought...
May I suggest you do not waste your time with Garmin and move onto the cheaper GPSs, like TomTom..etc.
Garmin is 2x or 3x the price of the others (where I am at least) so probably has a very limited lifespan.

clive:
The unit in question is an OEM puck antenna implementation, not a dash mount. Plus the poster is pulling raw PVT (Position,Velocity,Time) as a single binary message instead of a couple of $GPxxx NMEA sentences. This is a lot more efficient, and usually provides lat,lon,alt with more precision. Certainly the eTrex I have can push NMEA, or propriety raw data, but I can't say I was impressed with it's accuracy, quality of raw data, or it's MGRS conversion.

I'd probably pick up a $20 USB device which I could program to get 10 Hz raw measurements, and PVT solutions.

Navigation

[0] Message Index

[#] Next page

[*] Previous page