This is a clock with a lot of features.
It can display the time in up to 20 different locations in analogue or digital format (12 or 24 hour). Each location can be configured with its own title, time zone, daylight saving rules and type of display.
You can switch between clocks by tapping on the left or right hand sides of the display to step through the list of configured clocks.
The Super Clock can use three different time sources. An extremely accurate real time clock (RTC) module, a GPS module or an internal RC oscillator (for testing).
The Super Clock was described in the July 2016 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.
Micromite LCD Backpack
This project is based on the Micromite LCD Backpack which a combination of a low cost colour LCD display and a 32 bit microcontroller programmable in BASIC. In part this project was created to provide an example of what the Micromite is capable of so please feel free to download the BASIC program and extract portions of it for your own projects.
If you have a backpack and just want to play with the program you can do this because the Super Clock will drop into demo mode if it cannot find a real time clock (RTC) or GPS module.
The Super Clock can display up to 20 different clocks with each configured to display the time in either analogue format with hour, minute and second hands, or in normal 12 hour digital format with AM/PM indicator or in 24 hour digital format (ie, military time). These three modes are illustrated below.
To switch between the various clocks you tap on the left or right hand side of the screen to move backwards or forwards through the list of configured clocks.
To configure the Super Clock you tap on the centre of the screen and when you do this a screen such as the one shown below and on the right will be displayed. Using the CHANGE button on this screen you can step through the clock types (hidden, analogue, digital 12h and digital 24h) and this setting will apply to the current clock.
The particular screen shown on the right will be displayed if you are using an RTC as the time source. In that case the SET DATE/TIME buttons are displayed and when pressed they will take you to another screen (see below) where you can set the date and time.
If a GPS module is used the firmware will display the state of the GPS time synchronisation in this place. The status will normally be "GPS Time Synchronised" however it may display "No sync for n.nn hrs" which means that the GPS module has not been able to get a signal from sufficient satellites for the past n.nn hours (ie, if it has been two and a quarter hours since an accurate time fix it will display "No sync for 2.25 hrs").
If the GPS signal has been lost the Super Clock will use the crystal controlled oscillator within the GPS module for timekeeping. This is reasonably accurate and the clock will keep using this for up to 24 hours before it will halt and display an error message.
The PREV and NEXT buttons at the bottom of the configuration screen will take you backwards and forwards through through all 20 screens, even if they are set to hidden. This is how you setup a new clock, you step through until you find a hidden clock and then set it to visible (analogue or digital).
The CONFIGURE CLOCK button will take you to a screen where you can change the title, the time zone and the daylight saving rules for the particular clock. An example of this screen is shown on the right.
The daylight saving rules can be configured to suit most countries around the world. The actual switch to/from daylight saving is made at 2AM (non daylight saving time) except for the UK (time zone zero) when the change is made at 1AM.
The following images show some of the detailed configuration screens.
When configuring the daylight saving rules you can specify the month, the day of the week and the position of that day in the month (ie, 1st, 2nd, 3rd or last). This format suits most countries around the world.
Changing the title of a clock is easy. When you touch a letter that character is appended to the end of the title while DEL will delete the last character. The red triangles will step you through the character set.
|This is the screen used to set the clock if it is using an RTC or running from the Micromite's internal clock. The time being set is the local time for the currently displayed clock. All other clocks will then be automatically updated..|
Note that all the settings (including the current clock on display) are saved in non volatile flash memory and are automatically reinstated on power up. Because the Super Clock uses a touch sensitive screen for its setup it is easy to drive and after ten minutes you will get the hang of it and have your clocks configured.
The Super Clock can use three different time sources; a real time clock (RTC), a GPS module or the internal Micromite clock.
The RTC can be any of the types that the Micromite supports (see the Micromite User Manual) but I recommend an RTC module that uses the DS3231 chip. This can keep time to an accuracy of ±5 seconds per month which is an excellent result.
A typical module is pictured on the right. Just search eBay for DS3231 and you will get hundreds of hits.
This particular module is designed to use a LIR2032 battery which is a rechargeable Lithium Ion battery and it can be hard to find. You can also use the popular CR2032 non rechargeable battery in its place and it will last 20 or more years however, if you do this, you must disable the charging circuit by removing the diode circled in red. This is important, failure to do this could cause the CR2032 battery to catch fire.
The benefit of using a real time clock is that it will always work, whereas a GPS module can be quite unreliable - especially indoors where a tin roof, a double story house, rain and other factors can make it impossible to get a GPS signal. However, if you have a reliable signal a GPS module makes an excellent time source - it never needs setting and the time is always correct within a fraction of a second.
Note that after the GPS module has its first lock on the satellite signal the Super Clock will keep going even through extended periods without a satellite signal. This is because the software will use the crystal based clock inside the GPS module if the signal should vanish and it will keep doing this for up to 24 hours. This is a long time and usually the signal will reappear within that time. As a result, the clock will continue to display an accurate time despite intermittent loss of the GPS signal.
The Super Clock will first try for a connected RTC module. That only takes a few milliseconds and if that is found it will immediately startup displaying the time.
If an RTC is not found the display will show a message "Searching for GPS" and the software will then search for a valid GPS signal on COM1. The search takes about ten seconds and involves scanning the standard baud rates between 4800 baud and 56,300 baud for both the standard (TTL) polarity and the inverted (RS232) signals. This is the same function as the Boat Computer and you should refer to that article for details of how the software works and suitable GPS modules.
If the GPS module was not found the software will display a dialog box stating that neither the RTC or GPS can be found. When you touch the OK button the clock will then carry on using the internal clock within the Micromite. This is reset to 1st January 2010 on power up and is not very accurate but it is useful for when you just want to experiment with the software without connecting an RTC or GPS module.
Aging Register Adjustment
If you are using a DS3231 RTC module the SET TIME button in the configuration screen has an additional feature; if you hold it down for five or more seconds you will be taken to the Aging Offset setting for the DS3231.
This can be used to trim the DS3231's crystal oscillator to achieve an even greater accuracy than normal. By default the aging offset value is set to zero but you can set it to any number from +127 to -127. Typically a change of plus or minus one will change the clock's timing by 0.1 part per million, which is about a quarter of a second over a month. Incrementing the number will slow down the clock and decrementing will speed it up.
The Super Clock is really just a Micromite LCD Backpack with a time source (RTC or GPS) and a BASIC program.
The Micromite LCD Backpack consists of a 28-pin microcontroller with a low cost LCD display and less than a dozen other components and can be built in half an hour. If you are not familiar with it you should read this web page for the full description and assembly instructions.
Another component that you need to be familiar with is the standard 28-pin Micromite and this page provides a short description of it. For further information it is worth downloading the Micromite User Manual which covers every aspect of the device.
The RTC or GPS connect directly to the backpack as illustrated below
The DS3231 chip used by the RTC module uses the I2C protocol to deliver the time so it connects to the I2C signal lines on the backpack (pins 17 and 18).
The DS3231 chip can run from either 3.3V or 5V but 5V is needed to power the battery charging circuit (if a rechargeable battery is used) so it is shown connected to that supply.
Remember to disable the charging circuit (described above) if a non rechargeable battery is used.
The GPS version can work with modules that require either 3.3V or 5V. Just connect the power lead to the correct supply on the Micromite LCD Backpack.
The GPS module uses a serial interface and the 1K resistor and diode are necessary to protect the Micromite in case the GPS module is using RS232 signaling. However, if you are sure that your module uses TTL signal levels (most do), you can dispense with the diode and replace the resistor with a wire link.
In both cases the main power supply (+5V) to the backpack is shown using a USB connector and this enables you to use one of the many cheap USB chargers that are available. You could also use a regulated 5V plug pack or wall wart but make sure that it does have a regulated output and its voltage will not rise above 5.5V when unloaded.
Loading the Firmware
If you do not have a PIC32 programmer you can purchase a 28-pin PIC32 microcontroller from Silicon Chip magazine pre programmed with the full firmware (ie, SuperClockFull2.hex) by following this link. This makes it very easy, all that you need do is just plug the chip into its socket on the PCB.
Silicon Chip also offer a full kit of parts for the Super Clock including the Micromite LCD Backpack, their front panel, RTC or GPS module, the PCB, etc. Follow the above link if you are interested.
The Super Clock hex file includes four components. The Micromite firmware including the BASIC interpreter, the option settings for the LCD display, a set of embedded fonts and the BASIC program for the Super Clock. These components can be loaded individually and the method for doing this is explained in the Micromite User Manual (refer to the chapter titled "Micromite LCD Backpack").
If you wish you can separately download the fonts and BASIC program from below - this is especially handy if you just want to play with the BASIC program on a Micromite LCD Backpack that you have already built and configured.
This is a combined firmware file that contains the Micromite firmware configured for the LCD panel, the fonts loaded into the library and the BASIC Super Clock program.
|Super Clock BASIC Program
(includes SuperClockFonts.bas and SuperClock.bas)