Analog Digital Clock

5,538

56

9

About: I studied Electronics a long time ago and have worked in the past in the area of embedded software. Now I am a manager of a software team and decided to pick up embedded software development again in my spar...

The reason for making this clock was because my original IKEA clock did not work anymore and I really liked the housing of this clock. I found it a waste to throw the clock away and decided to re-use it for an analog / digital clock.

I could have made a standard clock but I decided to make something different. Like any other clock it shows the time but not in a standard way. Using 60 bi-color red/green LEDs the clock shows the time. The red LEDs are used to show the hours and the green LEDs show the minutes. The seconds are indicated by a walking yellow (red + green) LED and by a blinking yellow LED in the center of the clock.

It requires some practice to know how to read the clock. Since the LEDs are used to show both the hours and the minutes it needs a special way of presenting the time. The time is shown as a bar of LEDs where the longest bar shows either the hours or the minutes. If the longest bar is presented by the hours then the shorter bar presents the minutes in green and the remaining part shows the hours in red. In order to make the clock more readable in cases the bars are short, I added an hour indicator using the red LED. If the minutes become larger than the hours, the bars swap, that is all previous green minutes become red to show the hours and the remaining part will show the minutes so in fact almost all green becomes red and the other way around.

It is somewhat difficult to explain how it works so please watch the video. Due to the multiplexing of the LEDs it looks as if the LEDs are blinking in the video. This is only captured by the camera, not by the human eye.

As always I built this project around my favorite micro controller the PIC, using the JAL programming language but you can also use an Arduino.

Step 1: The Designs

In total I made three different versions of the clock before I was satisfied. These versions were designed as follows:

  1. Using a standard 20 MHz crystal for the PIC. With this design the clock was out of sync 1 second after one day of operation. This was too much. Next to that the time was lost when you switched off the clock since there was no back-up battery in the design.
  2. Using a DS1302 clock module. The nice thing about this module is that it has a back-up battery so the time is not lost when you switch off the clock. When I tested the clock with this module the clock was out of sync 7 seconds! after one day. I think this is caused by either the wrong crystal or a bad PCB design.
  3. Using a DS3231 clock module. This module also has a backup battery and it is more accurate than the DS1302. The clock worked fine with this module so I used this for the final design. Because of that, the PIC did no longer need a crystal.

The complete design is drawn-up in three schematic diagrams:

  1. Clock Controller using the PIC
  2. Led driver using shift registers
  3. 60 Bi-color LEDs

Step 2: Required Components

You need tohave the following components for this project:

  • A piece of breadboard
  • PIC microcontroller 16F1823
  • 3 shift register 74HC595
  • 1 Darlington Transistor Array ULN2803A
  • IC sockets: 1 * 14-pin, 3 * 16-pin, 1 * 18-pin
  • Clock module DS3231
  • 2 push-button switches
  • Resistors: 2 * 33k, 8 * 100 Ohm, 8 * 47 Ohm
  • 1 electrolytic capacitor 100 uF/16V
  • 4 capacitors 100 nF
  • LEDs: 60 2 mm bi-color (red/green), 1 5 mm yellow
  • Jack plug 3 mm
  • 5 Volt adapter, for example the one that is used for charging a Smartphone. Make sure it is a true 5 Volt power supply.
  • Optional: Headers for connecting the external parts to the breadboard
  • Kynar wire & wire stripper
  • A housing for your clock.

See the schematic diagrams on how to connect the components. It requires quite some soldering, especially for connecting the 60 LEDs. Schematic diagrams are included in the zip file.

Step 3: Building the Clock

Have a look at the pictures on how I build the clock. I started by removing the internals of the original clock after which I drilled 60 holes of 2 mm for the bi-color LEDs in the front plate. Then I painted the front plate black and added a piece of plastic to cover the hole where the original hands of the clock where positioned. Now a yellow LED is located at that position.

Then I mounted all 60 LEDs, used some hot glue to keep them at their location and connected them with Kynar wire to each other. Last but not least I assembled the breadboard with all components.

On the back cover I mounted the two push-buttons and the power Jack. Forget about the extra plate I glued on the back as show in the picture. I added that because in my first design the push-buttons were located there but I needed to move them because I had to add the DS3231 module and I could only find a spot where those buttons were when I made my first design.

