Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:15 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2 RTC & TIME$

     Page 1 of 2    
Author Message
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 01:35am 16 Jun 2020
Copy link to clipboard 
Print this post

Questions:-

From the Manual (P14) TIMING

"The Colour Maximite 2 has a battery backed clock so it will not loose
the time even when powered off. If you find that the time drifts while the power is off you can use the OPTION CLOCKTRIM command to correct for any inaccuracies."

I assume from this that OPPTION CLOCKTRIM only applies to the RTC & not to the internal timing of the CMM2 when it is normally running & only sets the time & date when the CMM2 is switched on?

Also, does a TIME$ = TIME$ call set the CMM2 time to the RTC time?

Brian



ChopperP
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1882
Posted: 02:14am 16 Jun 2020
Copy link to clipboard 
Print this post

Clock Trim is only for the RTC and Sys time is automatically set at power up to the RTC.

Mike
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 02:58am 16 Jun 2020
Copy link to clipboard 
Print this post

You have found an error in the manual.

It should be OPTION RTC CALIBRATE to trim the RTC oscillator.

One of my boards needs RTC CALIBRATE 140 and the other needs RTC CALIBRATE 23 so there is a big variation between boards.

In the CMM2, the RTC is used for all TIME$ and DATE$ functions, not just on startup. There is no need to set the RTC specifically.

PULSE and SETTICK etc use the 8MHz oscillator rather than the RTC clock.

Jim
VK7JH
MMedit
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 03:05am 16 Jun 2020
Copy link to clipboard 
Print this post

@Mike,

That's what I thought when I read the blurb.

So if the CMM2 is on 24/7, then CLOCKTRIM (once set) is of little use unless a TIME$ = TIME$ call sets the system time to the RTC time which I was told a good while ago happens with the CMM1.

But then the CMM1 had a separate RTC & I may be barking up the wrong tree here. The CMM2 may continuously read the RTC.

Edit

Just read Jim's post. OK then, I'll stop worrying about it. Thanks

I'm using CALIBRATE. Didn't notice the error. My board is running slow.

Brian
Edited 2020-06-16 13:13 by Chopperp
ChopperP
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1882
Posted: 03:22am 16 Jun 2020
Copy link to clipboard 
Print this post

Yes, I should have worded that differently, I was trying to differentiate between the CCM1 and CMM2. CCM2 and ARM-H7 both have inbuilt RTC, not sure about newer MM variants.

Mike.
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 05:19am 16 Jun 2020
Copy link to clipboard 
Print this post

  TassyJim said  PULSE and SETTICK etc use the 8MHz oscillator rather than the RTC clock.
Jim

So a SETTICK 1000, DoStuff,1 would drift over time with respect to the seconds on TIME$.

Something to bear in mind.
ChopperP
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1882
Posted: 06:03am 16 Jun 2020
Copy link to clipboard 
Print this post

I've always assumed that the xtal derived timer would not match the RTC, or use it as any sort of reference, but of course I could be wrong. If you use the system timer to time interrupt intervals set by SETTICK, you will see small variations between call times, which I expect to see due to MM basic, MM basics internal tasks and the variations of program and hardware resources. In my days, even with precision xtal clocked Micros, you still had to code critical u-sec timing tasks in assembler, perhaps that's changed over the past 20 years as smarter devices come along.
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 06:28am 16 Jun 2020
Copy link to clipboard 
Print this post

Looking at a photo of the underside of the Waveshare module, I see what looks like a watch crystal (along with the 8MHz one) which I assume is for the RTC.

EDIT: Looking further down the web page, it is the 32MHz RTC crystal with calibration

I would say that the 8Mhz crystal should be more accurate & stable than the RTC one.

Trying the RTC CALIBRATE maxed out at -255 at the moment. Still going slow.
Edited 2020-06-16 16:38 by Chopperp
ChopperP
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:55am 16 Jun 2020
Copy link to clipboard 
Print this post

  Quote  Trying the RTC CALIBRATE maxed out at -255 at the moment. Still going slow.

