Silicon ChipA GPS-Synchronised Clock - March 2009 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Carbon trading may not be needed in Australia after all
  4. Feature: Reviving Old Laptops With Puppy Linux by Warrick Smith
  5. Feature: Digital Radio Is Coming, Pt.2 by Alan Hughes
  6. Project: A GPS-Synchronised Clock by Geoff Graham
  7. Project: New, Improved Theremin Mk.2 by John Clarke
  8. Project: Build A Digital Audio Millivoltmeter by Jim Rowe
  9. Project: Microcontrollers Can Be A Snap by Stan Swan
  10. Vintage Radio: The deadly and the difficult: when to say "no" by Rodney Champness
  11. Book Store
  12. Advertising Index
  13. Outer Back Cover

This is only a preview of the March 2009 issue of Silicon Chip.

You can view 32 of the 96 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Digital Radio Is Coming, Pt.1 (February 2009)
  • Digital Radio Is Coming, Pt.2 (March 2009)
  • Digital Radio Is Coming, Pt.3 (April 2009)
  • Digital Radio Is Coming, Pt.4 (June 2009)
  • Digital Radio Is Coming, Pt.5 (August 2009)
Items relevant to "A GPS-Synchronised Clock":
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • GPS-Synchronised Clock PCB pattern (PDF download) [04203091] (Free)
  • PIC16LF88-I/P programmed for the GPS Synchronised Clock for stepping hands [0420309A.HEX] (Programmed Microcontroller, AUD $15.00)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • PIC18LF88 firmware and C source code for the GPS-Synchronised Clock with stepping hands [0420309A.HEX] (Software, Free)
Articles in this series:
  • A GPS-Synchronised Clock (March 2009)
  • GPS Synchronisation For Clocks With Sweep Hands (November 2009)
Items relevant to "New, Improved Theremin Mk.2":
  • Theremin Mk.2 PCB [01203091] (AUD $15.00)
  • Improved Theremin Mk.2 PCB pattern (PDF download) [01203091] (Free)
  • Improved Theremin Mk.2 front panel artwork (PDF download) (Free)
Items relevant to "Build A Digital Audio Millivoltmeter":
  • Digital Audio Millivoltmeter Input Attenuator front panel artwork (PDF download) (Free)
  • Input Attenuator PCB for Digital Audio Millivoltmeter [04205091] (AUD $7.50)
  • Digital Audio Millivoltmeter PCB [04103091] (AUD $20.00)
  • PIC16F88-I/P programmed for the Digital Audio Millivoltmeter [0410309A.HEX] (Programmed Microcontroller, AUD $15.00)
  • PIC16F88 firmware and source code for the Digital Audio Millivoltmeter [0410309A.HEX] (Software, Free)
  • Digital Audio Millivoltmeter PCB pattern (PDF download) [04103091] (Free)
  • Digital Audio Millivoltmeter front panel artwork (PDF download) (Free)
Articles in this series:
  • Build A Digital Audio Millivoltmeter (March 2009)
  • Input Attenuator For The Digital Audio Millivoltmeter (May 2009)

Purchase a printed copy of this issue for $10.00.

