
gps like an odometer
Hi
I like make some like an odometer with GPS but I have some problems.
on my GPS I have for example: time and speed and I know witch distance = speed*time.
my problem stay on speed, because it don't is an constant, some one have an ideia to implement this?
best regards

Try this:
currentTime = GetCurrentTime()
diff = currentTime  lastTime
avgSpeed = (speed + lastSpeed) / 2
dist = time * avgSpeed
lastSpeed = speed
lastTime = currentTime

you can calculate distance from two point's for example each second you calculate distance from current point(longitude&latitude) and point which you use one second before...

Yeah  I was gonna say (CurrentDistance  LastDistance) / (CurrentTime  LastTime) is the average speed (in that time period).
And for average velocity (for the displacement minded) = (CurrentLatitudeLongitude  LastLatitudeLongitude) / (CurrentTime  LastTime); but you'll have to work out the distance between the LatLongs (straight line between the two)  probably easiest in Nautical the convert to miles or km (Wiki?).
And I'm not using any GPSspeak; just descriptives. And  = minus; / = divide.

No need for time, but adding distances between points has it's advantages and disadvantages. The GPS will give positions every second, but you can always reject a new point and keep your reference point to increment your odometer later. Rejecting spurious values will be the fun part. :)
The Earth is a big Pi LOL so it's not all that simple.
Theta = (pointA.Long  pointB.Long)
ToRad = 0.01745566
DistRad = acos( ( sin( pointA.Lat * ToRad ) * sin( pointB.Lat * ToRad ) ) +
( cos(pointA.Lat * ToRad ) * cos( pointB.Lat * ToRad ) * cos(Theta * ToRad )) )
NautMi = DistRad * 57.2881 * 60.0
KM = NautMi * 1.852
Mi = NautMi * 1.151

Bingo! I see the "cumulative" addition of distances (or is that successive... arrghh!).
I was thinking more of uPC etc programming where you might store initial, then store last whenever, and subtract. But that's from a speedo cable etc  not a GPS.
And keep those calcs away from me! I remember those damned ionosphere or strato calcs with heights and deviations from spherical to provide accurate bounce angles so we could figure out if the target was on Burlington or Dixie. I mean like 3,000km was its official range and this was what  6 times that?? Damned refractions and abnormalities.... (LOL!!)

Hi
thanks for all opinions...
I think some like Curiosity write on 1º reply, but with 4 seconds and 4 speed regist.
I will try make this project with an PIC (18f252).
I think witch don't need use Latitude and Longitude to calculate distance, this is much complex and I don't know if my MCU have memory to this :lol:
best regards, and one more time thank.