Precision frequency sources like ovenized quartz crystals and atomic frequency standards like Rubidium and Cesium output a frequency. To tell the time from them requires a clock that can use their output to form the heart of a clock. Most consumer clocks use the mains power line as a time base or a 32,768 kHz crystal an so are not easily modified for precision time keeping.
The goal of this project is to build a 6 LED digit (hh:mm:ss) clock where either the oscillator signal driving the microcontroller (uC) or a 1 Pulse Per Second ( 1 PPS) signal is the timing standard. LEDs were selected because they can be purchased in large sizes that can be seen from some distance or you can make you own even larger digits.
If you have more than one precision frequency source then if each one was connected to one of these clocks you could see if one had a real problem, since they should all be telling the same time.
As of 20 Sep 2002 all this is in the rough idea stage, no where near any firm design.
PIC 16F628-20 MicrocontrollerThis PIC can run with a clock input up to 20 MHz which is good for this application and is a Flash programming part so a UV eraser is not needed during development and also the chips can be erased and new software burned in at a later time, allowing for easy upgrades. It has a number of hardware features that make the Precision Clock much more than just a clock.
Oscillator ModeIf the oscillator that is the clock for the uC is at a frequency of 1, 5, 10 or 20 MHz the software will automatically detect the input frequency and adjust it's timing parameters for it. Using Timer1 in an interupt mode where each inturupt is a fraction of a second and then counting the ticks to make up a full second. This way a 1 PPS output can be generated with a high time of about 0.2 seconds but with a leading edge right on 1 second.
The Watch Dog Timer (WDT), which is based on an RC oscillator inside the PIC can be used during in the start up routine that runs just after power up to measure the oscillator input frequency. All the rest of the time the WDT needs to be reset to keep it from becoming active. If it does become active then there is a fault condition that might casue all the display digits to blink an error number.
The 1PPS input is connected to the Capture pin (RB3 CCP1) which will put a copy of the 16 bit value of Timer1 into a register on an edge transition. This plus the Timer 1 overflow tick count will tell the uC the difference between the 1PPS input and the leading edge of the internal 1 PPS input.
If in OSC mode and a 1 PPS signal is present during power up it could be used to set the seconds edge automatically to some precision, much better than could be done my pressing a button manually.
Input signal conditioning done using the phase comparator circuit of a 74HCT4046 PLL 16 pin chip like used in the Brooks Shea GPS disciplined oscillator.
1 PPS ModeIn this mode a low cost 20 MHz oscillator is jumpered to the uC oscillator input and the clock uses an external 1 PPS as the basis of its time keeping. A mode select jumper needs to be in either the OSC or 1PPS position to tell the uC which source to use for time keeping. If the 20 MHz oscillator is jumpered and the mode selection is set for OSC then the clock runs in a non precision mode and the accuracy will be about like a store bought clock, but the other features of the clock will remain.
The Capture input pin will generate an interupt on every rising edge. CCP1IF will be set and needs to be cleared prior to starting and after every int service. The TMR1 interupt is disabled by the software when in 1PPS mode. PEIE set to enable this interupt.
This interupt replaces the one generated by Timer1 when in OSC mode.
Leap SecondsIf the clock counted the Day of the Year (1 to 366) there could be a provision to enter the day number and polarity (+1 sec or -1 sec) of a leap second and at 23:59:59 the next second would be 23:59:60 then 00:00:00.
Back to Brooke's Products for Sale, Home page
LED MultiplexingWhen LEDs are multiplexed the current drive can be increased so that the average power stays the same as it would have been for static operation. Since power is proportional to V2/R or I2*R the drive current needs to be increased by SQRT(n) where n is the number of digits. For a 6 digit display where the normal LED current is 20 mA will need about 50 mA for each segment. This exceeds the capability of the PIC line of microcontrollers.
Digit DriversEach digit is turned on, one at a time. In the case of Common Cathode LEDs the cathode is connected to ground. Since the number "8" is displayed by turning on all 7 segments it's possible for the combined segment current flowing out of the common cathode pin to be 350 mA, far in excess of the capability of the PIC. Since the digit driver is connected to ground it's called a low side driver.
A 74HC237 3 to 8 decoder can be used to reduce the need for PIC I/O pins. Since any of the 8 outputs can be selected in software there can be 8 available digit lines - 6 display digits = 2 more digits or 2 LEDs that can selectivley be turned on and off. For each of these 8 digit positions there can also be a switch that is sensed during the digit active time.
The 74HC138 is an inverting chip, the 74HC237 (74HCT237) is a non inverting version so an 8 line inverter is not needed.
During each digit on period push button and jumper type switches can be tested. 3 push button switches are used to set the time. One is the mode button that selects the 10h, 1h, 10m, 1m, 10s, 1s then 10h digits and the "up" and "down" buttons allow changing the display (setting the clock)
Some of the possibl jumper meanings are:
- OSC as the source of time
- 1PPS as the source of time
- GPS data as the source of time
- enable time hack on 1 PPS input
- enable calendar mode (if there's enough room in the program memory)
- x,x,x,x, to be determined
In the past a chip like the Allegro 2803 would be used for the digit driver, but there are much more efficient HEXFETs available for about the same total cost although they require a little more board complexity.
Segment DriverThe segment driver connects the LED + voltage rail to the segments. All the "a" segments are wired in parallel, all the "b" segments and so on. There's one segment driver for all the digits "a" segments. There are 7 segment drivers (8 for systems that use the decimal point (dp). Since the segment driver is connected to the positive rail it's called a high side driver and requires more complex drive circuitry because the LED positive rail might be at 15 Volts for a 7" high 7 segment LED and this far exceeds the output voltage capability of the PIC.
Power SupplyWhen LED digits that have only 1 LED in each segment are used a single 5 Volt supply can run the logic and light the LEDs. For larger LEDs a separate higher voltage power supply is needed for the LEDs. Both of these could be driven from a common wall wart.
In the case of a mains failure an external battery would keep the logic going so the clock would not loose count, but the 7 segment LEDs would go dark. One of the colon single LEDs would continue to blink, showing the heart beat of the clock. This LED is connected in parallel with the 1PPS output and that's why the 20% on duty cycle.
Computer InterfaceThere's a two way RS-232 serial interface to allow a computer to set the clock and the clock can output the time.
This might be used for a number of things like displaying the time coming from a GPS receiver, hack feature: if a pulse comes into the 1PPS input when the clock is in the OSC mode is will cause an serial output with a time stamp accurate to a small fraction of a second. Maybe a jumper option to stop the display (clock keeps running in background) when a time hack occurs, a second hack would move the clock count to the display. A First In First Out stack could provide some number of hacks that were very close together and still capture them.
Time code generation to drive clocks that need one of the IRIG time codes.
NEMA data generation to look like a GPS receiver outputting the time data as well as a 1PPS signal.
First ModelBuilt to use 0.56" character height 7 segment digits so that a common +5 Volt supply can be used for development. Later, with a new printed circuit board layout, the LED and it's power supply can be separated from the logic board to support any size LED display that's desired.
Future CascadingIf the hh:mm:ss clock outputs a 1 Pulse Per Day signal at midnight then another "clock" with identical hardware could have a different uC program that would display Month - Day - Year in a mm:dd:yy format. The calendar "clock" would run in the 1PPS input mode except it would be 1 PPD and the rules for how the digits change would be the calendar rather than time rules.
The calander clock might know about leap years and the day of the week which might be displayed using 7 segment "letters".
This is the [an error occurred while processing this directive] time this PC6 page has been accessed since since 20 Sep 2002.