{"id":202,"date":"2020-07-14T19:26:06","date_gmt":"2020-07-15T02:26:06","guid":{"rendered":"https:\/\/boom-tracker.com\/tracker\/?p=202"},"modified":"2020-07-15T09:47:08","modified_gmt":"2020-07-15T16:47:08","slug":"further-timekeeping-improvements","status":"publish","type":"post","link":"https:\/\/boom-tracker.com\/tracker\/blog\/further-timekeeping-improvements\/","title":{"rendered":"Further timekeeping improvements"},"content":{"rendered":"\n<p>One of the problems I&#8217;d been seeing was that every time I synced with the NTP server, the clock would jump forward or back anywhere from 15 milliseconds to 100 milliseconds or more.  I even had some cases where readings were appearing out of order because they happened right after one of these jumps.<\/p>\n\n\n\n<p> With a bit more hairy math, I&#8217;ve got it spreading out the corrections over a full second, and trying to adaptively adjust its mapping of the internal clock to the real world by continually skewing its reading of the <em>micros()<\/em> call slightly.  It&#8217;s still jumping slightly, (and backwards, which shouldn&#8217;t be possible now, so I likely have some subtle bug), but the jumps are fairly consistently -70 to -85 microseconds, which is shorter than the reading of a single data point, so I doubt it will cause much trouble.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small.png\" alt=\"\" class=\"wp-image-204\" width=\"769\" height=\"402\" srcset=\"https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small.png 937w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small-300x157.png 300w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small-768x402.png 768w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small-250x131.png 250w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small-550x288.png 550w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small-800x419.png 800w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small-344x180.png 344w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/Update_Skews_100_small-573x300.png 573w\" sizes=\"auto, (max-width: 769px) 100vw, 769px\" \/><\/figure>\n\n\n\n<p>That&#8217;s not to say that everything is perfect.  The offsets I&#8217;m measuring, while smaller, are still large (+\/-1000-2000 microseconds), but at least they&#8217;re not causing the reading to jump around as much.  This might be due to clock instability on the server side, or on the microcontroller side.  If it&#8217;s on the microcontroller side then my hopes of making the individual mic controllers stay in sync might be in trouble.  I&#8217;ll have to wait &#8217;til I have more than one fully functional to check out this theory.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-1024x512.png\" alt=\"\" class=\"wp-image-205\" width=\"857\" height=\"429\" srcset=\"https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-1024x512.png 1024w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-300x150.png 300w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-768x384.png 768w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-250x125.png 250w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-550x275.png 550w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-800x400.png 800w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-360x180.png 360w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-599x300.png 599w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small-999x500.png 999w, https:\/\/boom-tracker.com\/tracker\/wp-content\/uploads\/2020\/07\/NTP_Offsets_100_small.png 1141w\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the problems I&#8217;d been seeing was that every time I synced with the NTP server, the clock would jump forward or back anywhere from 15 milliseconds to 100 milliseconds or more. I even had some cases where readings were appearing out of order because they happened right after one of these jumps. With&hellip; <a class=\"more-link\" href=\"https:\/\/boom-tracker.com\/tracker\/blog\/further-timekeeping-improvements\/\">Continue reading <span class=\"screen-reader-text\">Further timekeeping improvements<\/span> <span class=\"meta-nav\" aria-hidden=\"true\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"bgseo_title":"","bgseo_description":"","bgseo_robots_index":"index","bgseo_robots_follow":"follow","footnotes":""},"categories":[3,8],"tags":[],"class_list":["post-202","post","type-post","status-publish","format-standard","hentry","category-blog","category-implementation"],"_links":{"self":[{"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/posts\/202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/comments?post=202"}],"version-history":[{"count":2,"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/posts\/202\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/posts\/202\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/media?parent=202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/categories?post=202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boom-tracker.com\/tracker\/wp-json\/wp\/v2\/tags?post=202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}