Binary Clock

There are only 10 types of people in the world: those who understand binary and those who don’t. Imagine: 4 bits showing what hour it is and 6 bits showing the minutes. Try to think binary and become a real geek! 😉 We’ll try to develop a binary watch with 1010-bits :-P. It must be as accurate as possible and you must be able to enter the correct hour.

This project will be made with only 1 Altera MAX7000s , the necessary switches and 10 LED’s.  4 LED’s will be used to display the hour, 6 LED’s will be used to display the minutes. As for that we will only be able to make a 12h-clock and not a 24h-version. Development will be done in Altera Quartus II Web Edition. This environment is freely distributable and gives you the possibility to design and program almost all Altera-CPLD’s. Programming will be done with the well-known ByteBlaster2 but you can also use other devices if you want to. As for the timing we will use the 50Hz available 230V-supply. I am told this frequency should be extremely stable in the long-term. Other benefits:
– 50 Hz is available without buying a crystal
– our divider should only count too 300, with a crystal he should count to a few millions!
As for the timing we will use a resonator working at 1.000MHz and 5V TTL-level. We changed this to simplify the project. In a later step we will change it into DCF to be 100% sure about the given time.
Binary Clock – STEP 1: basic watch
The Binary Clock / Basic Watch needs only one MAX7000s. I have tried to keep everything in a single Altera EPM7032SLC44 but I haven’t succeeded. You’ll have to use a EPM7064SLC44 or you will have the use a lower clockfrequency.Programming was done in Altera Quartus II Web edition Version 6.0 Build 178 in Block Diagram.
Brand new release! Please forget about the last v1.12 (the one with AM/PM): it didn’t work at all!

This release is a bugfix. From now on your clock will give you the exact time :-). In theory it wasn’t possible but when you builed the previous releases you probably had the same problem as I had: the clock was very exact for hours and without any reason he starts to flip and it missed some seconds and even some minutes!To avoid this problem I have connected the clock to the Global Clock (pin43) and I switched the unused pins from random output to tri-stated input. Two things I will always do from now on!

I’ve tested this release for a couple of weeks and it worked very well! I was planning to release a v1.20 totally written in VHDL (and as a matter of fact: I’ve finished it allready, it just needs some bugfixing) but because v1.12 is working so great I will leave it this way. This version is the final v1-release! You’ll have to wait until I receive my STK-500 so I can start programming v2.00, not using MAX7000s but written in ASM using an AVR and controlled by DCF77 or an internet-clock to be  100% sure about the results. Stay tuned and enjoy this v1-release!

The clock is entering at 1MHz. So, in the first place we have to recalculate that to 1 second. lpm_counter0 and lpm_compare0 are taking this job. After 1.000.000 hits you have reset for the counter and a trigger for lpm_counter4. The same pulse is used to togle some LEDs so we can see the MAX7000s is really working. lpm_counter4 and lpm_compare3 have to work together to divide those seconds into minutes while lpm_counter2 and lpm_compare2 are counting those minutes and dividing them into hours.

Resetting the counter is asynchronous since v1.01. Doing so avoids the problem as described in “known bugs v1.00”. TNX to Charlie Barbe for the hint!

New in v1.10 is the addition of lpm_compare4 and lpm_compare5. Together they make a pulsetrain with a small up-time and a frequency of 2Hz. The pulses are not coming up or going down together with the triggers for the seconds, minutes or hours.
This pulsetrain can be used to automate the manual-set of the minutes and the hours and because of the small up-time it will avoid problems with rumble.

Added in v1.11 is the aclr for lpm_counter4 connected to input SET_min. Everytime you release this button will reset the counter that counts the seconds. This makes it possible to set the clock exactly to the second.

— If you want to have a better look at the schematics, just save them —

— If you want to have a better look at the schematics, just save them —

The I/O’s are re-chosen as simple as possible:

  • 43 – CLK_1MHz
  • 11 – SEC_LED_RG
  • 31 – hours[0]
  • 33 – hours[1]
  • 37 – hours[2]
  • 39 – hours [3]
  • 18 – minutes[0]
  • 20 – minutes[1]
  • 24 – minutes [2]
  • 26 – minutes[3]
  • 28 – minutes[4]
  • 29 – minutes[5]
  • 17 – SEC_LED_GR
  • 4 – SET_min
  • 40 – SET_h

After compilation we used 44 macrocells (69%). So we still have a lot of macrocells in spare to add even more functionality!

You can download de Quartus-file by clicking here.

v1.12 [01/07/2006]:
– Changed the pin-assignment to use the Global Clock.
– Switched the unused pins from random output to tri-stated inputs.
– The bug that slows down the clock now and then should be fixed now.
– None for now.

v1.11 [27/05/2006]:
– Changed the pin-assignment to use only the outside-pins.
– Auto-reset when releasing the button to set the minutes.
– Using 41 macrocells.
– Without any reason the clock slows down now and then.

v1.10 [18/05/2006]:
– Added the possibility to keep pushing a button while time goes up. Push longtime instead of pushing multiple times.
– Rumble is no longer a problem.
– Using 40 macrocells now.
– There is no way to reset the seconds.
– Without any reason the clock slows down now and then.

v1.01 [17/05/2006]:
– Major bugfix! The trigger-problem has been solved now.
– The MAX7000s uses only 38 macrocells instead of 39. That’s one in spare for the future.
– There is no way to reset the seconds.
– Major rumble when pushing a button.
– Without any reason the clock slows down now and then.

v1.00 [16/05/2006]:
– First release so no updates yet.
– Using 39 macrocells and 19 pins.
– Because of the used counters you will see a bug in the last minute of every hour. When switching from minute 58 to minute 59 the trigger will be given to the next level to count a new hour but the reset is given at the next minute… big, big mistake! I’ll try to make a work-around asap.
– There is no way to reset the seconds.
– Without any reason the clock slows down now and then.

Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen. logo

Je reageert onder je account. Log uit /  Bijwerken )

Google photo

Je reageert onder je Google account. Log uit /  Bijwerken )


Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )

Verbinden met %s