GPS Distance Problem

Georg

Member
Licensed User
Longtime User
Hello,

i'd like to check the distance with GPS Modul. I use some functions from GPS4PPC.sbp and modified it. P.E.

Sub Timer1_Tick
stat = GPS1.Status
If Serial1.InBufferCount > 0 Then
Label2.Text = "GPS is connected."
GPS1.GPSStream(Serial1.InputString)
north = GPS1.LatitudeHemisphere
If checkdis < 1 Then
If north = "n" Then
n = true
Else
n = false
End If
n = true
n = true
vlat = GPS1.Latitude
vlot = GPS1.Longitude
End If
checkdis = checkdis +1
If checkdis = 5 Then
distanz
checkdis = 0
End If
counter = 0
Else
counter = counter + 1
If counter >= 5 Then 'After 5 seconds without any data we will try to make a new connection.
counter = 0
Timer1.Enabled = false
Serial1.PortOpen = false
Label2.Text = "No connection."
GPS1.GPSBuffer = ""
If Msgbox("GPS was disconnected." & crlf & "Do you want to reconnect?","",cMsgboxYesNo) = cYes Then
mnuConnect_Click 'Try to reconnect.
End If
End If
End If
End Sub

Sub distanz
If Gps1.SpeedOverGround * umrech >5 Then
n = true
LL() = Converter.UTMToLatLon(6378137,1/298.257223563,33,vlat,n,vlot)
lat1 = LL.Lat
lon1 = LL.Lon

LL() = Converter.UTMToLatLon(6378137,1/298.257223563,33,GPS1.Latitude,n,GPS1.Longitude)
Distance_Course(lat1,lon1,LL.Lat,LL.Lon)

dis() = res()
di = (dis.Distance * 1.852 + da)
dia= Round(di ,2)
label5.Text = dia
da = dia
End If

End Sub

But i get creazy results. If i multiplicate di with 1000 then the distance is around the true distance but only around. What' wrong?

Georg
 

Georg

Member
Licensed User
Longtime User
It does not work to calculate the distanc with Lat/Lon during the drive, to much diverence. I made it on this way and it works fine

Sub distanz
If Gps1.SpeedOverGround * umrech >= 4 Then
sek = sek +1
da =da + (Gps1.SpeedOverGround * umrech/3600)
di = Round(da,2)
If di > 0 Then
label8.Text = Round(da*3600/sek,2) & " Km/h"
End If
label9.Text = di & " Km"
If sek/3600 > 1 Then
h = Round(sek/3600,0)
m = (sek -(h*3600))/60
Else
h = 0
m = Round(sek/60,0)
End If
label14.Text = h & " h " & m & " min"
End If

End Sub

called by Timer

umrech value of miles or Km

perhaps it helps some other one

Georg
 

Georg

Member
Licensed User
Longtime User
Hi John,

thank you. That is exactly what i searching for. It works very well. You are right with GPS.SpeedOverGround > 2. But sometimes the Speed on my Devise runs up to 6 and 7 Km/h without moving. Perhaps the problem is, that in germany all the things are more nervous.

Georg
 
Top