[Ovmsdev] SIM808/SIM908 GPS accuracy
cheesemanedward at gmail.com
Wed Feb 8 18:45:09 HKT 2017
> On 8/02/2017, at 7:25 PM, HONDA S-2000 wrote:
> That's assuming that any rewrite turns out to be an improvement, otherwise the code could stay as it was. Let us know what you find out.
So, I got curious as to what happens to the lat and long coordinates after they got converted to the Q20.11 seconds notation.
The result of calls to gps2latlon() only end up in globals car_latitude and car_longitude.
Those variables get used directly in acc.c and log.c, which I gather is for logs, and calculating if an advanced charger is close?
As far as I can tell, everywhere else they are used only via stp_latlon().
Here I found a comment that pointed to the origin of the fixed point Q20.11 seconds format: it is native to the Tesla Roadster.
So what happens in stp_latlon() is another conversion via float to go from Q20.11seconds to 32bit degrees*1000000.
Degrees*1000000 is chosen for conversion to a human readable ascii string “(-)(D)(D)D.DDDDDD” …
... which just happens to be what the SIM808 puts out natively!
Rather than refactor all the location code I’m going to suggest changing that one remaining floating point conversion out with another fixed point integer multiply, and leaving it at that.
More information about the OvmsDev