Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 13:10 04 May 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 : GPS speed and distance calculations

     Page 1 of 3    
Author Message
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 10:38am 01 Sep 2011
Copy link to clipboard 
Print this post

Howdy.
Recently I built a GPS to pulse train converter for driving an electronic odometer/speedometer in a car. It's done using a PIC32795 and EM-406 Globalsat GPS module. The PIC reads the serial data from the GPS (VTG specifically) to get current speed, and calculates a base frequency for the 32bit timer pair and an output capture module to generate a pulse train that suits the input to the odometer.

Question is, what is likely to be more accurate for distance measurement? 1) using the GPS calculated speed (provided by the globalsat module to 1 decimal place), or 2) Calculating the distance between each 1 second sample of data using the lat/long.

1 Is reasonably easy. I currently convert the km/h to m/s, then divide the 32-bit timer's operation frequency by the speed in m/s to get the required PR2 value that then creates the pulse train of desired frequency for the output. Any speed below 3.6km/hr is ignored as even when stationary the GPS 'wobble' creates a small error above zero.

2 Sounds a lot harder, in that the calculations are much more complex to get the distance between two sequential samples, convert to speed and apply to the timer. Would there be a noticeable gain in accuracy? - given that the GPS is probably already doing most of this calculation to derive the speed output.

Thinking out loud, the challenges for accuracy using the GPS method versus using a pulse generator attached to the vehicle driveline mostly arise from the 1 second between GPS samples. The benefit is that installation into any vehicle is easy.

I figure that the GPS speed data would represent the average speed over 1 second. (I could be wrong if anyone knows NEMA GPS data better) It should be most accurate when driving at a constant speed in a straight line. Accelerating and decelerating and tight corners are where the error would creep in.

The point to point data would still include any 'straight lining' of the actual course over 1 second (tight corners being cut-off), and the resulting calculated speed still an average over the said course in that same second (accel and decel errors).

Out of interest, a journey to TAFE this morning recorded 13.78km on the GPS odometer, 13.92 on the other odometer that uses a vehicle speed sensor as the pulse generator, and google maps shows the journey as 13.9km.

Any insight or random thoughts?

Ben

 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 03:38am 02 Sep 2011
Copy link to clipboard 
Print this post

Hi Ben

just some quick info ....

What happens when you are not on flat ground ... you may need an inclinometer or altimeter to get more accuracy in distance travelled. Does the GPS use software to calculate the difference in heights between each second averaging? 3D calculations!

My understanding is that most domestic GPS speed and distance calculations are based on the ground speed on the ellipsoid of the GPS datum using information from the GPS satellite data. The more satellites being received the greater the accuracy in the calculations.

The end result is that the GPS software may be doing it's calculations thinking that you are travelling on a nice smooth ellipsoid at a constant altitude or 2D!

If you travel at a constant speed on level ground then reduced problems but the quicker you accelerate or decelerate the greater the update delays between the GPS calculated average ground speed/distance and the (almost) instantaneous vehicle speedo.

Speedo inaccuracy is best checked using constant speed and level ground with many individual measurements at constant speed and distance combined with a known relative GPS accuracy.

some light reading on most things GPS

http://gpsinformation.net/

Keith
The more we know, the more we know we don't know !
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 03:59am 02 Sep 2011
Copy link to clipboard 
Print this post

Keith, Didn't really think of un-flat terrain. I can't imagine there being an easy way to find out if the Globalsat module calculates speed in 3D or not.

The module does provide altitude figure in the data stream though. 3D calculations would add an extra layer of complexity - for a gain in accuracy i'm not sure would be worth it. After all how steep a hill can you go up in 1 second? And at say 1000m above sea level, how much longer surface distance would you have travelled compared to sea level between the same two datum points? (I know i could calculate it to find out - maybe later it is Friday after all!)

Ben
 
Xiongmao

Regular Member

