[Ovmsdev] SIM808/SIM908 GPS accuracy

HONDA S-2000 s2000 at audiobanshee.com
Tue Feb 7 15:21:58 HKT 2017


On Feb 6, 2017, at 10:43 PM, Edward Cheeseman <cheesemanedward at gmail.com> wrote:
>> On 7/02/2017, at 6:59 PM, HONDA S-2000 wrote:
>> Finally, to satisfy my curiosity, what are the latitude and longitude angles being converted to?
> 
>> On 7/02/2017, at 12:47 PM, Edward Cheeseman wrote:
>> OVMS native format:
>> Appears to be signed seconds * 2048. I haven’t delved into documentation here, just what I saw in the gps2latlon().
> 
> Seconds * 3600 = degrees. So native units would be degrees * 3600 * 2048.

I see. While intermediate values are calculated in float, the return value is a fixed-point, signed 32-bit long value (a.k.a. Q19.11).
That allows for a maximum of ±145 degrees (?).

> I think we all agree - if land or road surveying was the application better precision would be necessary.
> 
> When all we want is to know where our car is, within 30 meters is probably fine. Cars don’t hide that easy :)
> I only delved down this rabbit hole because the position was 200kms off! That cause has been separately solved.
> 
> The main advantage is, given the poor little 8bit PIC doesn’t need to deal with a floating point at all, there could be a speed improvement.
> A huge disadvantage is the code is not easily read.

Is there a way to separate the math into a generic function, and then rewrite the main function to use more readable function-based code?

Again, I suggest that a decimal math library might be able to directly handle the DDDMM.MMMMMM format without using float as an intermediate. If the decimal math library can convert directly to Q19.11 then it would be a sure win. Only problem is that I've never used a multi-digit decimal math library, so I wouldn't know where to point you for starters.

I agree that readability is important, but fixed-point math is never very readable, but it's indispensable in low-level firmware. At the very least, multiplication of fixed-point numbers like the Q19.11 format is not very readable, and that's already part of the design even before considering your optimizations. In other words, I think it's worth investigating integer and fixed-point optimizations.

Brian




More information about the OvmsDev mailing list