Silicon Chip6-Digit Retro Nixie Clock Mk.2, Pt.1 - February 2015 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Electronics affects every area of society - why not debate it?
  4. Feature: Look Mum, No Hands: It’s The AirWheel by Ross Tester
  5. Feature: Reach For The Sky . . . And Way, Way Beyond, Pt.1 by Dr David Maddison
  6. Project: 6-Digit Retro Nixie Clock Mk.2, Pt.1 by Nicholas Vinen
  7. Feature: What’s In A Spark? – Measuring The Energy by Dr Hugo Holden
  8. Project: Spark Energy Meter For Ignition Checks, Pt.1 by Dr Hugo Holden
  9. PartShop
  10. Review: 3-Way USB Scope Shoot-out by Jim Rowe
  11. Project: CGA-To-VGA Video Converter by Ewan Wordsworth
  12. Subscriptions
  13. Vintage Radio: The Philco T7 transistor portable radio by Ian Batty
  14. Market Centre
  15. Advertising Index
  16. Outer Back Cover

This is only a preview of the February 2015 issue of Silicon Chip.

You can view 36 of the 104 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:
  • Reach For The Sky . . . And Way, Way Beyond, Pt.1 (February 2015)
  • Reach For The Sky . . . And Way, Way Beyond, Pt.1 (February 2015)
  • Reach For The Sky... And Way, Way Beyond, Pt.2 (March 2015)
  • Reach For The Sky... And Way, Way Beyond, Pt.2 (March 2015)
Items relevant to "6-Digit Retro Nixie Clock Mk.2, Pt.1":
  • Nixie Clock Mk2 PCBs [19102151/2] (AUD $20.00)
  • PIC32MX170F256B-I/SP programmed for the Nixie Clock Mk2 [1910215G.HEX] (Programmed Microcontroller, AUD $15.00)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • Firmware (HEX) file and C source code for the Nixie Clock Mk2 [1910215G.HEX] (Software, Free)
Articles in this series:
  • 6-Digit Retro Nixie Clock Mk.2, Pt.1 (February 2015)
  • 6-Digit Retro Nixie Clock Mk.2, Pt.1 (February 2015)
  • 6-Digit Retro Nixie Clock Mk.2, Pt.2 (March 2015)
  • 6-Digit Retro Nixie Clock Mk.2, Pt.2 (March 2015)
Items relevant to "What’s In A Spark? – Measuring The Energy":
  • Spark Energy Meter PCBs [05101151/2] (AUD $20.00)
  • Spark Energy Meter calibrator PCB [05101153] (AUD $5.00)
  • Spark Energy Meter PCB patterns (PDF download) [05101151/2] (Free)
  • Spark Energy Meter panel artwork (PDF download) (Free)
Articles in this series:
  • What’s In A Spark? – Measuring The Energy (February 2015)
  • Spark Energy Meter For Ignition Checks, Pt.1 (February 2015)
  • What’s In A Spark? – Measuring The Energy (February 2015)
  • Spark Energy Meter For Ignition Checks, Pt.1 (February 2015)
  • Spark Energy Meter For Ignition Checks, Pt.2 (March 2015)
  • Spark Energy Meter For Ignition Checks, Pt.2 (March 2015)
Items relevant to "Spark Energy Meter For Ignition Checks, Pt.1":
  • Spark Energy Meter PCBs [05101151/2] (AUD $20.00)
  • Spark Energy Meter calibrator PCB [05101153] (AUD $5.00)
  • Spark Energy Meter PCB patterns (PDF download) [05101151/2] (Free)
  • Spark Energy Meter panel artwork (PDF download) (Free)
Articles in this series:
  • What’s In A Spark? – Measuring The Energy (February 2015)
  • Spark Energy Meter For Ignition Checks, Pt.1 (February 2015)
  • What’s In A Spark? – Measuring The Energy (February 2015)
  • Spark Energy Meter For Ignition Checks, Pt.1 (February 2015)
  • Spark Energy Meter For Ignition Checks, Pt.2 (March 2015)
  • Spark Energy Meter For Ignition Checks, Pt.2 (March 2015)

Purchase a printed copy of this issue for $10.00.