Joined: 25/08/2011
Location: Australia
Posts: 48
Posted: 08:12am 02 Sep 2011
Copy link to clipboard 
Print this post

The "left-field" solution may be to use a GPS module that updates faster than once a second. I believe there are modules with 10 measurements per second or higher. I imagine the vector of a road car isn't going to change much in 100mS.
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 01:36pm 04 Sep 2011
Copy link to clipboard 
Print this post

I don't know how you can get a reading faster than 1/second. The NMEA string from the satellites only comes once per second, unless there is a military system you can hook into.
Talbit
 
rhamer
Senior Member

Joined: 06/06/2011
Location: Australia
Posts: 174
Posted: 10:33pm 04 Sep 2011
Copy link to clipboard 
Print this post

  Talbit said   I don't know how you can get a reading faster than 1/second. The NMEA string from the satellites only comes once per second, unless there is a military system you can hook into.


You can get GPS receivers that will provide data at almost any speed, the issue is how fast the comms between the receiver and processing device is.

Also NMEA is just one format that some receivers have available as an output, it is not what is sent from the satelites. The receivers are constantly calculating their position etc and just choose to output that information in a particular format and at a particular speed. I suspect (without knowing) that the NMEA navigation standard is what specifies the update rate of 1/sec.

I havent done much with GPS for a while, but in the early days we had units that output their own binary standard as fast as we could poll them. In practice we limited it to about 1/sec.

Cheers

Rohan
Rohan Hamer
HAMFIELD Software & Hardware Solutions

Makers of the Maximite Expander.

http://www.hamfield.com.au
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 11:47am 05 Sep 2011
Copy link to clipboard 
Print this post

Tne Globalsat GPS is capable of SiRF Binary as well as NEMA. I'm yet to look at the SiRF protocol to see if there's any advantage.

No real spped issues with the PIC32 and processing, after all at this stage i'm only grabbing the GPS speed data.

I have tweaked the frequency output calcs and got the result to be within 10m over about 20km when driving on road. But things get inaccurate quickly when the roads turn to twisty dirt!!!
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 03:02am 06 Sep 2011
Copy link to clipboard 
Print this post

Ben

When you say things get inaccurate with twisty dirt, what are you comparing accuracy with?

A vehicle speedo with the input from the drive train to the driven wheels will always be far more inaccurate due to wheel slip (ie wheel spin). The sensor needs to be on an undriven wheel.

The GPS info will be inaccurate with speed because of the one second calculations and the amount of twisting and also the possible reduction in the number of satellites being received ie try an external high gain antenna/receiver if the road is in a hilly and/or forested area. But regardless even walking in these types of terrain will result in reception drop out and then it will rely on the firmware? as to how quickly it recovers ... some GPS receivers are better at this then others.

If the vehicle has ABS then you may be able to use one of the ABS wheel sensors but you will have reduced luck with 4X4 as all wheels are driven (all depends on the amount of slip).

To confirm the GPS situation with the 1 second timing and speed on a road ... use the track log from a GPS and you will see what I mean especially if you overlay it on a map eg Google maps and zoom in.

Keith
The more we know, the more we know we don't know !
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 03:30am 06 Sep 2011
Copy link to clipboard 
Print this post

Ben

An additional point to consider is that you need to average 2 (hopefully undriven) from opposite sides of the vehicle.

As an example ... if you are driving up a long winding road (20km) to the top of a mountain with mostly left hand corners then right hand corners and you only use a sensor on the outside wheel then it will be travelling a greater distance then the inside wheel or the centre line of the vehicle! Put the GPS unit on the outside and you will conceivably get the same result.

Keith
The more we know, the more we know we don't know !
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 07:41am 06 Sep 2011
Copy link to clipboard 
Print this post

Keith, I'm comparing to an electronic tripmeter that is currently sensing off the gearbox mounted VSS. Whilst they are driven wheels, no deliberate wheel slip was being employed at the time, and being a gearbox probe will average the two rear wheels.

