Pause Function - useful for a Clock?

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
johnnyrockets
Posts: 34
Joined: Tue May 03, 2016 12:42 pm

Pause Function - useful for a Clock?

Post by johnnyrockets »

Hi guys (gals),

I wrote a small program to (sort of) be a clock.

The idea is you have to enter the current time and then the clock should "go" on it's own.

Image

How reliable is the Pause command for something like this? Or is there a better way? Pause 120 seemed to be as close to 1 second as I could get using ZX81 with my laptop.

I'm a bit of a newbie so thanks for bearing with me! :)


Thanks!


John
User avatar
gammaray
Posts: 590
Joined: Sun Apr 17, 2016 2:44 am
Location: Texas

Re: Pause Function - useful for a Clock?

Post by gammaray »

Run for 30 minutes check your time and you will see how accurate 'tis.

If you add anymore lines in your loop, will the duration of it increase and the clock slow?
5-TS1000,UK ZX81<-Sheelagh, US ZX81, 2-TS1500/KDLX , 3-TS2040 printer, 2-TS2020 cassette decks, ZXPAND+AY, ZeddyNET, ZXBlast, UDG, ZX8CCB, AERCO, BUILDS/REPAIRS ZX Spectrum, ZX80 Minstrel, ZXMAX48 v1 v2, 2-TS-2068, ROM, 16kRAM
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Pause Function - useful for a Clock?

Post by siggi »

johnnyrockets wrote:Hi guys (gals),

How reliable is the Pause command for something like this? Or is there a better way?
In Wilf's NOVA the clock is hooked into the display routine and is updated with 50/60 Hz AND runs concurrently to the BASIC program (and can be read and set by the BASIC program):

Code: Select all

         1. Increased horizontal line length with up to 34 characters per line.
         2. Increased number of lines with up to 29 lines (in 50Hz mode)
         3. No N/L character (CHR$ 118) required to terminate video lines.
         4. Sliding display window on memory permits horizontal and vertical scrolling.
         5. Rapid switching of Display files facilitates screen animations.
         6. Increased execution speed with smaller screen displays for fast action.
         7. View contents of large A$ string array directly
 
         In addition to these display features, NOVA1000 includes several new system
         utilities such as

             1. Repeating keys.
             2. 100 Hour clock/timer
             3. BASIC line number trace.
http://www.user.dccnet.com/wrigter/inde ... va2005.htm

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
1024MAK
Posts: 5103
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Pause Function - useful for a Clock?

Post by 1024MAK »

Keep in mind that a real ZX81 or TS1000 uses a resonator rather than a quartz crystal, so the 6.5MHz ULA clock signal is not very accurate over long time periods. So a real machine will lose or gain a surprising amount over 12 hours, let alone a few days :(

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: Pause Function - useful for a Clock?

Post by Moggy »

1024MAK wrote:Keep in mind that a real ZX81 or TS1000 uses a resonator rather than a quartz crystal, so the 6.5MHz ULA clock signal is not very accurate over long time periods. So a real machine will lose or gain a surprising amount over 12 hours, let alone a few days :(

Mark

Agreed as anyone who has tried the "real time clock" listing in the Skywave forth ROM manual will testify, unreal time clock would be a more fitting description.

Inaccurate over the space of two hours let alone twelve. :lol:
johnnyrockets
Posts: 34
Joined: Tue May 03, 2016 12:42 pm

Re: Pause Function - useful for a Clock?

Post by johnnyrockets »

1024MAK wrote:Keep in mind that a real ZX81 or TS1000 uses a resonator rather than a quartz crystal, so the 6.5MHz ULA clock signal is not very accurate over long time periods. So a real machine will lose or gain a surprising amount over 12 hours, let alone a few days :(

Mark

Maybe not such a good clock then! ;)

Thanks! I did not know that!


JR
johnnyrockets
Posts: 34
Joined: Tue May 03, 2016 12:42 pm

Re: Pause Function - useful for a Clock?

Post by johnnyrockets »

Moggy wrote:
1024MAK wrote:Keep in mind that a real ZX81 or TS1000 uses a resonator rather than a quartz crystal, so the 6.5MHz ULA clock signal is not very accurate over long time periods. So a real machine will lose or gain a surprising amount over 12 hours, let alone a few days :(

Mark

Agreed as anyone who has tried the "real time clock" listing in the Skywave forth ROM manual will testify, unreal time clock would be a more fitting description.

Inaccurate over the space of two hours let alone twelve. :lol:

Funny what one gets themselves "into". I thought writing the clock would be simple. It is an exercise that I have done with many other modern languages, just for fun, but never with a retro computer.

Additionally, it is funny what one takes for "granted" in the modern computing world. Like Windows/Linux supplying the time and getting it right from the BIOS.

JR
User avatar
gammaray
Posts: 590
Joined: Sun Apr 17, 2016 2:44 am
Location: Texas

Re: Pause Function - useful for a Clock?

Post by gammaray »

Wilf's clock is "flex"-timeclock! It is ok for people on flextime... like myself. I am sometimes early... sometimes late!
5-TS1000,UK ZX81<-Sheelagh, US ZX81, 2-TS1500/KDLX , 3-TS2040 printer, 2-TS2020 cassette decks, ZXPAND+AY, ZeddyNET, ZXBlast, UDG, ZX8CCB, AERCO, BUILDS/REPAIRS ZX Spectrum, ZX80 Minstrel, ZXMAX48 v1 v2, 2-TS-2068, ROM, 16kRAM
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Pause Function - useful for a Clock?

Post by mrtinb »

You need some external hardware for a clock.

Maybe you could use ZeddyNet to sync the clock with an Internet server.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Pause Function - useful for a Clock?

Post by PokeMon »

You may write a clock program and give some correction factor manually based on your specific ZX81.
So let it run 1 hour, count the mismatch in seconds, divide 3600 seconds with your determined deviation and you adjust your time every 200 seconds or what it is by adding or subtracting one second. I think the frequency of your personal Zeddy won't change and can be treated more or less as constant. ;)
Post Reply