You can go to 512 if needed.

The RTC drifts with temperature:



The 8MHz Xal can be replaced with a 8MHz oscillator module but it is not going have  much better accuracy if any. We did this to improve video stability but by the time I did one of mine, Peter had solved the problem and the transplant is no longer required.

I am not sure if the same butchery can be done with the 32kHz Xal without firmware changes. If I wanted precision, I think I would use a GPS derived timebase anyway.

Jim
VK7JH
MMedit
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 07:04am 16 Jun 2020
Copy link to clipboard 
Print this post

  Quote  Trying the RTC CALIBRATE maxed out at -255 at the moment. Still going slow.


Sounds like the crystal load capacitors on your board may be dodgy or incorrect value.

These is a hidden option that may help

OPTION RTC DRIVE n

n can be between 0 and 3, it defaults to 2. Try 1 and 3 and see if one of them helps. I would start with 1 as a slow clock tend to mean the crystal is being over-driven

For the avoidance of doubt, all TIME$ and DATE$ calls use the RTC
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 07:20am 16 Jun 2020
Copy link to clipboard 
Print this post

Thanks Jim, Yes you can go from -511 to 512. Rechecked the manual

32MHz watch crystals rely a bit on body temperature to negate some of the effects from temperature variations.

I've got my CMM1's time derived from a GPS.

Just doing some time comparisons between TIMER & TIME$. After about 20 mins, the timer has advanced about 0.4 secs over TIME$. Over a second an hour.

TIME$ itself has lost about 5 secs in a few hours which would tie in with above. (I think)

Brian
ChopperP
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 07:22am 16 Jun 2020
Copy link to clipboard 
Print this post

Hi matherp

Thanks for that. Will try your suggestions.

Brian
ChopperP
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 07:59am 16 Jun 2020
Copy link to clipboard 
Print this post

If my RTC is running slow I use a positive calibrate value, not negative.

Extract from MMTimeLord:
  Quote  OPTION RTC CALIBRATE 0
>
17:36:24   Time check started.
Don't move or resize the window while timing!
Connected to Micromite at 115200
*

Configuration = CMM2 RTC at 30 seconds
17:36:25   Interval Error   Average S/D avS/D
17:36:55   30.000908 -0.0030%   -0.0030%   -2.62 -2.62
17:37:25   30.001112 -0.0037%   -0.0034%   -3.20 -2.91
17:37:55   30.001105 -0.0037%   -0.0035%   -3.18 -3.00
17:38:25   30.001121 -0.0037%   -0.0035%   -3.23 -3.06
17:38:55   30.000903 -0.0030%   -0.0034%   -2.60 -2.97
17:39:25   30.000353 -0.0012%   -0.0031%   -1.02 -2.64
17:39:55   30.021037 -0.0701%   -0.0126%   -60.59 -10.92
17:40:25   29.999099 0.0030%   -0.0107%    2.60 -9.23
17:40:55   30.000427 -0.0014%   -0.0097%   -1.23 -8.34
17:41:25   30.001082 -0.0036%   -0.0090%   -3.12 -7.82
17:41:55   30.000312 -0.0010%   -0.0083%   -0.90 -7.19
17:42:25   30.019828 -0.0661%   -0.0131%   -57.10 -11.35
17:42:55   29.999361 0.0021%   -0.0120%    1.84 -10.33
17:43:25   30.000741 -0.0025%   -0.0113%   -2.13 -9.75
17:43:55   29.999470 0.0018%   -0.0104%    1.53 -9.00
17:44:19   Time check stopped.

