Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:45 29 Mar 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : How to convert GPS data to USEFUL data....

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9030
Posted: 06:54am 17 Jan 2020
Copy link to clipboard 
Print this post

Hi all.

I am having a horrible time, trying to decipher the data received from a GPS module, to actual USEFUL information.  The data supplied by the module is in an odd(to me) format.

It is not just in degrees, minutes and seconds, but several digits then a decimal point, then several more digits.

An example string I get back from the module is:



The manual says that: "Output format is ddmm.mmmmmm" for Latitude, and "dddmm.mmmmmm for Longitude".

dd is obviously degrees, mm is obviously minutes, but where are the seconds?

Manual says that the string returned is:



Can someone help me see the light with how to convert the data returned, into some kind of useful co-ordinates?  
Smoke makes things work. When the smoke gets out, it stops!
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 185
Posted: 08:12am 17 Jan 2020
Copy link to clipboard 
Print this post

Grogster

Do you know what the lat/long is at the point you have that setup, even approximately from Google maps?

Is it possible to get another location (again with co-ords from GMaps)?
Rob White
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8517
Posted: 08:31am 17 Jan 2020
Copy link to clipboard 
Print this post

Find the decimal place using INSTR. Then subtract 2 then VAL the string. This gives the minutes component.
minutes - INT(minutes) gives you the fractions of minutes,
multiply by 60 to give seconds
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 813
Posted: 08:33am 17 Jan 2020
Copy link to clipboard 
Print this post

Hi Grogster,

maybe this website is useful for you?

It seems she can convert to all sorts of formats...
At the bottom you will find your "ddmm.mmmmmm" format.

Frank
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1757
Posted: 08:39am 17 Jan 2020
Copy link to clipboard 
Print this post

I would have thought it was 45 deg 52.861773 min so the seconds would be 60*.861773
In Google Earth you can get the position in this format. Go to tools/options.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 639
Posted: 10:32am 17 Jan 2020
Copy link to clipboard 
Print this post

G'Day Grogster

Now we know exactly where you live
I have been using GPS receivers for some time and I am surprised that your speed is zero. Is that a fluke?
I find the speed is all over the place when stationary but the accuracy improves when moving. It's another thing I don't understand but I accept it.
Our house has been clocked at 2 km/hr.

Peter
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 369
Posted: 12:35pm 17 Jan 2020
Copy link to clipboard 
Print this post

If there a $GPRMC format output you can use instead, it might save you some hassle, there is code around to read it, and it will include a data-valid flag
 
goc30

Guru

Joined: 12/04/2017
Location: France
Posts: 425
Posted: 05:51pm 17 Jan 2020
Copy link to clipboard 
Print this post

  Grogster said  Hi all.

I am having a horrible time, trying to decipher the data received from a GPS module, to actual USEFUL information.  The data supplied by the module is in an odd(to me) format.

It is not just in degrees, minutes and seconds, but several digits then a decimal point, then several more digits.



I give you my prog to have date time with gps module on uart and PPs pin (1 top each second)
i have delete downlaod fonts for size of src, if you use an LCD you can install some fonts (see fonts num 4 and 6 in my prog)


Option EXPLICIT
Option autorun on
Const vvmaj=1
Const vvmin=1
Const vvsm=2

Const TRUE = 1
Const FALSE = 0
Const TypAff = 2

Const top1s=7   'pin for irq top 1sec

dim i2 as integer
Dim cvai As integer
Dim ci1 As integer
Dim ci2 As integer
dim ca$ as string
Dim car$ As string length 1
dim cn as integer
dim flgcn as integer
dim flgcn2 as integer
dim txn as string
dim txn2 as string
Dim txversion$ As string

Dim i As integer
Dim j As integer
Dim ptime1 As float
Dim ptime2 As float
Dim ptWrite As integer
Dim ptRead As integer
dim v1 as float
dim vtx$ as string
dim vstat as string length 1
Dim vledgps As integer

