new widget: Adjust Clock (BETA)

Posted on
  • I'm making a widget which adjusts Bangle.js 2 clock continually in the background to counter clock drift.

    Widget doesn't attempt to determine clock drift in anyway. You need to measure clock drift yourself and then enter that value to the widget.

    Beta version is available from my app loader for now as this still needs more testing before adding to main app loader.

    I'll also publish source a bit later in GitHub as there are still few things I want to fix first. Of course code is available in my app loader (widget.js) if you want to see it. (Code includes some initial support for temperature correction but that isn't enabled yet.)

    ps. Update interval setting doesn't do anything yet, interval is currently fixed to 10 seconds. That is the next bug I'll fix. (EDIT: Fixed in version v0.00-beta-018)

  • Basic logic of how this widget reaches under 10 ms accuracy with setTime (in version v0.00-beta-026):

    • Internal clock error counter is updated periodically according to given clock drift.
    • If clock error exceeds given threshold then clock update is attempted.
    • setTime can only set time to full seconds. To set time more accurately
      a short delay is done until next full second, and then setTime is used.
    • Sometimes this delay can be longer than intented, e.g. if watch is
      busy doing something else. In this case setTime after too long delay
      would be inaccurate and so it is skipped and retried again later.
  • To others: I am testing this widget. It is working well.

  • @malaire just to add you mention:

    setTime can only set time to full seconds

    But it actually works to 1/32768 second. Even so, reducing the amount of times you call it is probably good practice since it'll affect when timers get called

  • But the documentation of setTime says that

    Set the current system time in seconds (to the nearest second).

    i.e. it discards fractional part of the given value and only uses integer seconds

  • oh wow, looks like documentation is completely wrong and setTime actually does set fractional seconds also - this completely changes how this widget should use setTime.

    I didn't even think of testing this before as I trusted documentation.

  • I'll update the docs for the next release. Generally the docs are fine but occasionally they do end up out of date, which I think is what must have happened here.

  • @malaire
    Did you see the idea in https://forum.espruino.com/conversations­/381378/?offset=25#16839063
    What do you think?

    On the technical side we could maybe overwrite setTime() to get a callback when the clock is set.

  • I don't think that would help much as drift depends a lot on temperature.

    (In my app loader there is a version which supports "Advanced PPM" which takes temperature into account, but configuring that is so difficult that I didn't publish that version into main app loader.)

  • I guess if the temperature was logged as well as the drift, it might be more possible to work something out?

  • For my "Advanced PPM" I recorded temperature and drift at multiple stable temperatures and then calculated needed quadratic equation from those datapoints.

    While it would be possible for widget to automatically follow temperature and detect when temperature has remained stable long enough, problem is that GPS only works outside and so you can't use e.g. freezer for stable cold temperature, or room temperature for another datapoint as I did.

    I don't see how user would be able to get the needed datapoints at multiple stable temperatures with GPS.

    (I guess it might be possible to calculate needed quadratic equation without stable temperatures but my math skills aren't enough for that.)

  • Wanted to share the following observation and ask maybe other users to share their ppm value.

    • Its about two bangle2 from kickstarter.
    • On my watch I did set the time beginning of May and noted the deviation about every week. There were rainy cold weeks and very warm ones like the last. Sometimes I did wear the watch all the time, other times not for several days.
    • For the watch of my wife I measured the deviation since a good week ago.

    To my surprise all deviations were about 70 (+-2)ppm!
    So maybe temperature has not such a big influence?
    Is it a coincidence that the two watches do have such a similar constant - or were might this systematic deviation stem from? (which after all makes about a whole minute every 10 days)

    And thanks for that widget. With so constant deviation we are looking forward to a pretty exact watch time in the future :-)

  • So maybe temperature has not such a big influence?

    It depends. ppm is most stable around 20°C - 30°C, so if you mostly keep watch in wrist or in room temperature then you don't see much difference in ppm. But if you wear watch in winter on top of clothing the difference can be large.

    Here's graph of my Bangle 2 ppm from year ago:
    (horizontal scale is temperature in Celsius, vertical scale is ppm)


    1 Attachment

    • drift.png
  • Ah, ok, interesting, thanks!
    So looks like I am in that low curvature regime all the time indeed.
    (There were lower temperatures outside, but wearing bangle it probably still stayed above 20°)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

new widget: Adjust Clock (BETA)

Posted by Avatar for malaire @malaire

Actions