ZX81 clock, but this one is different !

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

ZX81 clock, but this one is different !

Post by Andy Rea »

things you will need...

1) old 3.5" disk drive (5400rpm) preferably with 2 platters.
2) some really bright rgb led's
3) IO interface.
4) ZX81 of course !

take the cover off old hard drive and rip out the heads and servo mechanismn (ooo yeah that never gonna work again), take off the platters and cut a slot in each one 1mm wide is fine, almost to the center but not quite, on the platter that is going to be the bottom one paint it's top surface white leave the top platter unpainted, put them back in the drive so that the slots are 180° apart (opposite) this helps balance the drive so that it runs without excessive vibration.

you should have something like this.
Image

put an opto (pinched out of old mouse (do they still make them with balls ? ) at the 6 o'clock position so that the slot in the lower platter can be detected, mount your super bright rgb leds around the outside of the platters so that the light falls between the 2 platters. wire it all up using suitable drivers for the leds

now the disk spinds at 5400rpm which is about 90 times a second, if we can strobe the leds in sync with the disk spiining we can get the slot to light up where we want and any colour we want (well any from 7). i trigger a light sequence once every 2 revolutions, this is 45 times a second which is still plenty often enought to trick your eyes into believing it's static ( it's the persistence of vision phenomenom ) 1 revoluton takes 35700 - ish clock cycles at the end of the first revolution all lights go off and the program calculates where the lights should be strobed for the next revolution, then waits for the sync pulse.

you get this if all goes to plan.
Image

red hours, blue minutes, green seconds

and here it is connected to Zeddy (running in fast mode hence blank TV) it really is conected by 5 wires, gnd, sybc pulse from hdd, 3 outputs for red, green and blue leds, yiu can just see my io plugged into zeddy, the other verocard has 2*uln2003 darlington drivers driving the leds,each led draws 900ma ! 300 per colour ! and i have 4 of them. power comes from the old PC power supply in the background.
Image
Now to write better program, to allow adjustment of time, make it run slower or faster (currently it gains about 4 seconds and hour) add RTC which is on order and think up some different ways of displaying the time...

Regards Andy
what's that Smell.... smells like fresh flux and solder fumes...
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: ZX81 clock, but this one is different !

Post by Andy Rea »

RTC chip turned up today, so thats been added to the project, hard drive a bit noisey to leave running all the time. so with addition of RTC should be able to turn it off and when next powered up the correct time can be restored. Well thats the plan anyway, still got to think how to do this bit banging of the i2c bus... wonder how many attempts it will take to get it right :lol:
what's that Smell.... smells like fresh flux and solder fumes...
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: ZX81 clock, but this one is different !

Post by Andy Rea »

Whooey, i can read and write data to the RTC chip, bit banging i2c bus :)

pretty pleased since as the last time i did any kind of bit banging i was in control of both sides so could pretty much do what ever i liked, but this time i had to write routines to conform with some other and previously unknown format to me.

i must learn to think things through a bit better before sitting down to write code, first 2 attemps were very messy and never even got as far as compiling, then i went kiss (keep it simple, stupid!) calls galore but it makes reading the code easier, might replace the calls with macros, and weigh up the bloated code against the number of calls. i'm not overly worried about the final size of the code as the ulitimate goal is to perfect the code on zx81, and then build standalone z80 system.

Regards Andy
what's that Smell.... smells like fresh flux and solder fumes...
User avatar
bbock
Posts: 54
Joined: Wed Jan 12, 2011 7:59 pm

Re: ZX81 clock, but this one is different !

Post by bbock »

Hi Andy,

this is a weird clock indeed! I feel like you're "misusing" the zeddy as an oversized microcontroller, but why not? :D

Greetings from Germany
Bernd
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZX81 clock, but this one is different !

Post by sirmorris »

The phrase insane genius comes to mind ;)
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: ZX81 clock, but this one is different !

Post by Andy Rea »

:lol: i like the phrase misusuing the zeddy, it's a development tool ;) yeah i could go down the road of buying more kit, arduino, propeller, pic, ect... there's a few to choose from but why bother when i am happy with Z80, already know it's language and some of it's tricks ;) would be like riding uphill learning a new language whilst building hardware i haven't used before. i'm happy pottering away on the zeddy, got an old laptop thats good for cross assembling and can just about run eightyone for debugging ;)

