Page 1 of 1

Clock

Posted: Thu Aug 02, 2007 5:11 pm
by evildragon
(I posted this on another forum, but that forum is a tad slow.. so hopefully someone here can help-----and for the record, im basing time from vertical blanks)

I made a clock a while ago for the Genesis, but I'm getting complaints that it looses times, like, within 10 minutes.. This didn't happen on my emulator (Genesis Plus for Macintosh)..

Can someone else test it for me on real hardware? I don't have a flash cart.. I wrote it on Basiegaxorz a while ago, I might have the source code still on my laptop...

http://blackevilweredragon.spymac.com/s ... index.html

Also, if this does have a problem, then that means my other application GenTimer would also have a problem, as it was based on the source of my clock..

Posted: Thu Aug 02, 2007 6:02 pm
by Jorge Nuno
It is possible to happen because the 60/50Hz Vints could be something like 59.9/49.9 or 60.1/50.1 Hertz, so, you need to get an external real time clock with a precision oscilator.

Or, If you know the averege time deviation, you can apply some "corrections", but it varies from console to console :?

Posted: Fri Aug 03, 2007 12:21 am
by 8bitwizard
That's probably the problem, that it's not exactly 50 or 60 Hz. You either need to figure out what it really is, and hope that it doesn't vary much between consoles, or add a real-time clock chip.

But it's probably going to vary too much. I was looking at a bunch of the old Rex Sabio docs and noticed a tech note about the Xband modem. It said that any two average MD consoles can be expected to have their vertical sync counters go out of sync within two minutes.

Maybe if there was some way to configure it with a joypad to run faster or slower (add or remove one out of every few thousand vertical blanks), and display the tuning so you could re-enter it when you wanted to use it later.


It won't be useful here, but I know that you can get away with an inaccurate high-resolution counter if you have an accurate low-resolution counter like a real-time clock chip. I wrote a program on the Macintosh long ago which needed to have accurate timing for video subtitling, and I found out that setting up an interrupt handler for millisecond interrupts gave me somewhere between 1000 and 1100 interrupts per second. So I kept track of how long it was between real-time clock seconds changes and kept a running average over the last 10 seconds to get the scaling factor.

Posted: Fri Aug 03, 2007 12:51 am
by evildragon
perhaps if i take one of those old Dallas RTC "blocks" from an old motherboard, I can use one of those? I'd have to figure out how they work though..

I think they contain a crystal, IC, memory, AND a battery.. not sure..

Posted: Fri Aug 03, 2007 9:54 am
by Shiru
How about sync with Z80 or YM2612 timers? I don't think they clocking frequency can vary so much like VSYNC.

Posted: Fri Aug 03, 2007 9:58 am
by evildragon
Shiru wrote:How about sync with Z80 or YM2612 timers? I don't think they clocking frequency can vary so much like VSYNC.
I don't think I can, with the language I used..

Posted: Fri Aug 03, 2007 11:11 am
by Jorge Nuno
evildragon wrote:perhaps if i take one of those old Dallas RTC "blocks" from an old motherboard, I can use one of those? I'd have to figure out how they work though..

I think they contain a crystal, IC, memory, AND a battery.. not sure..

Yeah you can, Just look at the datasheet, it explains how to use it, and they don't contain batteries or crystals, but they are nearby on the motherboard, but forget about emulation.

Posted: Fri Aug 03, 2007 11:16 am
by evildragon
Jorge Nuno wrote:
evildragon wrote:perhaps if i take one of those old Dallas RTC "blocks" from an old motherboard, I can use one of those? I'd have to figure out how they work though..

I think they contain a crystal, IC, memory, AND a battery.. not sure..

Yeah you can, Just look at the datasheet, it explains how to use it, and they don't contain batteries or crystals, but they are nearby on the motherboard, but forget about emulation.
actually, the old Dalas RTC do have a battery, check the datasheet ;)

http://www.mcamafia.de/mcapage0/dsrework.htm

Posted: Fri Aug 03, 2007 12:05 pm
by Jorge Nuno
LOL but the internal battery probably it is dead by now, so you need extra work to preserve the time/date when you shut down the megadrive. 8)

Posted: Fri Aug 03, 2007 2:23 pm
by 8bitwizard
Shiru wrote:How about sync with Z80 or YM2612 timers? I don't think they clocking frequency can vary so much like VSYNC.
Those come from the same master timing source and will be exactly as incorrect as the vsync.

Posted: Fri Aug 03, 2007 2:38 pm
by Shiru
8bitwizard, you said that master clock frequency can vary on different SMD units? How that can be possible, with master clock which driven by quartz generator with very exactly known frequency?

Posted: Fri Aug 03, 2007 2:51 pm
by TmEE co.(TM)
Hmm, my 20year old Dallas RTC brick that I got from a 286 still works, never had to set the time again... but these have these stupid Address+Data lines which will make getting data out from them little more difficult...

Use of YM2612 timers give very stable results... but I want to know what results NTSC machines give... they have slightly different master clock... PAL machine has 53.203424(or 242)MHz OSC...

Posted: Fri Aug 03, 2007 9:44 pm
by evildragon
Jorge Nuno wrote:LOL but the internal battery probably it is dead by now, so you need extra work to preserve the time/date when you shut down the megadrive. 8)
Read the link I posted, shows how to hack an external battery for it.... ;)

But mine still work anyway.......luckily...

Posted: Fri Aug 03, 2007 11:22 pm
by Jorge Nuno
evildragon wrote:Read the link I posted, shows how to hack an external battery for it.... ;)

But mine still work anyway.......luckily...
I saw it, but it's kinda risky, at the first glance, well you are ripping/drilling/cutting the chip's package, if your hand shakes or slippers->probably RTC dead...

still works? then learn how to read the time from it, and you're set.

Posted: Sat Aug 04, 2007 12:35 am
by evildragon
Jorge Nuno wrote:
evildragon wrote:Read the link I posted, shows how to hack an external battery for it.... ;)

But mine still work anyway.......luckily...
I saw it, but it's kinda risky, at the first glance, well you are ripping/drilling/cutting the chip's package, if your hand shakes or slippers->probably RTC dead...

still works? then learn how to read the time from it, and you're set.
the block isn't a chip.. there's a chip IN the block.. the block is a chunk of potted plastic..