Step 4: The Software

As already mentioned, the software is written for a PIC16F1823 using the JAL programming language. The PIC runs on an internal clock of 32 MHz. As mentioned earlier, the clock timing is done by the DS3231 clock module.

The software performs the following main tasks:

  • Initializing the DS3231 module using an I2C interface. The module will generate a 1 second signal which is connected to the interrupt pin of the PIC. The PIC uses this 1 second interrupt to read the time from the DS3231 module.
  • Driving the 60 bi-color LEDs via the shift registers. In the schematic diagram it can be seen that the LEDs are connected in a 16 by 8 matrix. This reduces the number of wires that are needed to connect all LEDs. This matrix design requires that the PIC needs to multiplex the LEDs as to be able to light them up individually. Multiplexing the LEDs is done on an interrupt basis where the refresh frequency is 70 Hz so invisible to the human eye.
  • Handling the push-buttons. These are used to set the time, one for setting the hours and one for setting the minutes. Both buttons need to be pressed to activate the time-setting mode. When the time setting mode is selected the yellow led will be continuously on. After 5 seconds of not using the push-buttons the clock returns to the normal time operation and the yellow LED will start to blink.

See the second video on how to set the time.

The JAL source file and the Intel Hex file for programming the PIC are attached in the zip-file. If you are interested in using the PIC microcontroller with JAL – a Pascal like programming language – visit the JAL website.

Have fun building your own project and looking forward to your reactions.

Make it Glow Contest 2018

Participated in the
Make it Glow Contest 2018

Share

    Recommendations

    • Classroom Science Contest

      Classroom Science Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Sensors Contest

      Sensors Contest

    9 Discussions

    0
    None
    p_leriche

    5 months ago

    Good to see an Instructable contributor actually giving schematics instead of just "connect this wire from here to there..."! I'd like to see one or two photos to show your methods of construction and wiring though.

    I have a 60 pixel Neopixel ring which I used in my Small Hadron Collider and which I've been meaning to do something similar with for a long time. (I'll probably make it alternately collide hadrons and tell the time.) I've also used the PIC in a couple of projects but a disadvantage for many people is that a PicKit generally costs a lot more than a PIC! (I got one relatively cheap on eBay.) I used assembler but JAL looks interesting. I wonder what tool chain you used and whether it also supports Arduino?

    2 replies
    0
    None
    RobBestp_leriche

    Reply 5 months ago

    Did you check all photo's there are a few about the wiring. I bought my Pickit3 at Aliexpress which is much cheaper than the official one and it works fine. JAL is made for PICs, there is something mentioned in relation to Arduino, at board level: http://justanotherlanguage.org/content/jaluino_int...
    The development environment for JAL is not as fancy as for Arduino. There are two Editors that support JAL, JALEDIT (which is no longer maintained) and JALIDE (which is almost bug-free :-).I edit, and compile my program with JALIDE and use the Microchip IPE environment to program my PIC with a PicKit3. In rare occasions I use MPLABX when I really need to set breakpoints at assembly level for debugging but as said this is often not required.
    If you need more info, let me know.

    0
    None
    p_lericheRobBest

    Reply 5 months ago

    Ah yes, I missed those extra pics.Very nicely wired up - I just LOVE all those coloured wires! I take it they're just soldered direct to the LED legs.

    I found the simulator in MPLAB absolutely indispensable - it meant I could completely debug the code for my Raspberry Pi intelligent MIDI interface (except the i2c slave, which was surprisingly hard) before going anywhere near a real PIC. But I found PIC assembler pretty horrid - an instruction set clearly designed by an engineer, not a programmer. In retrospect, MSP430 probably would have been much nicer to program.

    0
    None
    lboliq

    5 months ago

    Digital analog in a single sentence? Like "living dead"?

    0
    None
    snorlaxprime

    5 months ago

    Nice use of an old clock.

    0
    None
    pinheadBE

    5 months ago

    Nice design, and good idea to use JAL.
    A very good language, tons of libraries, but unfortunately, not known enough yet !
    Thanks to projects like this one, let's hope more people join the JAL community !

    1 reply
    0
    None
    RobBestpinheadBE

    Reply 5 months ago

    Thanks. I try to promote JAL as much as possible so that the community will grow. All my project on Instructables are based on JAL.