Page 1 of 5

RTC Calibration program

Posted: Tue Jul 16, 2019 2:46 pm
by grsbanks
This program allows you to calculate the RTC calibration value to store in the \rtccalib.cfg file in your DM42's FAT drive.

Before running this program you'll first have to set the time correctly on your calculator and then wait a week or more to allow some drift to happen. The longer you wait to recalibrate, the more accurate the calibration will be.

When you run this program (XEQ "CALIB") you'll see a menu with four options. The three on the left, [DATE], [DRIFT] and [PREV] allow you to input data since the last calibration (or when the time was set if you've never calibrated), and [CALIB] on the right gives you the value to store in the calibration file.

1) Enter the date that the calculator's RTC was last calibrated (or set if you've not yet calibrated it) in the format normally used for dates, so that's dd.mmyyyy for me, 16.072019. Press [DATE]. The date you entered will be confirmed.

2) Enter the drift, in seconds, that has occurred since the date in 1). If the DM42 is running fast then the number of seconds is positive. If it's running slow then the drift is negative. Press [DRIFT] and the drift will be confirmed.

3) Enter the previous value you stored in rtccalib.cfg (or 0 if there is no rtccalib.cfg yet) and press [PREV]. That value will be confirmed.

4) Press [CALIB] and the (new) number to store in rtccalib.cfg will be displayed.

The .raw file is attached. The listing is as follows:

Code: Select all

00 { 191-Byte Prgm }
01▸LBL "CALIB"
02 FIX 06
03▸LBL 00
04 CF 22
05 CLMENU
06 "DATE"
07 KEY 1 GTO 01
08 "DRIFT"
09 KEY 2 GTO 02
10 "PREV"
11 KEY 3 GTO 03
12 "CALIB"
13 KEY 6 GTO 06
14 MENU
15 STOP
16 GTO 00
17▸LBL 01
18 FS?C 22
19 LSTO "DATE"
20 VIEW "DATE"
21 GTO 00
22▸LBL 02
23 FS?C 22
24 LSTO "DRIFT"
25 VIEW "DRIFT"
26 GTO 00
27▸LBL 03
28 FS?C 22
29 LSTO "PREV"
30 VIEW "PREV"
31 GTO 00
32▸LBL 06
33 RCL "DATE"
34 DATE
35 DDAYS
36 0.0864
37 ×
38 RCL "DRIFT"
39 X<>Y
40 ÷
41 2
42 ENTER
43 20
44 Y^X
45 X<>Y
46 ×
47 LASTX
48 1ᴇ6
49 +
50 ÷
51 +/-
52 ENTER
53 SIGN
54 0.5
55 ×
56 +
57 IP
58 RCL+ "PREV"
59 "rtccalib.cfg="
60 AIP
61 AVIEW
62 GTO 00
63 END

Re: RTC Calibration program

Posted: Sat Jul 27, 2019 2:50 pm
by ijabbott
I think the rtccalib.cfg value shown by the program possibly needs to be negated, or possibly the drift needs to be negated. I'm not sure which!

On 2019-03-31 (beginning of EU summer time), I set the calculator to the correct time.

On 2019-07-17 (108 days later), I noted my calculator had gained about 223 seconds, which is about +2.0648 seconds per day or +23.8983 ppm. The RTC calibration program produced a value of 25. I saved the rtccalib.cfg file with value 25 to the calculator and set the calculator to the correct time.

On 2019-07-27 (10 days since calibration), I noted my calculator had gained an additional 43 seconds, which is about +4.3 seconds per day or +49.7685. I.e. the rate of drift has slightly more than doubled since the initial calibration.

I know there has been some temperature variation between 2019-03-31 and 2019-07-27, but I can't imagine it having that much effect!

Today (2019-07-27) I shall set rtccalib.cfg to -25 and set the correct time on the calculator and monitor it in a week or so.

Re: RTC Calibration program

Posted: Sat Jul 27, 2019 4:47 pm
by ijabbott
Also, when rounding to an integer, the program adds 0.5 and takes the integer part. That's okay for positive values, but is incorrect for negative values. (IP truncates towards zero, not towards negative infinity.)

Re: RTC Calibration program

Posted: Sun Jul 28, 2019 6:39 am
by Joe Horn
ijabbott wrote:
Sat Jul 27, 2019 4:47 pm
Also, when rounding to an integer, the program adds 0.5 and takes the integer part. That's okay for positive values, but is incorrect for negative values. (IP truncates towards zero, not towards negative infinity.)
Is it well known that ENTER FP + IP correctly rounds to the nearest integer, even for negatives?

Re: RTC Calibration program

Posted: Sun Jul 28, 2019 10:52 am
by ijabbott
Joe Horn wrote:
Sun Jul 28, 2019 6:39 am
ijabbott wrote:
Sat Jul 27, 2019 4:47 pm
Also, when rounding to an integer, the program adds 0.5 and takes the integer part. That's okay for positive values, but is incorrect for negative values. (IP truncates towards zero, not towards negative infinity.)
Is it well known that ENTER FP + IP correctly rounds to the nearest integer, even for negatives?
That's a good sequence to know, and apparently not known well enough!

Re: RTC Calibration program

Posted: Thu Aug 08, 2019 12:08 am
by ijabbott
ijabbott wrote:
Sat Jul 27, 2019 2:50 pm
I think the rtccalib.cfg value shown by the program possibly needs to be negated, or possibly the drift needs to be negated. I'm not sure which!

On 2019-03-31 (beginning of EU summer time), I set the calculator to the correct time.

On 2019-07-17 (108 days later), I noted my calculator had gained about 223 seconds, which is about +2.0648 seconds per day or +23.8983 ppm. The RTC calibration program produced a value of 25. I saved the rtccalib.cfg file with value 25 to the calculator and set the calculator to the correct time.

On 2019-07-27 (10 days since calibration), I noted my calculator had gained an additional 43 seconds, which is about +4.3 seconds per day or +49.7685. I.e. the rate of drift has slightly more than doubled since the initial calibration.

I know there has been some temperature variation between 2019-03-31 and 2019-07-27, but I can't imagine it having that much effect!

Today (2019-07-27) I shall set rtccalib.cfg to -25 and set the correct time on the calculator and monitor it in a week or so.
Status update:

2019-08-07, 11 days after previous calibration, my calculator has gained only 1 second, which is pretty good. This confirms that when the clock is running fast, the calibration value needs to be reduced (towards negative infinity), which is opposite to what it says in the first post.

Re: RTC Calibration program

Posted: Thu Aug 08, 2019 7:01 am
by grsbanks
Thanks for the confirmation. I'll upload an altered program and edit the first post this weekend.

Re: RTC Calibration program

Posted: Sat Aug 17, 2019 10:23 pm
by FireBird
grsbanks wrote:
Thu Aug 08, 2019 7:01 am
...this weekend.
I guess your clock needs a calibration. :)

Re: RTC Calibration program

Posted: Sat Aug 31, 2019 12:18 pm
by grsbanks
Real life does sometimes get in the way of things so I've only got round to this now. Sorry about that.

I've corrected the program and updated the first post in this topic with the new version.

Re: RTC Calibration program

Posted: Sun Sep 01, 2019 10:05 pm
by HPMike
So, I just ran this program, but when I view the FAT drive in my PC file manager, I don't see any rtccalib.cfg file in the root directory. Am I expected to create this file, or am I missing something ?