Page 1 of 1

Interval timer on DM41(L): iffy accuracy

Posted: Wed Jan 31, 2018 8:22 pm
by keithdalby
Wrote a program to beep regularly with a given number of seconds between each beep. Useful for a lab where you're taking measurements every X seconds and don't want to keep an eye on a timer.

Problem is, the clock isn't very accurate and when I run this along side a stopwatch the difference is very noticeable indeed. Some beeps as as much as a fifth of a second out. May not seem like a lot, but I wonder if there's a way to improve the clock accuracy? Or is this more a problem of the program execution time being so variable?

Code: Select all

LBL BEEPER
"INTERVAL=?"
PROMPT
STO 01
TIME
HR
3600
×
STO 02
0
STO 03
LBL 01
RCL 01
RCL 03
×
RCL 02
+
TIME
HR
3600
×
X<=Y?
GTO 01
TONE 6
"N="
ARCL 03
AVIEW
1
ST+ 03
GTO 01
END

Re: Interval timer on DM41(L): iffy accuracy

Posted: Wed Jan 31, 2018 10:46 pm
by grsbanks
Keith,

How high is "X"?

The problem with the way you're doing this is the time taken for each iteration of the loop that determines when it's time to take a measurement.

For values of "X" greater than 10 seconds, I'd change tack and set up a repeating control alarm to run a program that takes the measurement.

A) it should be more accurate, and
B) you're not running the CPU at 100% in a a loop

Re: Interval timer on DM41(L): iffy accuracy

Posted: Thu Feb 01, 2018 7:15 am
by keithdalby
Mmmm, X can be as low as a couple of seconds. I also think that, because it's checking a difference in time from the internal clock, the time for actually running the program shouldn't cause the intervals to drift too much cumulatively. A few ms delay in a beep is fine - as long as it's consistent. I suppose it would average out in the end, but the noticeable ebb and flow of the beeping during operation bugs me a bit.

Why would you only use the XYZALM (or whatever) for values of X greater than 10?

Re: Interval timer on DM41(L): iffy accuracy

Posted: Thu Feb 01, 2018 2:48 pm
by grsbanks
The noticeable ebb and flow comes from the fact that it probably takes several hundred milliseconds to run each iteration of your loop. The DM41 is not a fast calculator by any stretch of the imagination. Certainly much faster than the original HP-41CX but that speed improvement is not as pronounced as it is with, for example, the DM15 or DM11.

The ten-second figure comes from the manual for the Time Module (built into the 41CX), which gives this as a figure below which the accuracy of the timer goes a bit pear shaped.

Re: Interval timer on DM41(L): iffy accuracy

Posted: Thu Feb 01, 2018 5:00 pm
by keithdalby
grsbanks wrote:
Thu Feb 01, 2018 2:48 pm
it probably takes several hundred milliseconds to run each iteration of your loop.
That makes sense, although I'm surprised it is so high. I am being naïve (again) in expecting the same program steps to produce the same latency every iteration, aren't I?

Re: Interval timer on DM41(L): iffy accuracy

Posted: Thu Feb 01, 2018 5:44 pm
by keithdalby
grsbanks wrote:
Thu Feb 01, 2018 2:48 pm
The ten-second figure comes from the manual for the Time Module (built into the 41CX), which gives this as a figure below which the accuracy of the timer goes a bit pear shaped.
In suppose I could include a conditional test that uses the code here for small intervals and a repeating XYZALM for intervals longer than 10s, but I doubt there'd be much point.