Maximite Family
  • Colour Maximite 2
  • Original Colour Maximite
  • Monochrome Maximite
  • The Maximite Story

  • Micromite Family
  • Micromite Summary
  • Standard Micromite
  • Micromite Plus
  • The Microbridge

  • Micromite LCD Backpack
  • Micromite LCD Backpack
  • Air Quality Monitor
  • DDS Signal Generator
  • Super Clock
  • Boat Computer MkII
  • Parking Assistant

  • BASIC on Raspberry Pi Pico
  • BASIC Interpreter
  • Boot to BASIC Computer

  • Other Projects
  • Precision Analog Clock
  • Windows/DOS MMBasic
  • ASCII Video Terminal
  • Utility Power Supply
  • Precise Voltage Reference
  • ISM Band Scanner
  • Game of Pong
  • Simple GPS Based Clock

  • Useful Techniques
  • Measuring Capacitor ESR
  • Surface Mount is Easy
  • Programming PIC Micros
  • Custom PC Boards
  • The Gerber Format

  • General Articles
  • Problems in Open Source
  • Hantek DSO-2250 Scope
  • Rigol DS1000 Scope
  • Brickbats

  • WEB Site
  • Home
  • Old or Obsolete Projects
  • About



  •  

     

     

    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Australia (CC BY-NC-SA 3.0)

    Precision Analog Clock

     

    Are you tired of having a wall clock that is always a little too fast or too slow?  Is adjusting the hands for daylight saving a chore that you would rather not do?

    How about a clock that is always accurate - to the second?

    This project will convert an ordinary wall clock into a precision timepiece that will stay accurate to within a few seconds and has a battery life of up to eight years using two C size cells.

    Even better, you will not have to adjust it for daylight saving - this clock driver will automatically do it for you by advancing the hands by one hour at the start of daylight saving and retarding the hands by the same amount at the end of daylight saving.

    This is a clock that you never have to touch and will always tell you the correct time.



    How is this precision achieved?   It is done using a low cost GPS module to get the accurate time and some clever firmware to control the clock's hands.

    The Clock Driver will cost about US $30 in parts to build and the whole thing can be put together in a few hours. The full construction details are provided below and the firmware is completely free to download and use.

    Almost any analog wall clock can be used. All that you need do is modify the movement to disconnect the internal controller and bring out the connection to the clock's motor.  The new controller described on this web page will take over the job of controlling the hands and will keep them accurate to within seconds.

    The image on the right shows the controller board with two AA batteries mounted on the back of a modified Ikea TJALLA sweep clock.

    This project was described in the September 2022 issue of Silicon Chip magazine.  This web page provides a shorter description so, if you would like the full story, you are encouraged to read the magazine article.  Back issues of the magazine can be purchased from Silicon Chip or electronic access can be purchased for about the cost of the printed issue - so it is good value.

    Clock Types

    There are two types of wall clocks that are generally available for the home.  Stepping clocks where the second hand moves once a second (often with a loud "tock" sound) and sweep clocks where the second hand moves continuously and silently around the dial. 

    Stepping clocks are the most simple and the motor in them must be driven with alternating positive and negative pulses delivered once a second and with a pulse width of 30 to 40 ms.  With each pulse the clock will advance by one second. The top oscilliscope capture below shows this waveform.

    Sweep clocks use a continuous stream of alternating positive and negative pulses with each pulse 31.25 ms in width and an idle time of 31.25 ms between each pulse.  This means that there will be 16 pulses in each second and the frequency of the drive is 8 Hz.  This waveform is also shown on the right. 

    Within the sweep clock's motor the momentum of the spinning rotor will keep it moving between each pulse so the second hand will move continuously (ie, sweeps) around the dial.

    In both cases the pulses needs to be between 1 V and 1.6 V (ie, the output of a standard carbon or alkaline cell).  The clock driver will increase the pulse width at low battery voltages so sweep clocks should continue to operate with a battery voltage of 0.95 V or even less while stepping clocks will typically stop with a drive voltage of 1.0 V or less.

    Stepping clocks are more common and can be found in most general stores while sweep clocks are often harder to find and more expensive.  However, a standout example of a good sweep clock is the Ikea “TJALLA” which cost just US $13 at the time of writing (most Ikea clocks use a sweep movement).

    The firmware within the Clock Driver will automatically take care of the details so you can use whatever type of clock you fancy.  The battery life for either type is similar and the only real difference is that stepping clocks generally make a loud "tock" sound every second while sweep clocks are silent.

    How It Works

    The Clock Driver is based on the Microchip PIC16LF1455, a low cost microcontroller which has a very low power consumption.  Referring to the block diagram below, the microcontroller has a 32.768 KHz crystal oscillator which drives a 16-bit timer.  Both of these will continue to run when the CPU is put to sleep and have a current drain of just a few microamps.

    When it is time to generate a pulse for the clock's motor the timer will wake up the CPU which will drive its output high or low to initiate the pulse.  Following this it will reset the timer for the required pulse width and go back to sleep again.  When the timer re-awakens the CPU, the CPU will terminate the pulse by setting its output to high impedance, reset the timer for the start of the next pulse and go back to sleep again.

    This continues forever with the CPU jumping in and out of sleep while toggling its output pin.  Most of the time the microcontroller is sleeping and, as a result, its average current consumption is quite low at about 18 µA.

     

     

    IC2 is an operational amplifier and its job is to buffer the signal and drive the clock's motor.  When its output is driven high the current for the clock's motor will be drawn from the top battery and conversely, for a negative pulse, the current will be drawn from the lower battery.  At idle between pulses its output will be at the midpoint of the two batteries so no current will be drawn. As a result, the power needed to drive the clock's motor will be divided evenly between the two batteries.  Typically a clock's motor will draw 140 to 170 µA (average) which, by using this arrangement, is 70 to 85 µA per battery.

    GPS Synchronisation

    After generating the output pulse the microcontroller will check if it is time to synchronise the position of the clock's hands with the time from the network of GPS satellites (which is accurate to within microseconds).  Initially the interval between synchronisations is set at 12 hours but over time this will be progressively increased up to 5 days.

    The recommended GPS module
    (a V.KEL VK2828U7G5LF).

    If it is time to synchronise, the CPU will not go to sleep but will drive the enable pin of the DC to DC converter to start it operating.  This is a Microchip MCP16251 which is configured to generate an output of 4 V and this is used to power the GPS module (a V.KEL VK2828U7G5LF).  After a short time (typically less than a minute or two) the GPS module will have a lock on enough satellites to return an accurate time to the firmware running on the microcontroller.  The microcontroller will then turn off the DC to DC converter to conserve the battery.

    While waiting for the satellite signal the DC to DC converter and the GPS module can draw quite a lot of current (as much as 100 mA) but, as this occurs infrequently, the drain on the batteries averaged over a long time is quite low at about 5 µA.

    With the correct time the firmware can then adjust for any error by driving the clock's hands faster or slower to make them agree with the time from the GPS module.  For a stepping clock this is done by stepping twice in a second or skipping a step entirely.  For a sweep clock the pulse train will run fast or slow by 12.5% for eight seconds thereby adding or subtracting a second in that time.

    The firmware will also calculate what corrections will be needed from time to time to keep the hands accurate during the following period up to the next synchronisation.  This takes the form of occasionally running fast or slow enough to add or subtract a second as needed.  As a result, the hands will stay accurate during the entire period.

    This correction mechanism will start operating after the first day or two after the clock has started running and will continue for the life of the batteries.  Therefore the clock will always be accurate, regardless of any error in the 32.768 KHz crystal's frequency or other factors such as ageing of the crystal.

    Daylight Saving

    When configuring the clock driver (described below) you can specify if daylight saving compensation should be applied and the rules for your particular location.  The firmware is flexible enough to cope with the daylight saving requirements for most countries around the world, although there are some that are just too complicated (for example Iran).

    At 2:00 AM on the day specified for the start of daylight saving the clock will run fast to add the required hour.  For a stepping clock it will step twice a second for an hour but for a sweep clock this will take eight hours because it cannot run as fast as a stepping clock.  At 3:00 AM on the day specified for the end of daylight saving a stepping clock will subtract an hour by stopping its hands for exactly one hour while a sweep clock will subtract an hour by running slow for eight hours. 

    In the United Kingdom (time zone zero) the daylight saving start and end times are one hour earlier.

    Following the adjustment for daylight saving the clock will resume its normal activity, keeping the time accurate to within a few seconds. 

    Configuring the Clock Driver

    The Clock Driver defaults to a stepping clock with no daylight saving.  So, if that is all that you need, you do not need to configure anything.

    However, most people will need to configure the Clock Driver and you do this using the mini USB socket mounted on the driver board.  When the batteries are inserted and the USB is plugged into a PC or laptop the LED on the PCB will flash three times to indicate that the firmware is in configuration mode and the Clock Driver will connect to your PC as a virtual serial port over USB. 

    When doing this it will imitate the Microchip MCP2200 USB/serial converter.  Windows 10 and 11 are delivered with the correct driver installed but with other operating systems you may need to load a driver, and this can be found on the Microchip website at http://www.microchip.com/wwwproducts/en/MCP2200.

    You also need to install a terminal emulator such as Tera Term (http://tera-term.en.lo4d.com) or Putty. This will display any text sent by the Clock Driver and send any keystrokes that you make back over the serial USB interface.  You need to configure the terminal emulator with the number of the virtual serial port created by your operating system but other than that everying (including the baud rate) can be left as the default.

    When you hit the Enter key you should see the header as shown on the right.  Incidently, this shows the configuration required for the east coast of Australia.

    The first question is "Sweep Clock (Y/N) ?" and if you reply N followed by the Enter key you will configure the driver for a stepping clock.  On the other hand Y will configure it for a sweep movement.

    Next is "Use Daylight Saving (Y/N)?".  If you reply N you are finished and you will be prompted to unplug the USB cable. 

    On the other hand, if you reply Y you will then need to enter three bits of information for both the start and end of daylight saving.

    These are:

    Finally, you need to enter the time zone in the format +nn.n or -nn.n.  For example, Los Angeles is -7.0.

    With this done you will be prompted to unplug the USB and the clock will restart, as if the batteries had just been inserted and it will run through its startup process (see below).  This configuration only needs to be done once and it will be remembered, even when you change the batteries.

    Starting the Clock

    Before you start the clock you need to set the hands to exactly the next hour or half hour (whichever will come first).  Then insert the batteries.

    The firmware will then go into its startup routine.  This consists of:

    When you set the hands of the clock the second hand will probably not be in the correct position.  If you hold down the tactile switch on the PCB while the clock is waiting to start the firmware will drive the second hand around the dial and you can release the button when it reaches the 12 o'clock position.  That way the clock will start running with the second hand in the correct position.

    Sometimes, when the clock starts running, the hands may start moving a second or two early or late.  If you are particularly concerned you can check for this by using the National Institute of Standards web site (www.time.gov) to get the precise time and correct for even this slight startup error. 

    To do this hold down the tactile switch (while the clock is running) until the LED illuminates, then if you:

    Note that this should only be used after startup to correct for any startup error.  It is not needed while the clock is running normally and if it was used later it would interfere with the automatic correction mechanism built into the firmware.

    If the GPS module is brand new, it can take up to 45 minutes to get its first lock on the satellite network. In this case you should place the clock outside with the GPS module pointing to the sky and leave it there for a while.  The GPS module will store important satellite information in its internal flash memory so, following this initial startup, subsequent synchronisation's should take less than a minute or two. 

    When the batteries are installed the firmware will wait forever for a signal but after this the firmware will only wait for 30 minutes for subsequent synchronisation's and then, if no signal was received, give up and retry in 24 hours.  In this case the LED will flash once a second as a warning that there was an insufficient signal.

    Battery Life

    In the design of the GPS Clock Driver particular attention was given to minimising the power consumption and thereby lengthening the life of the batteries. 

    The clock's motor, the microcontroller and other circuitry will draw a total of about 90 to 110 µA from each battery averaged over the long term.  Typical high quality AA batteries have a capacity of more than 2000 mA/h (terminating at 1 V) so, using these, the clock should run for about two years. High quality C cells have a capacity of about 8000 mA/h meaning that up to eight years is possible with these.  However, in this case the batteries' internal leakage over this long time might reduce their lifetime.

    You can also use AA sized Lithium Primary cells (ie, Energiser Lithium/Iron Disulfide) which have a capacity of about 3400 mA/h (with a light load and terminating at 1.2 V).  These have a very long shelf life (20 years) so most of their capacity would be used to drive the clock and you could expect a battery life of about 3½ years.

    If your clock stops running early it would be worthwhile measuring the voltage of the batteries when you remove them.  Most clock movements will keep running down to 1 V or below and that is the sort of voltage that you should find.  However, if your clock stopped running with a battery voltage significantly higher than this (say 1.1 V or 1.2 V), then that indicates that the clock movement is faulty and should be replaced.  Note that this does not apply if you are using Lithium Primary cells as their output voltage will revert to about 1.2 V when removed from the clock, even though they are fully discharged.

    Construction

    The Clock Driver is built on a PCB measuring 99 mm x 5 7mm.  This includes the battery holders for two AA batteries. 

    If you wish you can cut off the portion of the PCB with the battery holders and mount the batteries separately.  This particularly applies if you are using C cells or if you do not have enough space for the full size PCB.  The photo on the right shows such an installation using C sized batteries in separate battery holders.

    Rather than list the boring detailed construction data (parts list, assembly notes, schematic, etc) on this web page I have bundled all of this into the "Construction Pack" which you can download from below.  This includes everything that you need to know to build the Clock Driver including how to modify your clock and much more.

    Finding the required parts can be tedious so if you do not want to do that you can buy a complete kit of parts including the PCB from Silicon Chip magazine.  This includes the microcontroller pre programmed with the firmware, so all you need do is solder it in and you are ready to go.  For the full details see the September 2022 issue of Silicon Chip.

    Downloads

    Construction Pack (parts list, schematic, PCB manufacturing files, etc) DOWNLOAD
    GPS Clock Driver Firmware V1.0 DOWNLOAD
    Firmware Source Code V1.0 (Note: Requires Microchip XC8 Pro compiler V1.44) DOWNLOAD