Connected to Micromite at 115200
option rtc calibrate 130
>
17:44:47   Time check started.
Don't move or resize the window while timing!
>
RUN
Configuration = CMM2 RTC at 30 seconds
17:44:49   Interval Error   Average S/D avS/D
17:45:19   30.000085 -0.0003%   -0.0003%   -0.25 -0.25
17:45:49   30.000667 -0.0022%   -0.0013%   -1.92 -1.08
17:46:19   29.999778 0.0007%   -0.0006%    0.64 -0.51
17:46:49   29.999745 0.0009%   -0.0002%    0.74 -0.20
17:47:19   30.001277 -0.0043%   -0.0010%   -3.68 -0.89
17:47:49   30.000839 -0.0028%   -0.0013%   -2.42 -1.15
17:48:19   30.000340 -0.0011%   -0.0013%   -0.98 -1.12
17:48:49   29.999781 0.0007%   -0.0010%    0.63 -0.90
17:49:19   30.000752 -0.0025%   -0.0012%   -2.17 -1.04
17:49:49   29.998967 0.0034%   -0.0007%    2.98 -0.64
17:50:19   29.998154 0.0062%   -0.0001%    5.32 -0.10
17:50:49   29.999363 0.0021%   0.0001%    1.84  0.06
17:51:19   29.998792 0.0040%   0.0004%    3.48  0.32
17:51:49   29.998673 0.0044%   0.0007%    3.82  0.57
17:52:19   29.998943 0.0035%   0.0009%    3.05  0.74
17:52:49   29.999036 0.0032%   0.0010%    2.78  0.87
17:53:19   29.999042 0.0032%   0.0011%    2.76  0.98
17:53:46   Time check stopped.


Jim
VK7JH
MMedit
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 08:22am 16 Jun 2020
Copy link to clipboard 
Print this post

  Quote  If my RTC is running slow I use a positive calibrate value, not negative.


Jim, can you check the manual and confirm if it reads correctly. You have played with this much more than me.
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 08:22am 16 Jun 2020
Copy link to clipboard 
Print this post

Forgot about your MMTimeLord

From the manual under OPTION RTC CALIBRATE ±n

Positive numbers will slow the clock
down, negative will speed it up.

Is the manual wrong or am I reading it incorrectly? Mine's running slow.

May try +255 & see what happens.

Brian
ChopperP
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:32am 16 Jun 2020
Copy link to clipboard 
Print this post

I think the manual is wrong but I will like to see what Brian ends up with before annoying Geoff.

When I run MMTimeLord, if the average interval error is -0.0100%, ie slow,  I set the Calibrate value to +100

MMTimeLord has to run for 30 minutes to negate the timing variations in the USB-TTL converter.

This all assumes a computer clock that has been trimmed using NTP or similar.

Jim
VK7JH
MMedit
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 08:38am 16 Jun 2020
Copy link to clipboard 
Print this post

Likewise I think the manual is wrong - almost certainly my fault

Try the attached

settick 10000,myint
option milliseconds on
timer=0
do
loop
sub myint
print timer,time$
end sub


with OPTION RTC CALIBRATE 500 and then OPTION RTC CALIBRATE -500

The effect is obvious within the first minute
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 08:42am 16 Jun 2020
Copy link to clipboard 
Print this post

OK, reset to +512. See what happens in a couple of hours.
-511 didn't improve anything

@matherp..just saw your message. Will do later tonight

Brian
Edited 2020-06-16 18:46 by Chopperp
ChopperP
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 09:00am 16 Jun 2020
Copy link to clipboard 
Print this post

I can confirm that +512 speeds the RTC up.
ChopperP
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 10:06am 16 Jun 2020
Copy link to clipboard 
Print this post

OK, so after about an hour & 20mins, the RTC has gained ~2secs C/W PC clock as opposed to losing time.
Also, the RTC has gained similar amount over the TIMER using my test setup.

Will try Peter's routine.

Update:

Used Peter's routine & Jim's MMTimeLord (both similar).

Got down to a cal fig of +80

Manual needs updating...

Thanks

Brian
Edited 2020-06-16 20:43 by Chopperp
ChopperP
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025