Dim vtimezoneh As integer
Dim vtimezonem As integer
Dim flghete As integer
Dim vhete As integer
Dim heure$ As string
Dim vheur As integer
Dim minut$ As string
Dim vminu As integer
Dim second$ As string
Dim vsecon As integer
Dim vmilli As integer
Dim vjour As integer
Dim vmois As integer
Dim van As integer
Dim validgps As integer  'mot d'etat gps (0= tous les defauts), bit 0=crc (1=pas de faut), bit 1= valide (1=valide)
Dim errgps As integer       'compteur d'erreurs

Dim txjour$ As string
Dim txmois$ As string
Dim txan$ As string
Dim txthgps As string
Dim txtdgps As string
Dim txtdgpst1 As string



backlight 20
txtdgps=""
txthgps=""
txjour$=Left$(Date$,2):vjour=Val(txjour$)
txmois$=Mid$(Date$,4,2):vmois=Val(txmois$)
txan$=Right$(Date$,2):van=Val(txan$)
txtdgps=txjour$+"/"+txmois$+"/"+txan$
'print "Date : ";txjour$;"/";txmois$;"/";txan$;
heure$=Left$(TIME$,2)
minut$=Mid$(TIME$,4,2)
second$=Right$(TIME$,2)
txthgps=heure$+":"+minut$+":"+second$

txversion$="-- Version "+Str$(vvmaj,2,0," ")+"."+Str$(vvmin,2,0,"0")+Chr$(vvsm+&h61)+" --"
CLS RGB(black)

Text 160,40,"CMI7",CM,1,2,RGB(CYAN),0
Text 160,105,txversion$,CM,1,1,RGB(White),0
Text 160,125,MM.device$,CM,1,1,RGB(White),0
Text 10,145,"LcdPanel "+MM.INFO$(LCDPANEL),LM,1,1,RGB(YELLOW),0
Text 319,145,"SdCard "+MM.INFO$(SDCARD),RM,1,1,RGB(YELLOW),0
Text 160,80,"Box GPS",CM,2,1,RGB(CYAN),0
Text 160,180," Initialisation ",CM,1,1,0,RGB(WHITE)
if txthgps="00:00:00" then
 Text 160,200," Timer internal Default",CM,1,1,RGB(YELLOW),0
else
 Text 160,200," Timer internal OK",CM,1,1,RGB(GREEN),0
end if
'CLS
Text 160,220,"Connect GPS",CM,1,1,RGB(White),0
txversion$="V"+Str$(vvmaj,2,0," ")+"."+Str$(vvmin,2,0,"0")+Chr$(vvsm+&h61)'+" ---"

i=0
vtimezonem=0
vtimezoneh=1  'on est en UTC + 1
flghete=0   'on est en heure d't
vhete=1     'donc +1h
'flgminu=0

Open "COM1:9600,1024,spcomrec4" As #2
ptWrite=0
ptRead=0
txthgps=""
pause(1500)
if txn="" then
 Text 160,220," GPS Default ",CM,1,1,RGB(YELLOW),0
else
 Text 160,220,"   GPS OK   ",CM,1,1,RGB(GREEN),0
 time$=heure$ + ":" + minut$ + ":" + second$
 
end if

pause(1000)
cls
print time$;" = ";heure$ ; ":" ; minut$ ; ":" ; second$
SetTick 1000, task1sec,1    ' tache de base a faire toutes les 10ms  utile pour eteindre led de signalisation
SetTick 10, taskled,2    ' tache de base a faire toutes les 10ms  utile pour eteindre led de signalisation

SetPin top1s, intL, itop1sec   'btn depart
box 0,0,319,20,1,rgb(blue),rgb(blue)
box 0,220,319,19,1,rgb(64,64,64),rgb(64,64,64)
Text 5,10,TIME$,LM,6,1,RGB(WHITE),RGB(BLUE)
Text 316,10,DATE$,RM,6,1,RGB(WHITE),RGB(BLUE)