Tired of resetting the time on your wall clock? This GPS circuit will convert a standard battery wall clock into a precision timekeeper that never needs to be corrected. It will even automatically adjust for daylight saving time. GPS Synchronised Clock By GEOFF GRAHAM B attery-powered quartz crystal clocks are very common and they keep good time, with a typical accuracy of two seconds per day. However, that couple of seconds can add up. After a month it could be a minute out and after a few months, you are up on a chair again to reset it to the correct time. Wouldn’t it be nice if you never, ever had to do that again? This design replaces the electronics in a standard quartz wall clock with a controller that synchronises itself via the GPS (Global Positioning Satellite) system. It uses a relatively inexpensive (US$70) GPS module to get the precise time and a microcontroller to control the hands of the clock. It will run for about a year on two alkaline AA batteries and over that period will keep the time accurate to within a few seconds. Even better, it understands the rules of daylight saving (DST) and will automatically adjust by skipping forward an hour at the legislated time and date when daylight saving starts. When 22  Silicon Chip daylight saving stops, the clock will stop for exactly an hour at 3.00AM, – and start again when the indicated time is correct. It is also easy to use. All you need do is set the hands of the clock (including the seconds hand) to the 12 o’clock position and then insert the battery. The controller will use the GPS to get the current time and then step the clock hands at double speed around the dial until it has reached the correct time. It will then drop back into normal timekeeping mode with the time derived from a crystal oscillator. To conserve the battery, the GPS module is only used to synchronise the clock every 44 hours and following synchronisation, the clock will either skip seconds or double-step to reach the correct time. After synchronisation the microcontroller is also able to calculate the inherent inaccuracy of its crystal oscillator and will compensate by occasionally skipping or doublestepping a second. This process can also compensate for aging of the crystal and will keep the clock accurate between synchronisations. The controller also monitors the battery voltage and when it has dropped below 2V, the microcontroller will stop the clock at exactly 12 o’clock. You then replace the battery and it will repeat the start-up process by stepping to the correct time. In short, you never have to set the time. How it works First of all, let’s look at a standard battery-operated wall clock. It uses a crystal oscillator and a divider to generate a pulse every second to drive a simple stepper motor and, via gears, the hands of the clock. The crystal oscillator is normally quite accurate, especially when the clock is new – but it’s affected by age, by temperature, by battery voltage . . . all of which can add up to seconds a week. Our circuit replaces the clock’s electronics and generates compatible pulses to drive the stepper motor. The heart of our controller is a PIC16LF88 microcontroller which siliconchip.com.au It looks just like a bog-standard battery-powered wall clock and in fact, it started out life as such. But it’s only when you turn it over . . . uses a 32.768kHz watch crystal to drive a timer within the chip. This timer generates an interrupt which is used by the software running on the microcontroller to keep time. The software is where all the hard work is done and it is quite complex. As an illustration of this complexity, drafting the circuit of the GPS Clock took just a few hours, while the software took many weeks to develop. A normal clock cycle starts at the beginning of a new second. The timer will generate an interrupt which causes the processor (CPU) in the microcontroller to wake up and execute the interrupt code. The program will perform some calculations (more on this later) and then raise the voltage on one of the clock lines. It then sets the timer to generate another interrupt exactly 40ms after the first interrupt (you can change this) and promptly puts itself back to sleep. After 40ms, the timer will wake the CPU again and the program will lower the voltage on the clock line, terminating the pulse to the clock’s stepper siliconchip.com.au You can see it has something that’s not bog standard – a GPS module, microprocessor and driver. And no, we haven’t forgotten to put the clock movement battery in! motor. The program then will set the timer to 960ms and go back to sleep. This repeats, second after second. During the sleep period, everything except the crystal oscillator and the timer is shut down, resulting in a current drain of only a few microamps drawn by the microcontroller. In addition, the CPU in the microcontroller will run at full speed for only 60μs to 100μs while processing an interrupt, so the total current drawn by the microcontroller is negligible. Most of the current, in fact, is drawn by the clock stepper motor – which is the case with a “standard” battery-operated clock (see the box: Calculating Battery Life). At the start of a new second the program compares where the clock hands are actually positioned and where we would like them to be. The software does this with two variables, which hold the current position of the clock’s hands in seconds and the desired position. Depending on the result of this comparison, the program will bring the clock’s hands closer in agree- ment to the correct time by skipping a pulse to the clock’s stepper motor or by generating a double step. Normally the variable representing the desired position is simply incremented every second but the beauty of this arrangement is that we can control the position of the clock’s hands just by changing this variable. The code within the interrupt routine will automatically bring the hands of the clock into agreement. This is useful when, for example, daylight saving starts – we simply add 3600 seconds (one hour) to the desired position and the clock will fast forward until it is an hour ahead. When it is time to synchronise, the program will keep running after an interrupt (ie, it will not return to sleep). It then applies power to the GPS module and waits for the GPS to return an accurate time reading. With this reading the microcontroller has some hard work to do – it must convert it into an internal representation (seconds since 1st January 2000), apply the time zone offset, calculate if daylight March 2009  23 K 10k D1 A CONFIG S1 4 14 Vdd MCLR B RA4 3 4.7k 10 F SERIAL RS-232C CON1 22k E B 16 9 C IC1 RA2 PIC16LF88 L1 40 H 220 F LOW ESR 4 1 3 6 IC2 MAX756 5 1 4.7k 13 X1 32.768kHz 22pF 22pF 12 T1OSC1 RA3 RA0 T1OSC0 Vss 5 RA1 2 220 F LOW ESR 2 7 100nF 47 100nF 1k 5 1 17 STARTUP A 18 LED1 270 1 2 3 4 5 3V 5V GPS VOLTS SELECT 10k 10 K 8 RB3 RB4 3V BATTERY (2xAA ALKALINE) D2 1N5819 C RB5 RA7 E A Q1 BC557 11 220 Q2 BC327 100nF 100k 3 4  2 K PC BOARD EM-408 CONNECTIONS V+ EN Rx Tx EM-408 GPS MODULE GND CON2 TO CLOCK MECHANISM 1N5819 A SC 2009 GPS SYNCHRONISED CLOCK D1: 1N4148 A K BC327, BC557 LED K K A B E C Fig.1: while it looks very simple (and construction-wise, it is!) there’s a lot going on in this circuit, especially in the PIC microcontroller. Full operation is explained in the text. saving applies, calculate the internal crystal oscillator error, and more. When it is finished, the program will copy the correct time into the variable representing the desired position for the clock’s hands and put the CPU to sleep, ready for the next second. The GPS module NMEA standard for data output and generate a serial data stream at 4800 baud with eight bits per character. The voltage is inverted with respect to RS232 and uses TTL voltage levels but otherwise it is the same serial data standard used by desktop computers. The NMEA standard also describes the content of the data and we use the RMC (Recommended Minimum data) We normally think of a GPS module as a device to find our position on the globe. However, the GPS system is based on time signals derived from an extremely accurate atomic clock and as part of their output, they also give the time and date based on that clock. In fact, most time standard bodies around the world use the GPS system as a “standard beacon” to transfer accurate clock readings between each other. If you think that it is a waste to discard the latitude and longitude data, as we do with this circuit, then pretend that the module is merely an atomic clock The GlobalSat EM-408 GPS module used receiver at a cheap price! in this project. Other modules may work Most GPS modules follow the fine but we know this one does! 24  Silicon Chip message which is the default for almost every GPS module made. Finally, the PC board allows you to set the voltage (via a jumper) to power the GPS module (3.3V or 5V). As a result the clock controller will work with almost any GPS module. Regardless of this, we recommend that you use the EM-408 module produced by GlobalSat in China. It includes everything (antenna and data connector), it is available from many suppliers on the internet (see the parts list), it is relatively cheap and most importantly, we know that it works. The EM-408 uses the SiRF StarIII chipset, one of the most sensitive GPS chipsets on the market. So, if your normal GPS receiver can work where you intend to place your clock, this will also work. Circuit description The full circuit is shown in Fig.1 and the key component is IC1, a PIC16LF88 microcontroller. This drives the clock’s stepper motor, controls the power to the GPS module and siliconchip.com.au R 3V + 10 F 4148 X1 22pF 32kHz 22pF 10k 100nF 22k 4.7k 100k D1 220 EN GND Rx Tx Vcc 10k 100nF interprets the output of the module. The specified chip (with LF in the middle) is the wide voltage version of this common microcontroller and is guaranteed to operate down to 2V, whereas the standard chip (PIC16F88) is only guaranteed to 4V. Having said that, you will probably find that a standard PIC16F88 will operate without fault to below 2V. So, if you have a PIC16F88 in your parts box, give it a go before hunting for the LF version. The 100kΩ resistor and 10μF capacitor connected to pin 4 of IC1 serve to hold the microcontroller in reset for about a second after the batteries have been inserted. This provides enough time for you to properly seat the batteries in the battery holder before the microcontroller starts executing its program. Diode D1 prevents the capacitor from discharging into the microcontroller when the batteries are removed. The serial interface connector CON1 is linked to the microcontroller via a few protective resistors. This design siliconchip.com.au GPS MODULE Vcc Tx Rx GND EN 220 F 1k 5819 IC1 16LF88 D1 CON1 S T 9002 © 19030140 PRESS ON STARTUP 47 IC2 MAX756 100nF S1 LED1 + 5V CON2 Q2 o 4.7k 220 F 47 H 2 x AA CELL HOLDER Q1 + L1 TO PC 270 TO CLOCK relies on the fact that nearly all modern serial RS232 interfaces use a threshold of about 1.5V between a high and low signal. This is not what the full RS232 standard specifies but we use this fact to provide a simple interface to a personal computer for configuring the clock. Crystal X1 provides a stable timebase for the clock with the two 22pF capacitors providing the correct loading. Normally the accuracy of the clock between GPS synchronisations would be dependent on trimming these capacitors to achieve a frequency of exactly 32.768kHz but as the software automatically corrects for any errors, this is not required. The microcontroller applies power to the GPS module by pulling its pin 3 low. This turns on the Darlington transistor pair of Q1 and Q2, resulting in about 2.7V (with fresh AA cells) appearing at the collector of Q2. This voltage is stepped up by IC2, a MAX756 DC-DC converter. IC2 operates by drawing a current through inductor L1 and then suddenly cutting Fig.2: the component overlay for the GPS Synchronised Clock controller board, along with matching photograph below. Not shown here but mentioned in the text is the fact that an IC socket should be used for the microcontroller (IC1) but should NOT be used for IC2 due to the currents involved. The two AA cells on the left side of the PC board should last for at least a year in this application. it off. The collapsing magnetic field causes a positive voltage spike across the inductor that is dumped via diode D2 into the 220μF capacitor. IC2 can operate with a low supply voltage and still deliver a closely regulated output of 3.3V or 5.0V. The actual output voltage is controlled by pin 2 and this can be configured on the PC board to suit the GPS module in use. L1 must have a saturation current rating of 1A or greater. This means that it should be wound with heavy gauge wire on a powdered iron core; an RF choke will not work. The parts list provides two alternatives. Also, both the 220μF capacitors must have a low ESR (equivalent series resistance). Diode D2 is a 1N5819 Schottky type specified for its low voltage drop. Don’t be tempted to substitute an ordinary silicon diode as its higher voltage drop will lower the efficiency of the DC-DC converter and limit its operation at low battery voltages. Note that with a minimum battery voltage of 2V and a 0.7V drop through March 2009  25 Calculating Battery Life With an application such as this, battery life is important. After all, what is the point of a clock that does not need adjustment if you are forever changing the batteries? To calculate the battery consumption, we need to divide the activity of the circuit into phases according to the current drawn from the battery. Then, for each phase, we determine the current consumption and its duty cycle (the percentage of time that the current is drawn). Finally, we can calculate the average current drawn per hour and then the battery lifetime for a given capacity of battery. The table below is the result for our prototype. This table clearly indicates what is the major power user and this is the current drawn while driving the Function PIC in sleep Clock step pulse During GPS synch Battery self discharge* Current Draw (mA) 0.004 6 80 0.009 clock’s stepper motor. This is where you should concentrate your efforts if you wish to improve the battery life. One way to do this is to reduce the width of the pulse using the set-up menu. Another option would be to increase the value of the 270Ω resistor which limits the current drawn by the clock’s stepper motor. If you experiment with either of these options you should connect a variable power supply in place of the batteries and test that your clock steps correctly at less than 2V, the minimum expected battery voltage. Don’t just test it on its back either; stand the clock upright in its normal position as you might find that the stepper motor does not have enough power to lift the second hand against gravity. On Time (seconds) 158355 0.04 45 1 Total Time Duty Consumption (seconds) Cycle (mA hour) 158400 99.97% 0.004 1 4.00% 0.240 158400 0.03% 0.023 1 100.00% 0.009 TOTAL DRAIN (mA hours) 0.276 Lifetime for alkaline AA cells (capacity of 2400 mA hours*) in months * source: Energiser Alkaline Handbook Alk1.1 Q2, the voltage delivered to IC2 can be as low as 1.3V. The MAX756 has a typical minimum start-up voltage of 1.1V, so normally it should be OK. However, the specs for the MAX756 say that this might be as high as 1.8V on some devices. So, if you get one of these 12.1 chips, you might find that the clock will shutdown (stop at 12 o’clock) before the battery drops to 2V. This is unlikely but the only solution is to try a few different chips. All our samples worked without fault. IC2 generates a reference voltage of 1.25V which is used in regulating its output voltage. This reference voltage is also made available at pin 3 of the chip and we pass it back to the microcontroller which uses it as a reference to measure the battery voltage. By accurately measuring the battery voltage, we can stop the clock at the 12 o’clock position before the batteries get too low to operate the microcontroller. Incidentally, the microcontroller is programmed to measure the battery voltage at the time of greatest current draw (about 160mA) when the GPS module is starting up. If you measure the battery voltage without a load, you will probably get a higher reading. The GPS module is one of the simpler parts of the circuit. It has two connections for power, two for communications to the microcontroller (transmit and receive data) and an enable signal. We pull the enable line high with a 1kΩ resistor so that the module is always enabled when power is applied. As we do not send anything to the GPS module (the manufacturer’s default configuration suits us just fine), the receive data line is also pulled high by the same 1kΩ resistor. The 10kΩ resistor on pin 10 of the microcontroller limits the current into the microcontroller when the GPS module operates at a higher voltage. The microcontroller drives the clock stepper motor from pins 17 and 18. The 270Ω resistor limits the current so that the coil of the stepper motor sees about 1.5V, which is the normal supply for There is usually plenty of room (assuming the clock is large enough!) to fit the PC board, which includes the 2x “AA” battery holder and the GPS module. It can be held in place with some double-sided adhesive foam pads. 26  Silicon Chip siliconchip.com.au DB-9 FEMALE CONNECTOR (SOLDER SIDE) Parts List – GPS Synchronised Clock (3.5mm STEREO PHONE PLUG) 9 5 4 3 S R S R T T 2 1 6 Fig.3 construction of the cable that connects the clock controller to a standard PC. You will need this if you want to change the settings. this type of clock. The clock pulses alternate so that the first clock pulse is delivered by momentarily raising pin 17 high while pin 18 is held low – this will step the clock’s hands by one second. For the next second this is reversed and pin 18 is taken high while pin 17 is held low. This cycle is repeated to drive the clock’s hands around the dial. Construction All of the components for the GPS Clock, including the GPS module and the AA cell holder, are mounted on a PC board measuring 140 x 57mm and coded 04203091. The component overlay is shown in Fig.2. Check the board carefully for etching defects, shorted tracks or undrilled holes. Then install the four wire links on the board and continue with the low profile components, moving up to the transistors and capacitors. When mounting the battery holder, use double-sided adhesive tape or put a dab of glue on its underside before soldering it in. This will hold it securely when you remove or replace the batteries. IC2 must be directly soldered to the printed circuit board. Do not use an IC socket as the switching current through L1 is quite high and the voltage drop through the socket contacts will prevent IC2 from working correctly at low battery voltages. On the other hand, you should use a socket for IC1 so that you can remove it for reprogramming. The PIC16LF88 (IC1) must be programmed with the file GPS Clock (0420309A).hex which will be available from the SILICON CHIP website. The GPS module comes with a connector cable with identical connectors at each end. We only need one, so cut the cable in the centre. This will give you two separate cables, each with a connector. On one of these cables you should bare the cut ends and solder them to the PC board, ready for the GPS module. The other cable can be used if you need to unplug the GPS module from the board and test with your computer (see box: Experimenting With The GPS Module). Solder in the 3-pin header for LK1. Then install the jumper to select 3V for the GPS module. This must be done before the board is powered up. GPS Clock firmware 1.1 1 = Set timezone (hrs) 2 = Set daylight saving off (now +10.0) (now on) 3 4 5 6 (now (now (now (now = = = = Set Set Set Set start daylight saving month start daylight saving Sunday end daylight saving month end daylight saving Sunday 7 = Set clock pulse (msec) 8 = Set GPS update (hrs) 10) 1) 4) 1) (now 40) (now 44) Q = Quit Command: The setup menu is self-explanatory and provides prompts to help you. With it, you can set the clock to operate anywhere in the world. siliconchip.com.au 1 PC board code 04203091, 140mm x 57mm 1 GlobalSat Technology EM-408 GPS module * 1 32.768kHz crystal (X1) 1 47μH high saturation inductor (Jaycar LF1274 or Altronics L6517) 1 3.5mm stereo phono socket (Altronics P0096 or equivalent) 1 momentary pushbutton switch (Altronics SP0601 or equivalent) 1 dual AA battery holder (Altronics S5027 or equivalent) 1 18-pin IC socket 1 2-way header plug, 2.54mm pitch 1 2-way header socket, 2.54mm pitch, PC-mount, 90° Pins 2 AA alkaline cells Semiconductors 1 PIC16LF88-I/P microcontroller programmed with GPS Clock (0420309A).hex (IC1) 1 MAX756CPA DC-DC Converter (IC2). Available from www. futurlec.com 1 BC557 PNP transistor (Q1) 1 BC327 PNP transistor (Q2) 1 1N4148 diode (D1) 1 1N5819 Schottky diode (D2) 1 3mm red LED (LED1) Capacitors 2 220μF 25V low ESR electrolytic (Jaycar RE6324 or Altronics R6144) 1 10μF 16V electrolytic 3 100nF monolithic 2 22pF ceramic Resistors (0.25W 5%) 1 100kΩ 1 22kΩ 2 10kΩ 2 4.7kΩ 1 1kΩ 1 270Ω 1 220Ω 1 47Ω * The EM-408 GPS module specified suits the PC board pattern and also has an integral antenna. It is available from www.sparkfun.com part number GPS-08234, or www. starlite-intl.com or www.coolcomponents.co.uk and other suppliers). Other modules may have different spacing and require an external antenna. March 2009  27 If you don’t do this, pin 2 of IC2 will float and might cause the IC to deliver a lethal voltage to your GPS module. first time but if it does not, you can use the Startup LED to help isolate the problem. This LED will flash during normal initialisation (when the set-up button Powering up is not pressed) to indicate that Before you plug in the GPS each step of the initialisation module, you need to make some has been completed. The point tests. With IC1 plugged into its at where it does not flash will socket, insert two fresh batterindicate where you should start ies in the battery holder. After a hunting. When you insert the second you should see one flash batteries you should see the from the Startup LED, followed following signals in sequence: by a further two flashes another One Flash: the microcontroller second or so later. These indicate has started up. If you do not that the microcontroller and the get this then something is DC-DC converter, respectively, The insides of a typical quartz clock mechanism fundamentally wrong with the showing the modifications we made to terminate are working. If you do not get microcontroller or the batteries. the connecting leads to the stepper motor coil. these indications you should Two Flashes: the MAX756 DCrefer to the section on troubleDC converter has started up by using a 1.5V battery. Just connect (determined by measuring a voltage shooting. the battery to the wires leading to the on pin 3 of IC2). If you fail to get this After the double flash, the microstepper motor coil, then reverse the signal you should check IC2 and its controller will wait for two minutes, battery and repeat. On each connection, associated components. Check for expecting some data from the GPS the clock’s second hand should step by approx 2.7V (with fresh batteries) module before shutting down the DCone second. on the collector of Q2 and between DC converter. In this time, you need The method of attaching the PC board 1.23V and 1.27V on pin 3 of IC2. to measure the voltage at the connecto your clock will also vary but in the Three Flashes: the GPS module is tor to the GPS module. It should be simplest case, you can use double-sided working and has transmitted its between 3.2V and 3.5V, which is the adhesive tape to hold it onto the back of startup message. If you do not get safe range for the module. To reliably the clock. The board has been designed this then check the wiring to the measure the voltage you need a load so that you can cut off the area holding module. The GPS module is very for the DC-DC converter, so connect the batteries or the area holding the GPS sensitive to its power supply. Check a resistor of about 330Ω across your module, or both. This might come in that this is between 3.2V and 3.5V. multimeter leads. useful if you need to squeeze it into a If you have an oscilloscope, check Now that you have confirmed that small space. that there is less than 150mV peakyou will not blow up your GPS modNote that this design will only work to-peak noise superimposed on the ule you can remove the batteries and with the standard type of quartz clock supply rail to the GPS module. plug in the GPS module. The module that “ticks” every second. Some modFour Flashes: the GPS module has should be attached to the PC board ern clocks with a sweep second hand locked on to sufficient satellites using double-sided adhesive tape. employ a different drive mechanism and has responded with an accurate Finally, replace the batteries and and will not work with this controller. time signal. This can take up to the controller should go through the 90 seconds or more, so be patient. whole startup sequence as described Troubleshooting Immediately following the GPS lock in the section on troubleshooting. Hopefully your clock will work Modifying the clock mechanism Jim Rowe’s article in the March 2008 issue of SILICON CHIP provided a good description of the modifications required to access a clock’s stepper motor. You will have to remove the cover from the clock mechanism, identify the leads to the stepper motor coil, cut and terminate these somewhere, and finally connect them to a lead terminated with a 2-way header plug. The stepper motor coil should be easily identified, as it will be a large coil of enamelled copper wire. Every clock is different so you will be on a journey of discovery here. You can check your modification 28  Silicon Chip You will need a PC terminal emulation program to change the clock controller’s settings. Many free programs are available for download on the Internet. siliconchip.com.au (four flashes) the clock should double step around the dial to reach the correct time. If this does not happen, it means that the crystal oscillator (X1) is not working or the clock’s stepper motor is not correctly wired to the controller. In particular, check that you have isolated the clock’s electronic module and soldered your wires properly to the stepper motor coil. Incidentally, to save the clock from having to double-step for hours to reach the correct time, it makes sense to power up the clock shortly after 12 o’clock (ie, your local time). In that way, it will only take about ten minutes or so for the clock to finish double stepping and revert to normal accurate time keeping. Set-up By default, the controller is configured for the NSW, Victorian and Tasmanian time zone and daylight saving rules. If you live in these states and the government has not changed the daylight saving rules (unlikely), then you do not need to do anything. If you live in another state, you will need to change the settings by connecting the GPS Clock to a serial RS232 port on a personal computer. If your computer does not have a “legacy” serial port then a USB to RS232 converter cable will do fine. The cable from the clock controller to the PC is the same as the serial download cable used by Revolution Education Ltd for their PICAXE experimenter board, so if your have been programming PICAXEs, you can get double use from it! It is terminated at one end with a stereo phono connector and a 9-pin D connector at the other Experimenting With The GPS Module If you would like to experiment with the GPS module, you can connect it directly to your personal computer using the circuit below. If you do change the settings of the module, remember to reset it to the manufacturer’s default configuration before using it in the clock controller. Descriptions of the commands accepted by the EM-408 are available on the internet. Search for “EM408 User Guide” and “SiRF NMEA Reference Manual”. +5.0V 1 F 16V DB9F SOCKET 5 4 3 2 1 1 F 16V 16 +3.3V 2 6 1 4 3 MAX232 5 1 F 16V 8 7 13 12 14 1 4.7k 3 4 11 6 15 1k 5 9 10k 2 Vcc En Rx Tx EM-408 GPS MODULE Gnd Fig.4: GPS Module to PC test interface. This can be constructed on a small piece of perforated board and it may be useful if you need to diagnose a fault or reset the module if it becomes stuck in a strange mode. end – see Fig.3 for details. These cables are available from Microzed (www. microzed.com). You will also need a serial terminal emulation program running on your computer configured for 4800 baud, 8 data bits, no parity and one stop bit. Many free programs are available on the Internet including PuTTY, RealTerm or Hercules Terminal Emulator. Use Google to search for one or more of these names. To enter set-up mode, hold down the Set-up button while you install fresh batteries and continue to hold it down until you see the menu. The It is easy to reconfigure the clock for different time zones and clock mechanisms. When you change a setting you are prompted to enter the correct data. siliconchip.com.au 1 F 16V Startup LED will also flash when the microcontroller transmits a character to your computer, and this may help in diagnosing communication problems. If you are observing daylight saving you can select any month for the end or start. You can also set the day for the event (1st, 2nd, 3rd or last Sunday in the month). The time of the day that daylight saving starts (2AM) is fixed in the program, as is the end time (3AM). The clock pulse width can be changed in steps of 8ms and this setting might need to be adjusted to suit your clock. Most clocks work with the default 40ms but some may need 48ms or even 56ms to reliably step with a low battery voltage. Finally, to gain a little extra accuracy or improve battery life you can change the interval between GPS synchronisations. All changes are saved in nonvolatile memory and therefore will be retained, even when you remove the battery. Well, that’s it. With your clock properly set up you can hang it on the wall and be assured that at least one clock in the house is accurate. Incidentally, you can also check the clock’s accuracy at any time if you have internet time enabled on your SC desktop computer. March 2009  29