This winter I had my first Hack Days at FreeAgent. During the Hack Days everybody at FreeAgent teams up for a couple of days and builds something fun and (preferably) useful. That’s when “Machine that goes ‘Ping!’” was born.
With an Arduino Uno board, some Sugru, bicycle bell, a few LEDs, servo motor and a RabbitMQ subscription to production logs it was able to ring a bell and flash some ligths every time FreeAgent got a new subscriber. The machine was a grand success.
This little project inspired me to do something more challenging. I wanted to further develop the idea of the subsribers counter and I knew that the new version of the machine should not only make a sound when a user subsribes or unsibscribes but also display the total number of subscribers. As an inspiration I used this Geiger counter project I found a while ago. I hadn’t completely figured out the design yet, but decided to use Nixie tubes anyway.
Here’s the impression of what the finished product might look like produced with my rudimentary drawing skills:
On the inside the architecture is pretty simple: Raspberry Pi gets the total number of subscribers and an event of subscription somewhere online. It sends the number to the Nixie tubes for display and a signal to the speaker on a subscription event.
The first part of this scheme I’m going to dive into is the Nixie tubes part.
A Nixie tube is a vacuum tube with a bunch of electrodes inside. When current goes through the tube electrodes glow due to the effect called glow discharge.
If you put two electrodes - cathode (-) and anode (+) - in a tube filled with gas, and apply enough voltage, electrons start to “break” from cathode and fly to anode ionizing gas inside the tube and causing a glow.
Nixie tubes have multiple cathodes, shaped like digits from 0 to 9, and one anode. If you connect this common anode to a high-voltage power source and connect one of the digit cathodes to the ground you’ll see the digit glowing with bright light.
Nixie tubes come in different varieties. I’ve got the model IN-4
.
IN-4
tubes have 14 pins: 10 digits-cathodes, an anode (pin 4) and 3 more pins the meaning of which is unknown to me.
Because Nixie tubes operate at such high voltage (180V) and because it’s not very handy to look up a pin number you have to “activate” every time you want to display a digit a driver should be placed between a controlling device and a tube.
In this project I used K155ID
chip - a high-voltage BCD-to-decimal decoder. More on this in the next post. For now let’s just assume that for each tube we have 4 input pins instead of 10 and if we send a binary coded number from 0 to 9 to these pins the number would show up on a Nixie tube attached to the driver.
To show a 6 digit number, we have to send signals to 6 * 4 = 24 input pins. That’s way too many inputs for a simple device, let’s try to reduce the number.
One way to do this is to align all 24 pins, connect them to a single wire and connect that wire to a Raspberry Pi. Then we can send one signal at a time for each pin on this wire, i.e. form a succession of “messages” like “1 to pin #23”, “0 to pin #22” etc. This process is called multiplexing.
Of course we will need a device that will decide which pin is to receive what signal. For that we can use shift registers.
Serial-in, parallel-out shift register is an electronic device that receives a serial input (a sequence of “1” and “0” send one after another), stores it and transforms it to the parallel output.
Shift registers have two clock inputs: SHCP
or SCK
(Shift Register Clock) and STCP
or RCK
(Storage Register Clock). Every time signal changes from 0 to 1 on SHCP
input all data stored in shift register “shifted” one bit to the right. When STCP
input is triggered, the data stored in shift the register gets sent to the outputs.
Shift registers can be stacked together, each later one using serial output of the previous one as a serial input. This way the array of shift registers can be used as one big register, allowing to store and convert larger numbers.
As 74HC595
shift registers have 8 outputs we can connect two Nixie tube drivers to each of them.
Three boards like this connected one to another can drive 6 Nixie tubes. Elements JP2
and JP3
are sockets containing five wires common to all boards: power (VCC
), ground (GND
), SHCP
(CLK
), STCP
(LATCH
) and RESET
(an input signal used to clear a shift register) and serial input and output.
Serial output of the first shift register (QH*
) becomes a serial input of the second one while the serial input of the first register (SER
) is connected to a Raspberry Pi.
To test a shift register on a series of simple inputs we can use an Arduino Uno. We need to plug three inputs of the shift register to Arduino: SHCP
and STCP
clocks and serial input DS
. To monitor the state, we connect 8 LEDs to the outputs.
The first test is to send a single 1
to the DS
input and “shift” it from the first output pin to the last, blinking the LEDs as the number shifts.
After uploading this program to the Arduino board you should see 8 LEDs flashing one after another, then the whole sequence repeating.
The second sketch features how to write a two-digit Binary Coded Decimal (BCD) to the 8 output pins. The first digit to the first 4 pins and last digit to the last 4 pins. The number in this example is 99. Which is admittedly not a very good example as the number is a palindrome in both decimal and binary bases.
Here’s the picture where active LEDs form the binary number 10011001
- 99
in BCD form.
Arduino website has a great tutorial on using a shift register with Arduino.
That’s it to the shift register! Another chip I used in the project is K155ID1
Nixie tubes driver. In the next post we’ll try to use it to transform an input BCD number to a corresponding pin number on a Nixie tube.