RTC Calibration program

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

RTC Calibration program

Post 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
Attachments
calib.raw
(194 Bytes) Downloaded 548 times
There are only 10 kinds of people in the world: those who understand binary and those who do not.
User avatar
ijabbott
Posts: 253
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

Re: RTC Calibration program

Post 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.
User avatar
ijabbott
Posts: 253
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

Re: RTC Calibration program

Post 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.)
Joe Horn
Posts: 108
Joined: Thu Oct 04, 2018 2:10 am

Re: RTC Calibration program

Post 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?
User avatar
ijabbott
Posts: 253
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

Re: RTC Calibration program

Post 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!
User avatar
ijabbott
Posts: 253
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

Re: RTC Calibration program

Post 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.
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: RTC Calibration program

Post by grsbanks »

Thanks for the confirmation. I'll upload an altered program and edit the first post this weekend.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
FireBird
Posts: 5
Joined: Wed May 30, 2018 12:49 pm
Location: Austria

Re: RTC Calibration program

Post by FireBird »

grsbanks wrote:
Thu Aug 08, 2019 7:01 am
...this weekend.
I guess your clock needs a calibration. :)
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: RTC Calibration program

Post 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.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
HPMike
Posts: 439
Joined: Fri Jul 21, 2017 11:01 pm
Location: DFW, Texas

Re: RTC Calibration program

Post 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 ?
DM15L, S/N 00548. DM42, SN: 00159. DM41X, SN: 00973. DM32, SN 00054.
Post Reply