News:

  • June 27, 2026, 09:36:50 AM

Login with username, password and session length

Author Topic: Most accurate timing  (Read 11633 times)

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
Most accurate timing
« on: December 14, 2016, 04:16:42 PM »
What would be the most accurate "thing" to use for timing, count the 50ms bit? just use a timer? In ThinkNDo I was told to count the rolling msec counter as it was more accurate than using a timer.  Calculating a rate - weight change from a scale for 5 sec and sometimes 10 sec   

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Most accurate timing
« Reply #1 on: December 14, 2016, 05:05:01 PM »
Most precise? TICKus() in MATH.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
Re: Most accurate timing
« Reply #2 on: December 14, 2016, 05:16:42 PM »
thanks

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Most accurate timing
« Reply #3 on: December 14, 2016, 05:23:51 PM »
Normal timers are 1ms resolution. TICKus() gives you access to the raw microsecond timer that we use internally.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
Re: Most accurate timing
« Reply #4 on: December 14, 2016, 05:55:52 PM »
So if I triggered a math calculation from a done bit of a TMR with a preset of 5 Sec vs triggering from Tickus() of 5000000, it would be just as accurate either way? I don't need the resolution, I just need it to be the 5 sec every time, regardless if program scan time is varying slightly. Or if the TMR done bit is actually 5.001 sec, will it be 5.001 sec every time? Does that make any sense?
« Last Edit: December 14, 2016, 06:03:44 PM by davidbgtx »

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Most accurate timing
« Reply #5 on: December 14, 2016, 07:07:06 PM »
They are both scan bound, and driven by the same underlying timebase, so yes.

We have some wonderful hardware-based timer options in the new hardware due out early next year, which will allow you to trigger interrupt routines with microsecond accuracy and about 5us of latency. For now, software-based timers at scan resolution are the best you can do.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
Re: Most accurate timing
« Reply #6 on: December 15, 2016, 04:54:17 AM »
Cool!
and Thanks for your help