<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div>Sorry, in my P.S., I think I miscalculated the improvement.<div><br></div><div>1] Current methodology:</div><div><br></div><div>Signed 16 bit integer</div><div>Every 104.8576ms timer interrupt, add 105ms to the counter.</div><div>If counter >1,000 treat it as 1 second and deduct 1,000 from counter.</div><div><br></div><div>Accuracy: loses 0.1424ms per timer interrupt.</div><div><br></div><div>2] 50ms methodology:</div><div><br></div><div>Signed 16 bit integer</div><div>Every 104.7576ms timer interrupt, add 5243 to the counter.</div><div>That is equivalent to 5242.88 50ms chunks.</div><div>Difference is 0.88 / 50 ms</div><div>Accuracy: loses 0.01760ms per timer interrupt</div><div><br></div><div>Or, is my new maths wrong? Is the inaccuracy 0.01760ms or 0.12ms per timer tick?</div><div><br></div><div>Confused, I am.</div><div><br></div><div>Mark.</div><div><br><div><div>On 21 Oct, 2014, at 3:16 pm, Mark Webb-Johnson <<a href="mailto:mark@webb-johnson.net">mark@webb-johnson.net</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div>My thinking is that losing 1 ms every second or so means 1,000 seconds (16 minutes) to lose 1 second. As we poll the GSM modem for clock once every 60 seconds that should be fine and we should maintain accuracy. The GSM modem includes a real-time clock, so even if it loses GSM connectivity it should still keep good time.<div><br></div><div>P.S. There is a simple slight improvement I thought about last night. I use a 16bit unsigned integer to count milliseconds, adding 105 to it every 104.8576ms timer interrupt, and taking off 1,000ms every time it gets >1,000. Leading to an inaccuracy of 0.1424ms every timer tick. I could simply count 50ms instead, adding 5243 every timer tick of equivalent 5242.88 50ms chunks, and then taking off 50,000 every time if gets >50,000. That would lead to an inaccuracy of 0.12ms every timer tick. We could also mess around with the timer functions to try to get something more divisible into 1ms. But, with the GSM polling, I just don't think it will be necessary.</div><div><br></div><div>Regards, Mark.</div><div><br><div><div>On 21 Oct, 2014, at 2:55 pm, Gianluca <<a href="mailto:notifications@github.com">notifications@github.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p>After quick math every 7 interrupts you "loose" one ms. Maybe you could count interrupts and adjust ms count. To be more precise every 44 adjustments you should skip the increment. Let's say is a gregorian solution :)</p><p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System/commit/1a97b928d42e4f0db5940ebfc3416845354ce09a#commitcomment-8236670">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/797262__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyOTQ5Mzc0NywiZGF0YSI6eyJpZCI6NDY0MTI0NDZ9fQ==--8dfb3dd2b93b08cf8ae7c15d7f99c383e32b88de.gif" width="1"></p>
<script type="application/ld+json">{"@context":"<a href="<a href="http://schema.org">http://schema.org</a>"><a href="http://schema.org</a>">http://schema.org</a></a>","@type":"EmailMessage","description":"View this Commit on GitHub","action":{"@type":"ViewAction","url":"<a href="<a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System/commit/1a97b928d42e4f0db5940ebfc3416845354ce09a#commitcomment-8236670">https://github.com/openvehicles/Open-Vehicle-Monitoring-System/commit/1a97b928d42e4f0db5940ebfc3416845354ce09a#commitcomment-8236670</a>"><a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System/commit/1a97b928d42e4f0db5940ebfc3416845354ce09a#commitcomment-8236670</a>">https://github.com/openvehicles/Open-Vehicle-Monitoring-System/commit/1a97b928d42e4f0db5940ebfc3416845354ce09a#commitcomment-8236670</a></a>","name":"View Commit"}}</script></blockquote></div><br></div></div></blockquote></div><br></div></body></html>