Charlie.... it's a very fine line between insanity and genius....i've had a foot on either side before now ;) was quite literally pulling my hair out earlier, i have a loop that goes round 360 times, for each degree on the clock face (but really it has nothing to do with degrees, 360 divides nicely by 60 and 12) the entire loop needs to be exactly 35910 clock cycles, so 35910/360 = 99.75 :? yeah right using 99 leaves a gap at the 12 o'clock position and using 100 makes it overlap. (and probably on another zeddy it will be different again !) i have 40 clock cycles to waste in the middle of the loop, so my solution was to loose 1 clock every 4th time round the loop using the lower 2 bits of the loop counter to test if it's a 4th time or not simples, well it is when you see it now, at first i had then entire loop duplicated 4 times (without the test to see if it had done 360 iterations yet except on the last copy) it was messy and a waste of memory but it proved it worked.

bah i'm rambling.

regards Andy

P.s bugger, got so engrossed in what i was doing i missed the end of an ebay auction by 30 minutes, zx81 in dk'tronics keyboard/case :( never mind i'll get the next one ;)
what's that Smell.... smells like fresh flux and solder fumes...
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: ZX81 clock, but this one is different !

Post by Andy Rea »

Well it works, i can tune it off and come back to it some time later load up the program and have the correct time displayed :D

still tweaking the code before i start adding extra display modes (when i can tihink of them)

first bit of code that i'm trying to optimise is this

Code: Select all

BCD_TO_A	
		LD		D,A		;SAVE THE BCD NUMBER FOR LATER
		AND		$F0		;10'S FIRST.
		RRCA				;SHIFTING IT RIGHT WE HAVE 8X IN THE ACCUMULATOR
		LD		E,A		;PUT 8X IN E
		RRCA				;NOW WE HAVE 4 X IN A
		RRCA				;AND FINALLY 2 X IN A
		ADD		A,E		;ADD ON THE 8X IN E AND THE TENS PART IS DONE
		LD		E,A		;PUT 10'S PART IN E
		LD		A,D		;GET OUR ORIGINAL BCD NUMBER BACK
		AND		$0F		;1'S DIGIT
		ADD 		A,E		;ADD ON THE TENS WE ALREADY WORKED OUT
		RET					;JOB DONE.
it's a lot better than what i had to start with saving 7 bytes and 41 clock cycles. basically takes a BCD number in the accumulator and returns a normal number, I.E. $33 in bcd would return $21.

Anybody know any better way ?
what's that Smell.... smells like fresh flux and solder fumes...
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZX81 clock, but this one is different !

Post by sirmorris »

The first question is why do you want to do this?
It may be that the answer is to apply the old adage 'the fastest code you'll ever execute is none at all'...
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: ZX81 clock, but this one is different !

Post by Andy Rea »

ah ah... it's not that i particularly want it to go faster, i write code in a very haphazardous way, commenting out sections and putting in new bits, then when i am happy with the results i sit down and tidy it up, add more comments to make it easier to understand what is going on and delete all the commented out code.

i was merly wondering if there is a better way of doing BCD back to a 'normal' number as it must be something that people have encountered the need for before, the reason i need to do it, is the data from the ds1307 RTC is BCD, yes i could keep the BCD data and increment (by adding 1) then use the daa instruction and whilst that will keep the time very well in BCD i would then still have the same problem converting that 0 - 59 (say for seconds) into 1 of 360 possible locations that the second hand should be displayed in...

Why the Clock??? why not, yeah it's potty, and not much use except for telling the time, it's just something i saw and thought yeah i'd like to have a go at that, so instead of following somebody elses instructions i just do it with mostly what i have around me already.

Hmm yeah sorry having re-read what i have just wrote it sounds a little defensive, it was not meant as such, just trying to explain myself.

Regards Andy
what's that Smell.... smells like fresh flux and solder fumes...
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZX81 clock, but this one is different !

Post by sirmorris »

I wasn't asking why the clock - I was asking why the conversion from BCD :D

You could always use a lookup table. Presumably it's the minutes value you have there: make a sparse table with the necessary values in it and index it. If you can afford the storage then it's going to be faster, especially if there's more calculations to be done on the result. If you can afford the cycles then what you've got makes perfect sense.

C
Post Reply