The test course on dirt was around 2km, with the GPS tripmeter recording around 200 to 400m less than the traditional tripmeter.

On the same day, on the tarmac drive out to the test track, the GPS tripmeter was only 10m behind the traditional tripmeter. Both have 10m resolution.

I'm confident that the increased error on the dirt is largely due to the 1 sec sample period. Lots of cornering, acceleration and deceleration when compared to the tarmac drive to casue trouble. When time permits, i'll check out the SiRF protocol to see if it's faster.
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 04:32am 07 Sep 2011
Copy link to clipboard 
Print this post

Ben

Sounds pretty typical from my past experience.

The differences can be weird on dirt to say the least. It all depends on the distance between the intermediate reference/turn points. The greater the distance the greater the potential for error. Then the number of corners, road surface, types of tyres and horsepower/torque can throw all sorts of slip errors. You don't even have to be driving competitively.

For rally type driving conditions, I consider GPS with good satellite reception to be very good for position information (especially if stationary or moving slowly).

Non-driven wheel distances are far superior compared to the distances from the ones that slip.

A large percentage of rally competitors use Terratrip computers with a probe on a non-driven wheel. These have a resolution of 1 metre.

Here is an interesting system for dead reckoning ... http://www.u-blox.com/en/dead-reckoning.html ... maybe this is what you are aiming for with a Maximite?

I'll be interested in how you go ... so please keep us updated.

Keith


The more we know, the more we know we don't know !
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 11:38am 07 Sep 2011
Copy link to clipboard 
Print this post

Looked at the SiRF protocol tonight, still only a 1Hz output.
Seems that the GPS satellites send data out at 2Hz intervals, so I can't imagine any GPS modules being available that would be faster than this.

Might have to resort to some clever manipulation of the data, maybe some averaging etc etc. Suppose i could supplement the GPS with a Gyro!! It is interesting to see the change is GPS speed v's vehicle speed on some of the tighter bends on-road. Might have to set up some data logging of the GPS output v's a wheel sensor.

Not many terratrips with 1m resolution that I've seen, Coralba maybe?

Ben
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 12:41am 08 Sep 2011
Copy link to clipboard 
Print this post

Ben

Sorry if I am telling you info that you may already know ... it is also for everyone who may read this forum.

The minimum wheel driven resolution is derived from the number of pulses per revolution divided into the rolling circumference you won't necessarily see this degree of resolution displayed as it would be unreadable at speed.

The down side is the maximum frequency that the sensor/device can reliably handle.

Inaccuracy in the GPS system was purposely inbuilt even though they improved the resolution for the public from the early days. The military most likely have a higher resolution and better equipment that for example rejects multipath signals to the receiver and less noise in the electronics etc.

Keith


The more we know, the more we know we don't know !
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 11:32am 13 Sep 2011
Copy link to clipboard 
Print this post

Tis OK Keith, just a different use of the term resolution at my end. I would consider the resolution of the tripmeter to be equal to the smallest increment it can display, where as it's accuracy would be a function of the number of pulses per revolution supplied to the internal divider. eg, a terratrip with 10m display resolution could have an accuracy of 1m if at least 10 pulses per 10m are provided.

The dead reckoning link you supplied earlier is interesting, I think I am trying to achieve the exact opposite - I'm after some good accuracy from the GPS without adding the road position and other sensors to the system.

I'm going to have a go at calculating an arc length based on the GPS heading at the start and end of any given pair of samples and apply this to correct the GPS calculated speed between the same two points. I'm assuming that the vehicle is travelling in a consistent arc between two samples which admittedly is not correct, but it may yield a better approximation than the straight line used now - especially on tight twisty dirt stuff. Some excel calculations tonight suggest that applying such a correction to measurements with a change of direction greater than 30 degrees, up to 180 degrees could make quite a difference.
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 10:00am 18 Sep 2011
Copy link to clipboard 
Print this post