6-Digit Retro Nixie Clock Mk. . . . now with optional GPS time Revel in the retro glow of this cool Nixie Clock. But while it looks like something out of the 1960s, this is a modern design utilising a 32-bit microprocessor and (optionally) a GPS receiver module to always give you accurate time and date, automatically determined by your location. We’ve also added a date display function, a 7-day alarm and other new features. Pt.1: By Nicholas Vinen 26  Silicon Chip siliconchip.com.au Features & Specifications • • • • 6-digit Nixie clock with date display and 7-day alarm and snooze functions. • • Time zone override for other locations or in case daylight saving rules change. • • • • • • • Auto-dimming of Nixie tubes and blue LEDs. Blue LEDs to provide effect lighting; can be switched on or off. Locked to GPS time to within a fraction of a second (if GPS module is fitted). Automatically determines time zone and daylight saving zone within Australia, New Zealand, UK, USA, Canada & Western Europe. Without GPS, timekeeping crystal can be trimmed to keep accurate time within less than one second per month. Proximity sensor for easy date display. Keeps time for several hours during mains power failure. Easy to set time and date via two button interface. 12/24 hour time and leading-zero blanking options. All through-hole components to simplify construction. Complete kit available, including clear acrylic case. This photo doesn’t do the clock justice. The glowing colours from the Nixie displays and the blue LEDs are actually quite a lot brighter and more dynamic than this photograph shows. .2 W E HAD SO many people at the 2014 Electronex show ask us about the Nixie Clock that we had on display that we decided it was time for a new and improved version. The original project was presented in the July and August 2007 issues of SILICON CHIP and hundreds of kits have since been sold. This new design has the same retro look but with new features. Essentially, a Nixie tube is a neonfilled tube with 10 differently-shaped cathodes. A high voltage is applied siliconchip.com.au between the anode and one of the cathodes, causing the gas around that cathode to become excited and glow. Nixies were used heavily before vacuum fluorescent displays, LCDs and LED 7-segment displays replaced them. The biggest drawback of Nixie tubes, apart from the high voltage required to drive them (150V+), is their complex construction and thus cost. This type of Nixie tube is no longer manufactured and what stock is left will only get more expensive over time so if you want to build one of these clocks, now is the time! So what will it do, besides display the current time (hours, minutes and seconds) on the six Nixie tubes which protrude from the top of the clear acrylic case? Well, it also keeps track of the date and will display it if you wave your hand in front of the unit. It also has a 7-day alarm with a piezo buzzer and options for 12/24-hour time display and leading zero blanking. In addition, it can be GPS-locked so that you never have to set or adjust it. It even automatically adjusts for daylight saving time. As with the original Nixie Clock, the blue LEDs under the Nixie tubes can be switched on and off to add extra visual appeal. So basically this new Nixie Clock is just like the old one, only better! Circuit description Fig.1 shows the control portion of the circuit, which is built onto the lower PCB. The Nixie tubes and LEDs are on the upper PCB and this part of the circuit is shown in Fig.2. PIC micro At the heart the control circuit of Fig.1 is microcontroller IC1, a PIC32MX170F256B. This is a 32-bit, 40MHz chip with 64KB RAM and 256KB flash memory in a 28-pin DIP package. Such is the march of progress that this powerful microcontroller costs less than an 8-bit chip (with just a measly few kilobytes of flash and RAM) did just a few years ago. This large amount of flash memory allows us to do some fancy things regarding time zones, which we’ll get to later. For now, let’s just look at how it keeps time, drives the Nixie tubes and communicates with the GPS module, if it’s fitted. IC1 runs from a 3.3V supply and has a 32.768kHz watch crystal connected between pins 11 & 12 (SOSCI/ SOSCO) with 22pF load capacitors on each pin. An internal low-power amplifier drives this crystal to form the “secondary oscillator” and this is connected internally to a Real Time Clock and Calendar module (RTCC), which keeps time even when the micro is in sleep mode. An internal clock trim register adds or subtracts a configurable number of pulses every 10 seconds to allow for inaccuracies in the crystal frequency to be adjusted out. Nixie segments There are a total of 46 Nixie segments that we need to drive for the time or date display. For ND2, ND4 & ND6 (Fig.2) we drive all 10, as these are the units digits for hours, minutes and seconds. When displaying the date, these are used instead to show the day, month and year respectively. For ND3 and ND5, the 10s digits for minutes and seconds (or month and year when displaying date), we only drive segments 0-5. Similarly, with ND1, we only drive segments 0-2 for the hours (time display) 10s digit or 0-3 for the day (date display) 10s digit. 44 of the 46 Nixie segment connections are made via CON4/CON10 which are rows of pads along the front edge of the two PCBs that are connected via 27kΩ resistors soldered between the boards. The other two connections are made using wires connected to PCB pins CON5 & CON6. February 2015  27 CON4 44 43 42 41 40 39 38 37 35 36 33 34 32 31 29 30 28 27 25 26 23 24 ZD1 13V A K + +12V – PB1 BUZZER +3.3V 7 6 5 4 3 2 1 15 100nF 16 Vcc Q7 MMC 10 MR Q4 IC2 74HC595 Q3 Q7S Q2 SHCP Q1 STCP GND 8 5 4 CON5 9 3 11 2 12 1 13 OE Q0 6 TO '3' OF ND1 (UPPER BOARD) Q6 Q5 7 14 DinS C Q51 E 15 27k Q7 100nF 16 Vcc MMC MR 10 Q5 Q3 Q7S Q2 SHCP Q1 STCP OE Q0 B GND 8 DinS 6 TO '2' OF ND1 (UPPER BOARD) Q6 IC3 Q4 74HC595 7 5 4 CON6 9 3 11 2 12 1 13 14 C Q52 15 27k Q7 MMC MR 10 Q6 Q5 IC4 Q4 74HC595 Q3 Q7S Q2 SHCP Q1 STCP OE Q0 B E 100nF 16 Vcc DinS GND 8 9 11 12 13 14 100k +5V +12V REG4 MCP1700-3.3/TO BR1 10-12V AC/DC POWER CON1 REG2 78L05 47Ω W02 + IN 0.5W 1000 µF 25V – +5V K A IN +5V +4.3V OUT 100µF GND 100 µF 100 µF 16V 16V 16V REG3 MCP1700-3.3/TO 1F IN 5.5V SUPERCAP OUT GND 100nF A +12V C Ips 1000 µF 25V REG1 SE MC34063 VFB GND 4 SC  20 1 5 NIXIE CLOCK MK2 2 B B E E Q46 BC337 Q47 BC327 16V D1 UF4004 L1 2 2 0 µH 3 A 6 8 Vcc DRC 1 SC ~180V K D G Q48 390k IRF740 S 10 µF 250V C 5 +3.3V 100µF MMC 7 +3.3V2 GND ~ ~ OUT D2 1N400 4 CON8 HT+ (TO UPPER PCB) HT– CON9 Ct 3 820Ω 2.7 k 1nF ZD1 D1, D2 CONTROLLER BOARD CIRCUIT A K A K Fig.1: the circuit for the lower (control) board of the Nixie Clock Mk2. Microcontroller IC1 keeps time using crystal X1 and, if fitted, the GPS receiver via CON7. This micro drives the Nixie tubes via CON4 using nine of its own output pins plus 37 from serial-to-parallel latches IC2-IC6. REG1 generates the 180V HT rail for the Nixies while REG2-REG4 supply power to the micro and associated circuitry. LED1 and IRX1 are used as a proximity sensor to trigger date display. 28  Silicon Chip siliconchip.com.au (TO NIXIE TUBE CATHODE DRIVER TRANSISTORS BASES ON UPPER PCB) 22 21 20 19 17 18 16 15 (TO UPPER PCB) LEDS CON2 +12V 1 13 14 12 11 10 9 7 8 6 5 4 3 1 2 2 +3.3V 7 6 5 4 3 2 1 C Q50 BC337 15 6.8k B Q7 100nF 16 Vcc MMC MR 10 7 6 Q6 5 Q5 IC5 Q4 74HC595 4 Q3 Q7S Q2 SHCP Q1 STCP OE Q0 E DinS GND 8 9 3 11 2 12 1 13 14 C Q49 BC337 6.8k B 15 Q7 16 Vcc 100nF MMC MR 10 Q6 Q5 IC6 Q4 74HC595 Q3 Q7S Q2 SHCP Q1 STCP OE Q0 E GND 8 DinS 9 11 12 13 14 GPS PWR +3.3V2 10Ω +3.3V 100nF 10k IR DET 100k 10 λ LED1 2 K 100Ω 3 220Ω 4 MMC 13 RA3/CLKO 28 VDD AVDD AN5/RB3 RA0 /AN 0 /VREF+ AN4/RB2 RA1/AN1/VREF– PGEC1/AN3/RB1 TD0/RB9 RB0/AN2/PGED1 TCK/RB8 100 µF 16V IRX1 10k 3 47k 1 λ λ TDI/RB7 LDR1 47k PGED2/RB10 25 AN10/RB14 2 +5V 100nF MMC A LK1 IC1 PIC32MX170PIC3 2 MX170F256B PGEC2/RB11 AN12/RB12 7 6 5 18 17 16 21 22 23 (CERAMIC PATCH ANTENNA) 1 1 2 14 3 15 4 X1 32.768kHz 5 CON3 ICSP S1 S2 22pF 11 12 MCLR 10k PGEC3/RB6 AN9/RB15 AN11/RB13 CLK1/RA2 SOSCI/RB4 SOSCO/RA4 22pF AVSS 27 VSS 19 VSS 8 VCAP CON7 1 1 26 TxD 2 2 24 RxD 3 3 4 4 PGED3/RB5 9 20 10 µF 6.3V TANT. OR SMD CERAMIC 5 5 6 6 V+ RxD TxD 1PPS GPS RECEIVER MODULE GND NC GPS W04 LED1 K A IRX1 1 BC327, BC337 3 siliconchip.com.au E GND IN B 2 78L05 MC P1700 C OUT Q51, Q52: 2N6517/ MPSA44/MPSA42 GND IN G OUT C B E +~~– IRF740 D D S February 2015  29 27k 1W λ 180Ω λ 220k 1W ND2 9876543210 MINUTES x10, MONTH x10 ND3 3 987654 3210 NT1 NE-2 A K λ LED6 180Ω A LED4 27k 1W HOURS x1, DAY x1 2 9876543210 K A K Q2 B λ λ LED7 C 44 Q1 Q11 B B C E 42 Q13 41 40 Q14 B B Q3 – Q1 0 E 43 C E 39 38 37 36 35 C E 34 33 C Q12 B Q15-Q17, Q19 E 32 31 30 29 28 27 32 31 30 29 28 27 CON10 +12V CON14 C E K CON13 K CON15 A LED3 λ K ND1 1 A LED5 A LED2 27k 1W HOURS x10, DAY x10 18x 27k CON4 1 2 CON2 SC 20 1 5 44 43 42 41 40 39 38 37 36 35 34 33 CON6 CON5 NIXIE CLOCK Mk2 DISPLAY BOARD CIRCUIT Fig.2: the upper board circuit has the six Nixie tubes, 44 of the 46 driver transistors plus the neons that separate hours/ minutes/seconds and six blue LEDs to illuminate the Nixie tubes. The 27kΩ base resistors for the 44 driver transistors are strung between the two boards, ie, between CON4 and CON10 which are slotted edge connectors. Returning to Fig.1, nine of these 46 lines are driven directly from IC1’s outputs RB1-RB3 (pins 5-7) and RB7-RB12 (pins 16-18 & pins 21-23). Since we don’t have enough pins on the micro to drive all 46 segments, the other 37 are driven instead by the outputs of five 74HC595 serial-to-parallel shift registers, IC2-IC6. These ICs are controlled by the micro using outputs RA1 (serial data output, pin 3), RB14 (serial clock, pin 25), RA0 (register latch, pin 2) and RA3 (output enable, pin 10). To change which Nixie digits are lit, IC1 delivers 5 x 8 = 40 bits of data on RA1, clocked using RB14, then brings RA0 high to update the outputs of IC2-IC6 simultaneously. It then immediately updates the output stage of the other nine control lines. Each of these 46 lines drives the base of a high-voltage NPN transistor, Q1Q46, via 27kΩ current-limiting resistors. Thus, with an output high at 3.3V, the base current is (3.3V-0.6V) ÷ 27kΩ = 0.1mA. The Nixie tubes draw about 1-2mA and the transistors typically 30  Silicon Chip have an hFE of around 40, so Q1-Q46 will be driven into saturation. We’re only using 37 of the 40 total output pins for ICs2-6 to drive Nixie segments. One of the remaining outputs (pin 7 of IC6) is unused while the other two drive the piezo buzzer (for the alarm function) and the blue LEDs mounted under the Nixie tubes. Thus the LEDs are under software control and can be easily dimmed or switched off if required. Power supply The clock is powered from a 10-12V AC or DC supply, plugged into DC socket CON1. The ~180V DC used to drive the Nixie tubes is derived from this via a boost converter. Bridge rectifier BR1 rectifies the AC or if a DC supply is used, provides reverse polarity protection. The resulting DC is smoothed with a 1000µF capacitor. This then feeds REG2, a 78L05 5V regulator, via a 47Ω/100µF RC filter. The main purpose of the 47Ω resistor is to reduce the dissipation in REG2 when the filtered DC voltage is on the high side. It will dissipate up to 500mW with a 15V DC supply (eg, 12V AC rectified) and a 100mA draw on the 5V line. Under these conditions, REG2 will also dissipate 500mW, just under its 625mW maximum rating. The output of REG2 is used to power a 5V GPS module, if fitted. It also charges a 1F super capacitor via diode D2, resulting in around 4.3V. Lowdropout (LDO) regulator REG3 derives the 3.3V for IC1 from this 4.3V input. Thus, if there is a mains power failure, IC1 will continue to run off the charge in the super capacitor. By disabling all its outputs and dropping into a sleep mode, it can continue to keep time for many hours until the mains power comes back. A second identical 3.3V LDO, REG4, is used to supply power for a 3.3V GPS module (if fitted) and also powers some of the ancillary circuitry such as the infrared proximity detector. This regulator is fed directly from the 5V output of REG2 so if mains power fails, the GPS and proximity detector will power down immediately. LK1 siliconchip.com.au ~180V 26 25 24 B E E 23 22 21 C 20 19 18 16 17 15 Q 31 -Q3 3, Q35 14 ND6 9876543210 C Q28 B Q44 B Q34 C C B Q36-Q43 E E E 13 12 11 10 9 8 7 6 5 4 3 2 1 13 12 11 10 9 8 7 6 5 4 3 2 1 CON10 HT+ E Q30 B SECONDS x1, YEAR x1 6 9876543210 Q18 Q 20 – Q2 7 ND5 5 NT2 NE-2 C C SECONDS x10, YEAR x10 CON11 ND4 4 Q29 220k 1W 27k 1W HT– MINUTES x1, MONTH x1 9876543210 B 27k 1W CON12 27k 1W 25 24 23 22 21 20 19 18 17 16 15 14 CON9 CON4 26 CON8 2 6 x 27k HT– HT+ ON CONTROL BOARD LEDS Q1– Q4 4 : 2N6517/ MPSA44/MPSA42 K C B E A Suitable GPS Modules selects whether the GPS module runs from the 3.3V or 5V supply. HT supply REG1 forms the boost converter and this runs directly off the rectified and filtered supply of around 12-15V DC. The 1nF capacitor between pins 3 and 4 (CT and GND) sets its oscillation frequency to around 33kHz. When its switch output at pin 1 goes high, the gate of Mosfet Q48 is driven high via an emitter-follower buffer comprising NPN transistor Q46 and PNP transistor Q47. This buffer is required because pin 1 is an opencollector output and while it has good pull-up strength, a very low value resistor would be required to discharge the gate of Q48 quickly at switch-off. The buffer allows a higher value pulldown resistor (820Ω) to be used while keeping switching time fast. When Q48’s gate is driven high and it turns on, current flows from the ~12V DC supply, through inductor L1, through Q48 and to ground. This is effectively a short circuit across L1 siliconchip.com.au The following modules should be suitable for use in this project: GlobalSat EM-406A, Fastrax UP501 and VK16E. The Digilent PmodGPS and RF Solutions GPS-622R should also work but will not fit on the board unless mounted on top of a non-conductive spacer (which we recommend, anyway). Most other modules that will fit on the board should also be suitable but if they run off 5V, you will need to check that the serial output voltage does not exceed 3.6V. Note that a few GPS modules are available with onboard RS-232 level converters and will deliver ±12V or similar on the TxD line. These should not be used in the Nixie Clock Mk2. Note also that the GPS module isn’t normally included with the kit but will be offered as an optional extra (or you can supply your own). and causes its magnetic field to rapidly charge. Its inductance, combined IC1’s limit on the on-time, prevents this current flow from becoming excessive. When Q48 is switched off, this magnetic field causes current to continue to flow in the same direction through L1 but the only path is then from ground, through ultrafast diode D1 and into the 10µF 250V capacitor. As a result, the voltage at this end of the inductor shoots up well above the 12V input. Current flow drops off as L1’s magnetic field collapses, until Q1 switches on again and the process repeats. IC1 monitors the voltage across the 10µF capacitor using a 390kΩ/2.7kΩ resistive divider and adjusts the duty cycle with which Q48 is driven to maintain 1.25V at its feedback pin (pin 5). This regulates the voltage across the 10µF capacitor to 1.25V x (390kΩ ÷ 2.7kΩ + 1) = 182V. This then supplies the Nixie tube and neon lamp anodes. GPS interface CON7 provides the connections for February 2015  31 Parts List 1 control (lower) PCB, code 19102151/NX15L, 144 x 64mm 1 display (upper) PCB, code 19102152/NX14U, 144 x 64mm 1 9-12V 250mA AC or DC plugpack 1 PCB-mount DC socket 1 perspex case 6 1N14 Nixie tubes, 14-pin bases (ND1-ND6) 2 NE-2 neon lamps (NT1,NT2) 1 220µF 3A toroidal inductor (L1) 1 32.768kHz watch crystal, 10pF load capacitance (X1) 1 3-pin header with shorting block (LK1) 1 2-pin header, 2.54mm pitch (CON2) 1 5-pin header, 2.54mm pitch (CON3) (ICSP, optional) 4 1mm PCB pins (CON5,CON6, CON8,CON9) 1 6-pin header for GPS, 2.54mm pitch (CON7) 2 40-pin snappable machined socket strips (to make Nixie sockets) 1 mini 9-14V piezo buzzer, 7.62mm pin spacing (PB1) (Jaycar AB3459, Altronics S6105) 1 47-100kΩ LDR (LDR1) 2 PCB-mount horizontal momentary pushbuttons (S1,S2) (Altronics S1495) 1 GPS module with suitable connection cable (optional) 1 length double-sided tape (to affix GPS module) 1 plastic block, ~20 x 20 x 8mm (to affix GPS module) 1 250mm-length 1.5mm heatshrink tubing 4 25mm tapped metal spacers 4 12mm tapped male/female metal spacers 8 M3 x 8mm pan-head machine screws 12 4G x 12mm self-tapping screws (supplied with perspex case) Assorted lengths of medium-duty hook-up wire 1 black card, 24 x 12mm Semiconductors 1 PIC32MX170F256B-I/SP 32-bit microcontroller programmed with 1910215A.hex 5 74HC595 serial to parallel latch ICs (IC2-IC6) 1 infrared receiver (IRX1) 1 MC34063 switchmode regulator (REG1) 1 78L05 5V 100mA regulator (REG2) 2 MCP1700-3.3/TO 3.3V micropower low-dropout regulators (REG3,REG4) 46 2N6517, MPSA42 or MPSA44 high-voltage transistors (Q1Q44, Q51-Q52) 3 BC337 NPN transistors (Q46, Q49,Q50) 1 BC327 PNP transistor (Q47) 1 IRF740 400V 10A Mosfet (Q48) 1 13V 1W zener diode (ZD1) 1 infrared LED (LED1) 6 blue 3mm LEDs, clear lenses (LED2-LED7) 1 W02/W04 1.5A bridge rectifier (BR1) 1 UF4004 ultrafast 400V diode (D1) 1 1N4007 1A 1000V diode (D2) Capacitors 1 1F 5.5V super capacitor 1 1000µF 25V electrolytic 5 100µF 16V electrolytic 1 10-100µF 6.3V tantalum or 10µF SMD ceramic 1 10µF 250V electrolytic 8 100nF multi-layer ceramic 1 1nF MKT, ceramic or polyester 2 22pF ceramic Resistors (0.25W, 1%) 1 390kΩ 1 2.7kΩ 2 220kΩ 1W 5% 1 820Ω 2 100kΩ 1 220Ω 1 47kΩ 2 180Ω 6 27kΩ 1W 5% 1 100Ω 46 27kΩ 1 47Ω 3 10kΩ 1 10Ω 2 6.8kΩ Where To Buy A Kit The Nixie Clock Mk2 will be available exclusively as a complete kit from Gless Audio. This includes the PCBs, all components, a programmed microcontroller, Nixie tubes and the case hardware. Kits should be available late February/early March 2015. Contact Gless Audio on 0403 055 374 or email glesstron<at>msn.com 32  Silicon Chip a GPS module. There are two power supply pins – 3.3V/5V (depending on the module used) and 0V (GND). There are two serial pins, for transmit and receive, although the receive pin is not terribly important as most modules will send the required data without prompting. It’s there for completeness. Note that we’re assuming that if a 5V GPS module is used, it has a 3.3V serial interface. That is typically the case – eg, the GlobalSat EM-406A requires a 5V supply and uses a serial signalling level of around 2.85V, while the VK16E can run off either 3.3V or 5V (or anything in between) and its TxD pin will produce a maximum voltage of 3.6V. Hence, we have no over-voltage protection for IC1’s RxD input beyond the normal internal clamp diode. Refer to the panel on suitable GPS modules for more information. The remaining GPS pin is for a 1PPS (one pulse per second) signal from the GPS module to the micro. This is used so that the seconds “tick” is accurately synchronised. However, should you use a module without a 1PPS output, the clock will still be synchronised to GPS time. It’s just that it could be off by half a second or so. Most people will not care about this. Just wave for the date Because it’s inconvenient having to reach around the back of the unit to press a button when you want to see the date, we’ve fitted a simple proximity sensor. All you have to do is wave your hand in front of the unit and it will show the date for 10 seconds, then switch back to showing the time. This is implemented using an infrared LED (LED1) and infrared receiver IRX1. LED1 has a series 220Ω currentlimiting resistor and is driven directly from microcontroller output RB0 (pin 4). This is configured as a PWM output via the internal Peripheral Pin Select crossbar. Periodically, based on a timer interrupt, this PWM output is enabled and driven at 38kHz with a low duty cycle. Some of the emitted infrared light pulses reflect back to IRD1 which detects this signal and its output goes low. Depending on the proximity of objects to LED1 and IRX1, some of this light is reflected, resulting in a variable length output pulse. IC1 detects changes in the length of this pulse as indicating movement of nearby objects siliconchip.com.au The unit is built on two double-sided PCBs, with the Nixie tubes plugged into sockets on the top display board. The GPS module, microcontroller and time-keeping circuitry are on the lower control PCB. Pt.2 next month has the full constructional details. and responds by showing the date. Because there are no spare pins on IC1, the infrared receiver signal is connected to pin 25 via a 47kΩ resistor. This pin is also used to drive the SCK (serial clock) lines of serial latches IC2-IC6 however it’s only driven when there is serial data to send. The 47kΩ resistor isolates the infrared receiver output during this time. The rest of the time, IC1 can sense the output level from IRD1. Pins 2 & 3 of IC1 are similarly used for dual purposes. Both have resistive voltage dividers connected which are “overridden” when those pins are being used as outputs, to drive the latch clock lines of IC2-IC5 and the serial data lines respectively. Pin 2 is used to monitor ambient light levels using LDR1 while pin 3 is used to (indirectly) monitor the mains supply voltage. Both are “read” by IC1 using its internal analog-to-digital converter (ADC). For pin 2, as the light level drops, LDR1’s resistance increases and so the voltage at this pin approaches the positive rail. This allows the unit to adjust siliconchip.com.au the Nixie tube and LED brightness so it isn’t overpowering in a dark room. Pin 3 is connected to the filtered DC supply via an 11:1 voltage divider (ie, 100kΩ ÷ 10kΩ + 1). The voltage on this pin is periodically checked and if it drops below 0.64V, indicating less than 7V on the main filter capacitor, it is assumed that the mains power has failed (or been unplugged). In this case, IC1 turns off all its outputs and goes into sleep mode, to minimise the discharge rate of the 1F supercap. The current drain in this mode is around 40µA and the real-time clock continues to run. At this rate, the clock should be able to keep time for a week or more until power is restored. IC1 “wakes up” every few seconds and checks the voltage on this pin again. Once it rises above 0.73V, mains power has resumed and so the chip switches back to normal operation. Note that the LDR voltage is being read immediately after updating the data in latches IC2-IC5 so that, should the resulting voltage be low enough to effectively toggle the register latch inputs of these ICs, it will not change the state of the 40 output pins; they will merely re-latch the same data just sent. User interface Besides the proximity sensor, which is used to display the date and snooze the alarm, there are only two pushbuttons to control the clock, labelled S1 and S2. These are connected to pins 14 & 15 of IC1 which are set up as inputs PB5 and PB6 with internal pull-up resistors enabled. The chip’s Change Notification Interrupt feature is used to detect when a button is pressed, pulling one of these lines low. These lines are also the programming interface (PGED and PGEC) and are connected to in-circuit serial programming header CON3. However, those functions are only operational when the unit is in programming mode, initiated by pulling pin 1 (MCLR) to a high programming voltage, so they don’t interfere with button sensing. There are a large number of functions available using these two buttons, including: setting the time and date (when a GPS module is not fitted), manually setting the time zone February 2015  33 Determining Local Time Using GPS If a GPS module is fitted to this unit, once it has acquired enough satellites, it automatically broadcasts the current time and date at its serial output pin. However, this time and date are in Universal Co-ordinated Time (UTC) which is almost identical to Greenwich Mean Time (GMT). To figure out your local date and time, we need to know which time zone you are in and what your daylight saving rules are. Based on this information, we can then compute the local time. Once we know the time zone, this just involves adding the local time zone offset to the UTC time and date, then checking the local daylight savings rules and if applicable, adding the DST offset. The tricky part is figuring out the current time zone. Once it has a fix, the GPS module provides its location as a latitude, longitude and altitude. To figure out what time zone you are in from this information, we need a map which defines all time zone boundaries and rules. We initially considered using a free database called tz_world. This contains thousands of regions, defined by strings of lat/long pairs which make up their boundaries (as closed polygons) and each region is then associated with a time zone by name. Unfortunately, tz_world is many megabytes. It could be loaded onto something like a Raspberry Pi or Beaglebone Black but even then, the calculations to go through those thousands of polygons (many of which are bounded by thousands of points) would take some time, even with a fast processor. After some effort, we managed to extract enough information from this database to be useful and compress it into a much smaller size. The end result is a little under 100KB of data which contains enough information to determine whether a given lat/long is within any time zone for Australia, New Zealand, the UK, the USA, Canada or Western Europe. After extracting this information, we simplified it as much as possible without compromising the accuracy. For example, we merged the zones for New South Wales, Victoria and Tasmania since they operate under the same rules and this eliminates the need to store the detail of the NSW/Victoria border. We also removed most of the coastal detail as it really isn’t necessary. If you are using the Nixie Clock at sea, it will simply show time in the time zone for the nearest land mass. We also found that tz_world defined straight lines or nearly straight lines (eg, most of the borders between Australian states) as a number of points in the polygon when we only really need to store the two end points. Removing the unnecessary intermediate points allowed further reductions in size. (with GPS fitted), trimming the crystal frequency, setting and viewing the alarm, turning the alarm on and off and changing various options such as 12/24-hour time and leading zero blanking. To handle all these different cases, the unit detects long and short presses of the two buttons and also combination presses: both buttons pressed si- multaneously, both buttons held down or one button held down and the other pressed. These various combinations allow the user to get into the different modes necessary to access the above functions. 34  Silicon Chip Delta compression Finally, we applied a variable bit length delta compression to the data. Essentially, when a region is defined as “n” lat/long pairs, we don’t need to store each pair separately. Rather, we can store the first pair, then the two-coordinate distance vector between subsequent pairs. Because each point bounding a region is usually quite close to the last, these “delta” values tend to be much smaller than the original lat/long values. We store the values in thousandths of a degree. For example, Sydney is at 33.86°S, 151.2094°E (approximately). We store this as integers -338600,1512094 which takes approximately 48 bits of data space, ie, 6 bytes. Say that is the first point in a region and the second is 33.85°S, 151.28°E. Rather than storing this second pair and using up another 6 bytes, we can store a delta of +0.01°,-0.0706° instead. Converting this to our integral format yields values of +10,-71. We can store delta pairs of Piezo buzzer Piezo buzzer PB1 is used to sound the alarm and is driven by NPN transis- up to ±0.1° in 16 bits, so this delta takes up 1/3 the number of bytes compared to the absolute location. Similarly, deltas of up to ±0.0723° in lat/long can be stored in 24 bits (3 bytes, 1/2 the space) and up to ±1° in 32 bits (4 bytes, 2/3 the space). Very few co-ordinate pairs are further than 1° apart and on average, our scheme uses less than half the space required to just store the lat/long pairs. Decompressing the data is simple and quick; the size of the next delta is stored in the first few bits of data, with the deltas themselves following. We then read these values and simply add them to the last decoded co-ordinate to get the next one. Time zone search Once we had created the database of time zone boundaries, we needed a way to figure out if the current lat/long is within each region. That’s not as simple as you might think given the complexity of some of these shapes. We need a way to determine whether a point is within a polygon by examining the points which define its vertices. Before doing this though, we look at the lowest and highest lat/long values in the set of vertices and compare these to the current lat/long. If it’s outside that bounding box, it can’t possibly be within the time zone polygon and so we can skip that zone entirely. Assuming that our lat/long is within the bounding box, we must then do the full polygon check. First we pick a random co-ordinate (lat/long) that’s definitely outside the time zone boundary, using the bounding box as a guide. We then draw an imaginary line from our present position to that random position which we know is outside the time zone being considered. If the current lat/long is within the polygon, that imaginary line will intersect the bounding line segments an odd number of times – most likely once, but possibly three or five times say. If we are outside tor Q50 from output Q0 of serial latch IC5. This buzzer can run off 9-14V. Since it’s possible for the unfiltered DC supply to be slightly higher than this (depending on the plugpack used), 13V zener diode ZD1 is connected across the buzzer to limit the maximum voltage applied. The current through this zener is limited by the drive capabilities of siliconchip.com.au it, the imaginary line will intersect the boundary lines an even number of times – probably zero, but possibly two (if our position and the random position happen to lie on opposite sides), or maybe four or more times, depending on the complexity of the shape. So we go through each bounding line segment and test it for intersection with our imaginary line segment. This is done by computing the dot products, cross products and lengths of those vectors with reference to the signs and magnitudes of the results. This is hard to explain unless you are well-versed in vector mathematics but it’s a relatively fast method to find whether the lines intersect. For each intersection, we increment a counter. After having considered all point pairs in the time zone boundary polygon, if the counter value is odd, we must be within that time zone and we need not consider any of the others. We then look up its rules (offset, daylight savings) and apply them to the UTC time/date to get and display the local time. If we go through all the time zone regions and we’re not within any of them, the time zone offset must be entered manually via the pushbutton interface. Alternatively, should your time zone rules change, you can override this automatic detection using the same setting to prevent the clock from showing the wrong time. Nixie Tubes: How They Work Nixie tubes work on the same principle as the simple neon indicator. A neon indicator consists of a small glass tube filled with inert neon gas and containing two metal electrodes. When a sufficiently high voltage is applied between the electrodes, the gas around the negative electrode (the cathode) ionises and envelops the electrode with an orange glow. The voltage required for ionis­ation of the gas is dependent on the electrode spacing and the temperature. Typically, it is more than 80V for small neon bulbs and more than 150V for Nixie tubes. In practice, higher voltages are used, with a series resistor to limit the discharge current to a safe value. Two small neons are used in this clock design, between the hours and minutes and between the minutes and seconds tubes. A Nixie tube has a see-through metal mesh anode at the front and 10 different shaped cathodes (0-9) behind the anode, each being terminated to a different wire lead or pin on the tube. The number-shaped cathodes are not necessarily placed in direct order behind the anode but are placed to give minimum obstruction of each digit by the ones in front of it. The anode is connected to +HT via a current-limiting resistor and the particular cathode is pulled down to 0V when it is to be lit. By the way, “HT” is old-timer talk for “high tension” or high voltage. New old stock Nixie tubes are no longer man­ ufactured. Instead, they are now available as “new old” stock, originally made in either the USA or the former USSR. The ones used in the Nixie Clock described in this article were made by RCA (USA) in February 1954 – ie, over 60 years ago. The Nixie Clock is built into a clear acrylic case. Pt.2 next month has the full constructional details. siliconchip.com.au February 2015  35 How Quickly Will You Get A GPS Fix? When a GPS module is powered up for the first time, it starts searching for satellite signals. Normally, there are somewhere between about 10 and 14 GPS satellites overhead at any one time however if parts of the sky are occluded (eg, by a roof), then the receiver may not be able to pick up all the signals. In addition to “finding” the satellites, the receiver module has to gather the “ephemeral” data which is slowly broadcast by those satellites. This will normally take at least half an hour. This data changes slowly, so if the receiver has a recent copy of the data, it won’t need as long to get enough data to begin operation. With a “hot start”, it can be up and running in seconds. If, however, it has never been powered up before or if it has lost power for long enough for its RAM back-up battery/capacitor (if fitted) to discharge, it can take quite some time to get a fix. How long depends on how clear a “view of the sky” the receiver has. In an indoors location, some receivers will never get a fix unless they already have a relatively up-to-date version of the ephemera stored in RAM. In other words, you might find that the module will not get a fix until it has been taken outdoors for a few minutes (powered up, obviously) and then brought back inside. It may then be able to maintain a good fix with the weak signal available at that location. Sometimes, putting the module next to a window for a little while will do the trick. This is why many GPS modules have an onboard RAM back-up battery, so they can keep track of time and ephemeral data while powered down. Some do not have this feature though – presumably, the assumption is that they are part of a battery-powered instrument and so are never without a power source. You don’t need to use a GPS module with an on-board battery in the Nixie clock. Most modules which don’t have a battery will have a power pin which can be connected to a back-up power source. This may be labelled VDD_B or similar (check the data sheet). On the UP501, this is pin 5. (The UP501B has an onboard battery and pin 5 should be left unconnected). Assuming that a 3.3V supply is suitable (which is true for the UP501 and probably most other modules), you can simply wire this up to pin 2 of CON3, the ICSP header. VDD_B will then be powered from the onboard 1F supercap and so the ephemera will be preserved for many hours (probably days or weeks) without mains power. The GPS module will then be able to get a fix relatively quickly when the power comes back on. Note that one reason that the ephemera is required is that GPS time differs slightly from UTC. At the time of writing, the difference is about 12 seconds and this is due to leap seconds having been used since the GPS system was set up. So the receiver needs this data not only to get a position fix but also to report accurate time. Note also that in some buildings, you may need to keep the Nixie Clock near a window in order for it to get a good fix at all. Q50. Its base current is around 0.4mA and with a typical hFE of 150 it will therefore sink about 60mA if ZD1 conducts, about 30mA through PB1 and 30mA through ZD1. The blue LEDs on the upper board are powered via NPN transistor Q49 which is driven from the Q0 output of serial latch IC6. Software The software for this unit, while fairly complex (to handle all the various modes), is straightforward. Its main job is to set up the real-time clock, wait for a second to pass, then drive the appropriate Nixie segments to display the correct time. Simultane36  Silicon Chip ously, it monitors the GPS serial and 1PPS signals for time/date updates and also monitors the pushbuttons, LDR, infrared receiver and supply voltage. The most complex part of the software involves handling time zones correctly. Simply getting the time from a GPS receiver is quite straightforward. It’s just a matter of parsing the text messages which are sent several times per second and extracting the time field. However, this gives Universal Coordinated Time, which is akin to Greenwich Mean Time. And we want the clock to display local time, which is only the same as GMT in the UK when daylight saving is not in effect. These days we tend to expect clocks to take care of things like daylight saving time. After all, modern computers and phones always show the correct local time, if set up correctly. We can do the same thing using a GPS module since we can figure out the time zone and daylight savings rules based on the present location. But this is a difficult problem because there are so many different rules and the various boundaries where they change are not always straight lines! For example, consider people who live in or near Coolangatta, on the zig-zagging New South Wales/ Queensland border. While NSW and Queensland are in the same time zone, NSW observes daylight saving while Queensland does not. Depending on which street a house is on in Coolangatta, the (official) local time could vary by an hour. So we need to figure out which side of the border the unit is on to display the correct time year-round. Basically, if you are using a GPS module for time, this is all handled automatically. The calculations are accurate to within a few tens of metres so unless you live right next to the border and are very unlucky, the time shown should be correct. If you’re interested in the details of how the software does these calculations, refer to the “Determining Local Time Using GPS” panel. Physical layout As mentioned earlier, the Nixie Clock is built on two PCBs, with a few wires and 44 resistors connecting them together. The lower PCB has the power supply and all the control circuitry (including the GPS receiver, if fitted), while the upper PCB has the Nixie tube sockets, neon indicators, blue LEDs and most of the high-voltage transistors. In fact, the upper PCB is almost identical to that used in the original 2007 design. It’s the control circuitry on the lower board which has been completely revamped. Both boards are mounted on spacers within a clear acrylic (Perspex) case to provide insulation so that you can’t get a shock from the 180V Nixie anode supply. The Nixie tubes protrude through holes on the top, while the power connector and pushbuttons are accessible through holes at the rear. We’ll get to the construction of the two PCBs and the final assembly into SC the case in Pt.2 next month. siliconchip.com.au