3

(coco) #1

How I Made: Time-to-go-clock


FEATURE



  • Red Turns off red LEDs

  • Green Turns off green LEDs

  • Blue Turns off blue LEDs

  • Edit Mode Puts clock in edit mode
    (effectively, this changes the operation
    of the rotary encoder so it can be
    used to change the future event
    being monitored)


Frankly, if there were
fewer cut-outs, I could
have dispensed with
some of these or assigned
them to the encoder. But
their convenience means
they do get used more,
especially changing the
LED backlight colours.
Finally, I installed the rotary encoder,
LCD dimming potentiometer, and motion
detector in various other existing or newly
created holes.


STAYING INFORMED
You can see the code at hsmag.cc/nSTnRR.
A not inconsiderable advantage of buying
the GRA and AFCH driver board is that


they offer some sample code to run a clock
using the board. That said, since I needed to
make some fairly significant modifications to
this code, it was important to start with an
understanding of how their code works.
First, some basics. Nixie tubes work in a
similar way to an array of ten LEDs with a
common anode (at least, for a tube that can
display the digits 0–9). Each LED represents
one digit, so you can light any LED/digit by

applying the requisite voltage to the anode,
then grounding the cathode of the LED you
want to display. In this arrangement, you can
just connect each LED cathode to an Arduino
pin (through a resistor, of course) and drive
the appropriate pin low to turn on that LED.
Since the Arduino keeps pretty good track
of elapsed time, switching on each LED
sequentially in one-second intervals is not
much more complicated. Already we are well

on the way to making a clock! To make a
working Nixie-based clock, however, we still
need to overcome three obstacles:


  • Nixie tubes require around 180 V DC to
    light up; an Arduino cannot source or
    switch anything like that.

  • A clock displaying hours, minutes, and
    seconds requires control of six tubes. If
    we persist with the approach
    above, we’ll need 60 pins just
    for switching the Nixies; even
    an Arduino Mega has only 54
    I/O pins.

    • While the Arduino keeps
      pretty good track of elapsed
      time, it doesn’t actually know
      what time it is.




Since we’ve already moved on to
discussing the code, let’s just note that the
driver board solves obstacle one by stepping
up the 12 V from the Arduino’s Vin pin to the
required voltage.
The second obstacle is overcome by a
mixture of hardware and software. On the
hardware side, the driver board has three
shift registers, each with 20 high-voltage
outputs. Connected in series, these registers
can therefore do the necessary switching of
all six tubes without multiplexing.
On the software side, we need to tell the
registers which of their pins to switch. This
is done by converting the digits to display
on the clock (held in the stringToDisplay
variable) to a 64-bit variable, then sending
that data via SPI in eight byte-sized chunks to
the registers. This is handled by some clever
bit manipulation in the doIndication function
(courtesy of GRA and AFCH).
Last, we can crack the third problem
by using a library of time-related functions
(TimeLib) and getting the current time from an
internet time server.
Computers, microcontrollers, and the like
establish what time it is by counting the
number of seconds from a reference point, for
example 1 January 1970. The TimeLib library
helps deal with the tedious mental arithmetic
needed to figure out what the time and date
is if, for example, it is 1 516 365 708 seconds

The clock’s defining feature, broadly hinted at


in the name, is that it can display the time to


any future event


Above
The LCD screen
can display any
messages you want
Free download pdf