Well, did some more dirt driving today. With the arc correction I got the error down to about 10% over about 2 km. Heaps better than before, but still room for improvement.

Seems to be some delay in the GPS's heading calcuations though as the corrections are still being applied a couple of samples after the tighter corners.

I've got a feeling that the GPS speed is also a bit non-linear. The on-road accuracy is pretty good at 60-70kph, a bit short below and at highway speeeds it goes over. Will have to set up some frequency comparisons between the GPS pulse train and the wheel sensor to see what's happening.
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 12:04pm 18 Sep 2011
Copy link to clipboard 
Print this post

Keep going Ben

I'm still with you on this one!

And yes I have noticed the delays with different GPS units. I have been well past a corner before the units indicate that I'm at the corner. Some times this is because the unit may be navigating me around the corner and I choose to ignore and go straight ahead.

Mostly I find they are just too slow to respond the faster I go .. I wouldn't rely on one to navigate my way in thick fog or dust at any speed.

I have checked some of my tracks against the vector graphics used in mapping and have observed various irregularities such as the track truncating corners at speed which if I walk the same road it will show a far closer track with the vector. Some of the vectors are so far out of alignment with the actual road it's not funny but that's a different story.

I don't use the lock to road option when doing these checks so I have also observed the track being no where near the vector - being some 20+ meters away. If I walk the same road it will approximate the vector. I use this to confirm the road alignment with the vector which is supposed to be the center line of the road.

Using the track overlaid on satellite mapping doesn't improve the situation.

I have put this down to better reception and more time to respond with the unit outside the vehicle at walking speed. Mainly using various Garmin units and a Navman ... I have even had 2 identical Garmin units side by side giving different readings?


Keith
The more we know, the more we know we don't know !
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 11:55am 22 Sep 2011
Copy link to clipboard 
Print this post

Turns out the GPS heading is calculated the same way as the speed, by calculating the difference between the last 2 samples, so you end up with a bearing that represents your heading from one sample to the next, not quite what i need for good arc correction. Looks like I'll have to venture into Differential GPS calculations based on 2 modules, a fixed distance apart in the car at 90degrees to the car's axis. Using DGPS, i can calculate the actual direction the car is facing at any given sample. Lucky i have a few GPS modules lying around!
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 01:37am 25 Sep 2011
Copy link to clipboard 
Print this post

Hey Ben

DGPS that's a quantum leap.

I was thinking about the problems with accuracy and it raised a question ...

Does the speed and distance relate back to the datum spheroid? I.E. If you are in an aircraft at 10,000m .... is your speed/distance calculated at the larger spheroid of your height or the speed/distance projected onto the 0.00m smaller spheroid?

Keith
The more we know, the more we know we don't know !
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 03:40am 25 Sep 2011
Copy link to clipboard 
Print this post

Hi

some light reading ... http://en.wikipedia.org/wiki/GPS_augmentation

Keith
The more we know, the more we know we don't know !
 
trippyben

Regular Member

Joined: 26/06/2011
Location: Australia
Posts: 91
Posted: 11:35am 26 Sep 2011
Copy link to clipboard 
Print this post

Not sure about the datum spheroid size. The GPS module datasheet doesn't provide that much info.

WAAS is not available in Australia, so that doesn't help either.

The Wheel sensor to GPS frequency comparisons are interesting. IF you manage to drive at constant speed, the 2 signals agree closely. It is interesting just how difficult it is to maintain a constant speed.

During acceleleration, the GPS frequency lags the wheel sensor, and decel is opposite. Much as expected due to the 1 sec update from the GPS module.

I'm not yet ready to go with DGPS, I'm not sure the market exists, but the experimenting thus far is good fun. I could also achieve the heading info using an electronic compass module, but the cost is significantly more for a module that handles tilting etc.

I've not come across any modules that provide a faster output than the typical 1Hz, anyone have any links?
 
     Page 1 of 3    
Print this page
© JAQ Software 2024