01 June 2014, 20:31 | #1 |
Supernormal
Join Date: Jul 2007
Location: Istanbul / Turkey
Age: 43
Posts: 1,411
|
Why is Amiga clock never precise?
I have tried many clock programs but all of them had the same problem. The only clock program that works precisely is the Clock from utilities drawer.
Seconds are not really seconds. Seconds always pause for a very short time and then suddenly it moves faster to catch "now" only to pause again for a very short time. This goes on and on. Any reason for this? |
02 June 2014, 05:03 | #2 |
A1260T/PPC/BV/SCSI/NET
Join Date: Jan 2013
Location: Moscow / Russia
Posts: 840
|
On a real machine or under UAE ? Also what specs ?
Chances are your main CPU is loaded and the clock tasks are running at lower priority. |
02 June 2014, 08:39 | #3 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,522
|
I think OP means clock GUI display update looks "unstable".
Reason is quite simple, they usually update screen only once/second (or sometimes twice/second) using vblank wait but vblank wait is not synced to clock, it will slowly drift depending on screen mode. Use of CIA e-clock based timer would look more stable. Clock updates will look like this (of course it is not that bad in real world, this is just short example): draw clock, clock seconds+1, draw clock, draw clock (it looks like clock stopped for one second), clock seconds+1, draw clock, clock seconds+1, clock seconds+1, draw clock (clock jumped 2 seconds at once) and so on.. |
02 June 2014, 13:58 | #4 |
Supernormal
Join Date: Jul 2007
Location: Istanbul / Turkey
Age: 43
Posts: 1,411
|
Thanks for the explanation Toni. Any reason people program clock utilities without using CIA ? For example Dopus5 clock or MCP clock are "unstable".
|
02 June 2014, 14:00 | #5 |
Cheesy crust
Join Date: Nov 2008
Location: Hawk's Creek
Age: 48
Posts: 1,383
|
Processing Power. You don't want to spend resources on a clock...
|
02 June 2014, 14:20 | #6 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,768
|
But how will you know the exact frequency of the CIA? Doesn't it change based on the screen's refresh rate?
I don't think that's a problem. |
02 June 2014, 15:58 | #7 | ||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,522
|
Quote:
CIA TOD counters count h and v-blanks. Quote:
vblank timing is practically free. |
||
02 June 2014, 16:14 | #8 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,002
|
VBLANK has a resolution of 50Hz or 60Hz. This is by far enough to wait for the next second. There is no need to waste a CIA for timing. You just don't have to wait stupidly one second every time, but have to calculate the number of ticks needed until the next second arrives. Depending on how much time is needed to draw the graphics this can well be far less than a second.
|
02 June 2014, 16:27 | #9 |
Supernormal
Join Date: Jul 2007
Location: Istanbul / Turkey
Age: 43
Posts: 1,411
|
I just realized that something similar also happens on my Windows 7 PC.
Click the clock once to open the analog clock which shows seconds and watch. It seems like default Amiga clock from the Utilities drawer is better than the default Windows one. :P |
02 June 2014, 16:29 | #10 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,768
|
Quote:
How can you get accurate timing if these vertical rates can vary so much? On systems with an RTC you simply count VBlanks and read the clock once per second. Accurate and fast. |
|
02 June 2014, 16:38 | #11 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,351
|
The thing could be as well that some 3rd party clocks do actually count the Vblanks, but they have a different setup to you. So, if someone programmed their clock to wait 60 frames before redrawing, and you run it on a 50Hz (PAL machine), then it will drift and catch up with itself over the space of around 5-6 seconds.
Using a CIA timer is a terrible idea (though would result in very accurate redraws)... It would tie up that timer so it's not available for use by other things, and some things such as audio decoders etc. do use CIA timers, so you want them available. I don't know how the Workbench clock works, but perhaps it polls the clock once a frame or once every 5 frames or something, and if the time's changed, it redraws. Doing that every couple of frames wouldn't be that resource hungry and should give near-instant updates. |
02 June 2014, 17:00 | #12 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,002
|
dos/dos.h defines TICKS_PER_SECOND as 50, no matter if NTSC or PAL. So on a NTSC machine this might run out of sync.
But if you use timer.device UNIT_VBLANK or UNIT_WAITUNTIL you can specify how many seconds and microseconds to wait. Timer.device calculates how many ticks to wait. |
02 June 2014, 19:39 | #13 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,522
|
Quote:
(Or did you plan to quote thomas' post, not mine?) |
|
02 June 2014, 19:52 | #14 | ||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,768
|
Quote:
Quote:
I meant your post. |
||
02 June 2014, 20:57 | #15 | |
Registered User
Join Date: Jun 2010
Location: PL?
Posts: 2,775
|
Quote:
btw - VBLANK in nominal mode is not 50Hz unless bit LACE is active, also overall quartz oscillators accuracy apply to system. Last edited by pandy71; 02 June 2014 at 21:03. |
|
02 June 2014, 21:22 | #16 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,002
|
|
02 June 2014, 21:37 | #17 |
Supernormal
Join Date: Jul 2007
Location: Istanbul / Turkey
Age: 43
Posts: 1,411
|
|
03 June 2014, 15:46 | #18 | |||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,522
|
Quote:
Quote:
Quote:
I guess models that have vsync/power line tick jumper can use power line tick (which clocks CIA TOD timer) as a reference clock but they aren't that common... |
|||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Clock for Amiga 500 (1MB chip-ram) | StevenMarshall | support.Hardware | 3 | 07 February 2017 22:45 |
Amiga 4000 clock problems | cyberfox_it | support.Hardware | 5 | 30 March 2011 23:27 |
Speed up Amiga realtime clock - how? | DeathAndPain | support.WinUAE | 5 | 21 May 2009 20:46 |
clock in cloanto amiga forever... | zACK! | support.WinUAE | 2 | 08 April 2006 20:36 |
Amiga 600 clock problem | Uukrul | support.Hardware | 10 | 17 June 2002 23:26 |
|
|