'*****************************
Do
 'ptime1=Timer
 reccom
 'ptime2=Timer
 'If ptime2-ptime1>100 Then
 '  Print Time$;" ->";Str$((ptime2-ptime1)/1000,4,3)
 'End If
 pause(100)
Loop
'*****************************

sub reccom()
   if flgcn2=1 then  'if frame is ok and complete
     flgcn2=0
     vtx$=mid$(txn,8,6)
     vstat=mid$(txn,18,1)
     vheur=val(left$(vtx$,2))
     vminu=val(mid$(vtx$,3,2))
     vsecon=val(mid$(vtx$,5,2))
     vsecon=vsecon+1      'because top 1sec come before frame gps
     if vsecon=>60 then
       vsecon=vsecon-60
       vminu=vminu+1
     end if  
     vminu = vminu + vtimezonem    'add hour time zone
     If vminu=>60 Then
         vheur=vheur+1
         vminu=vminu-60
     End If
     vheur = vheur + vtimezoneh
     If flghete=1 Then vheur = vheur + vhete  'if summer/winter
     If vheur=>24 Then
       vheur=vheur-24
       vjour=vjour+1
     End If
     heure$=Str$(vheur,2,0,"0")
     minut$=Str$(vminu,2,0,"0")
     second$=Str$(vsecon,2,0,"0")
     txthgps= heure$ + ":" + minut$ + ":" + second$
     cn=0
     validgps=0
     if vstat="A" then validgps=2
     if vstat="V" then validgps=5
   end if
end sub

sub affgps()    'print on screen yime
 If (validgps And 2) =2 Then
   if TypAff = 2 then Text 20,120,txthgps,LM,4,1,RGB(Green),0
 Else
   If (validgps And 5) =5 Then
    if TypAff = 2 then  Text 20,120,Time$,LM,4,1,RGB(Yellow),0
   Else
    if TypAff = 2 then  Text 20,120,Time$,LM,4,1,RGB(RED),0
   End If
 End If
end sub

sub task1sec   'print date-time on top of screen (if use others functions)
Text 5,10,time$,LM,6,1,RGB(WHITE),RGB(BLUE)
end sub

sub itop1sec()    'irq PPS 1 second from gps module
 If ((validgps And 2) =2 and vsecon=3 and (vminu mod 10)=0) Then   'every 10 min time=gps
    time$=heure$ + ":" + minut$ + ":03"    'time$ = time from gps
    Text 5,10,time$,LM,6,1,RGB(WHITE),RGB(BLUE)
    Text 316,10,DATE$,RM,6,1,RGB(WHITE),RGB(BLUE)
 end if
 affgps
end sub


Sub spcomrec4    'ieq uart
 ci1=Loc(#2)
 If ci1>0 Then
   ca$=Input$(ci1,#2)  'rec 1 char
   for i2=1 to ci1
     car$=mid$(ca$,i2,1)
     cvai=Asc(car$)
     If cvai=36 Then  'if rec "$" then begin frame
       flgcn=1
       txn2=""
       cn=0
     End If
     if flgcn>0 then
       If (cvai=10) Then   'if end of frame and frame = RMC then frame is ok
         txn=txn2
         flgcn=3
         flgcn2=1
       Else
         If cvai>31 Then  
           txn2=txn2+car$   'add char in local buffer
           cn=cn+1
       End If
       if (cn=6 and txn2<>"$GPRMC") then  'flag rec not RMC then ignore all chars rec
         flgcn=0
       end if
     end if
   next i2  
 End If
End Sub

Edited 2020-01-18 03:59 by goc30
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1584
Posted: 10:26pm 17 Jan 2020
Copy link to clipboard 
Print this post

Grogster, I have not looked into it myself but have you looked at Geoff's Boat Computer?

Bill
Keep safe. Live long and prosper.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024