A few weeks ago, I was looking to hook my turntable up to a new receiver. Previously, it had been hooked up to a 70’s classic, the Kenwood KR-2090. As much as the linked review rags on it, this receiver has served me really well, and it’s built in phono preamp sounded really nice to my ear.
My new receiver is a 90’s era, low end Sony unit. Being from the 90’s, it lacks any phono preamp. As such, I needed to get a discrete unit. I don’t consider myself an audiophile, so after reading the customer reviews, I decided to go with a cheapo model, the Pyle PP444 (don’t worry, I stripped the affiliate links, so I don’t get a commission or anything). At first listen, I was happy that it ‘worked’ — the gain was about right and it sounded vaguely OK. The more I listened to records, the more it sounded ‘off’ to me, however. I’m not an audiophile, however, and I can’t claim to have a golden ear (I have a tin one, really).
Anyway, this was an excuse to see if I was right, and better yet, an excuse to use my SR780.
I decided to do a comparison. Using a 10mV input signal and a 20Hz to 20kHz log-spaced sweep, I generated the responses for both the Kenwood and the Pyle PP444 (seen below, compared to the reference RIAA equalization curve). I’ve normalized all three responses to 0dB at 20Hz to simplify comparison.
Sure enough, the Kenwood (blue line) perfectly follows the official RIAA curve (yellow line), while the Pyle (orange line) rolls off way more slowly. Even at 1kHz, the Pyle is about 12dB louder relative to 20Hz deep bass than it should be. No wonder things sound tinny!
I guess the summary is that I shouldn’t have expected much from a $13.20 (at press time) preamp, but nonetheless, I feel like I don’t have a good way to be sure if I’m getting one that actually delivers the response I want at any pricepoint.
I guess the summary is, if you care about sound quality, avoid the PP444. If you just want something that will ‘work’, I guess it’s fine.
Years and years ago, I heard about the AtariVideoMusic. A short lived music visualization device created by Atari in the late 70’s. It would hook up to your home hi-fi and living room TV and show off the music. Techmoan did a good introduction to it here, but imagine a very primitive version of MilkDrop.
Anyway, since before the time Techmoan did his review, I have been thinking about creating my own, modern-retro take on the idea. Music visualizers seem to have dropped off the face of the earth in the last few years, but I’ve always loved them.
Anyway, long story short, a couple of years ago I started making my own. I realized that the Raspberry Pi was the perfect tool for the job. It could easily do all the music visualization I wanted it to, and be built into the stereo component style box with an integrated, tiny, CRT that I envisioned at the time. Fate would have it that my old academic advisor had a tiny portable color television that he gave to me, gratis, and in the course of developing the code, I decided that the TV itself was perfect, so I just put the Raspberry Pi out of sight behind the TV and called it a day.
Video Tour
Software
The software is all written in python, and can be found here.
There are two files, RaspberryVideoMusicSupervisor.py and RaspberryVideoMusic.py. The former simply makes sure the latter is running as a process. It allows me to automatically recover from the occasional crash and I have set up my Pi to simply launch that script on boot.
RaspberryVideoMusic.py is the main script. It relies on Pygame and Pyaudio. The basic loop is simple. Pyaudio captures audio frames and raises a flag when there’s new data.
There are some basic data ‘services’ available at all times, updated when new data is available. These include things like the audio frame, an FFT of the audio, and a detected signal envelope.
The main loop updates the Pygame display when new data is available. Every few seconds it randomly selects a different foreground and background visualization as well as randomly selected color schemes for each.
Hardware
The hardware is extremely simple. The display is a portable color CRT TV with a composite input. The audio input is a cheap USB sound card. The only trick is that the Raspberry Pi composite output tends to inject audible display noise into the audio. I fixed that by adding a USB isolator between the Pi and the USB sound card.
Additionally, because the sound card input is a mono mic input, it shorts the left and right channels together, creating a mono signal. That’s fine for the visualizer (it could pretty easily be hacked to handle stereo input), but it means that there should be a headphone amp between your signal source and the mic input to prevent the Pi from distorting your sound and making it mono.
Recently on the electronics subreddits, there was a series of posts by people showing off their collections of unique old display modules. I realized that I had quite a few sitting in boxes. Unlike a lot of the posts on Reddit, I am also able to power them on to show off the goods. Enjoy!
Most of you who see this post will have seen the original UNIAC post before this, and hopefully some will have seen the post detailing the hardware. For those who haven’t, UNIAC is a Raspberry Pi based Spotify playing boombox that is controlled with buttons on the front and displays status using Nixie tubes. This post will cover the software used to make UNIAC work — both tools developed by others and the software I wrote myself.
While I am writing this from the perspective of documenting UNIAC, the software could be pretty easily recycled to work with any display and buttons, you’d just have to rewrite the display and button event functions to support your hardware.
Also note that I did a major ripup of the UNIAC software after the original post, so this version does not use Mopidy, MPD, or Mopidy-Spotify. And if any of you have used those tools before, you’ll understand that’s a good thing.
I will start with a disclaimer however: I am an electrical engineer, not a software engineer, so this design will probably make software guys sick to their stomach. Sorry in advance…
Third Party Software
The first thing to understand about the architecture used in UNIAC is that control and playback of music are two separate processes. Raspotify is a software package that connects to Spotify and makes your RPi act as a Spotify endpoint. Essentially a dedicated speaker. There are a couple of similar packages that can give you a Spotify client on a RPi, but Raspotify has a trivial installation process:
curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
The second part, Spotipy, is a Python library that you give permissions on your (paid) Spotify account. It allows you to see current playback status, and control playback on your Spotify devices (computers, speakers, etc). By combining these two, you can have a full Spotify instance running on your device with programmable control.
The two pieces are connected by the UNIAC Python script. UNIAC sets up a spotipy connection and then controls what device the playback occurs on. Since the name of the UNIAC Raspotify instance is constant, it simply has to tell Spotify to playback there, and music will play on the UNIAC hardware. This has the added benefit that I can ‘cast’ whatever I’m currently listening to over to UNIAC and it will just continue to play.
The last piece worth mentioning is eSpeak, a relatively primitive speech synthesizer that takes strings from the command line and announces them. This lends UNIAC its characteristic robot voice when announcing settings information and playlist names.
Hardware Libraries
The hardware interfaces are pretty straightforward, mostly. The buttons are controlled by an i2c GPIO expander, and Adafruit has the MCP230XX library to support it. For other GPIO, I use RPi.GPIO.
The last, and most unique library is the NixieDisplay library. It is a custom library that I developed to communicate with my Teensy 3.2 based multiplexing, crossfading Nixie display. In the first prototype, I used Taylor Edge SmartNixie modules instead of my custom display, so I also wrote a library supporting them on the RPi, though I’m not using it on the finished version.
These libraries are pretty straightforward. You print numbers to the tubes to display and forget about it.
The VU-Meter only has an audio input, so it doesn’t have any software control and doesn’t appear on any of these block diagrams.
UNIAC Software Architecture
The UNIAC software is essentially an interrupt driven button handler. There is a master ‘Menu’ class in Menu.py to which arbitrary ‘Modes’ are attached. An attached mode must provide a function handler for each physical button as well as a display update handler (and a few other helper functions).
When a button is pressed, the Menu object calls the current Mode’s handler for that button.
The UNIAC.py script creates a Menu instance and attaches the modes defined in that script. The modes (currently) are: clock, track time, date, alarm clock, change playlist, and options.
For instance, when the ‘Plus’ button is pressed in the track time mode, the menu object will use Spotipy to progress to the next track, but when ‘Plus’ is pressed in the alarm mode, it will advance the alarm time by one.
The ‘Mode’ button is a special case that does not call an attached handler function but instead changes the selected mode in the Menu object.
The Menu object also requires that each mode have a display update handler. This handler is called by the master UNIAC.py script in an infinte loop to update the display every 100 ms.
This code was actually based off of another (unfinished) project of mine which used two buttons and a character LCD. By changing the displayUpdate function and the button handlers, this script could be used for virtually any menu interface with multiple ‘pages’.
Interfacing with Spotipy
As discussed in the preceeding section, UNIAC is controlled through a series of button handlers. To interface with Spotipy, most of the modes used in UNIAC inherit from the mpdGeneral class.
This class has a few static variables and references the globally available spotipyLogin.sp object, which is an instance of the bare Spotipy API created by the spotipyLogin.py script. It includes things like track status, play, pause, loading a defined playlist from URI, listing available playlists, et cetera.
The UNIACConfig class allows settings like alarm time, current playlist, and settings to be pickled to a config file and loaded on restart. The other classes (including the option menu mode) use this class to handle i/o to the settings file, ‘UNIAC.conf’.
The remainder of the classes are more or less straightforward implementations of their self explanatory modes and hook the various parts and pieces together.
The last piece of secret sauce, which is not on git, because it is in m gitignore is spotipyLogin.py, a simple script which holds my Spotify login credentials and makes a logged in Spotipy object available.
UNIAC Supervisor
Finally, there is a UNIAC supervisor script. This is an independent Python process which checks if the UNIAC script is running and if not launches it. It also checks that only one instance of the script is running, and if a second copy has started somehow, kills all but the first process. It’s not strictly necessary, but is a nice-to-have feature. I ran without it for years, with only occasional failures.
Conclusion
The UNIAC software is a combination of several bits and pieces of code which allows a button driven paged menu system to control the Spotify web API and stream music for plaback locally on the RPi, as if it were a commercial product. The interface is ideally suited to a ‘Nixie Boombox’ but could be used with any oddball display you wanted with a little modification.
After sharing my last post on Reddit and Hackaday, I’ve gotten lots of kind feedback — and I deeply, deeply appreciate it all. More than anything else, it makes me regret not sharing this project with you sooner.
That said, the biggest ask has been for a detailed build guide. Unfortuantely, I didn’t document the build process in enough detail to write up a step by step guide, and I just don’t have the energy to build an entire new copy right now.
What I can do, however, is share discuss the design choices I made and share the build files. This post will focus on the hardware design of UNIAC, and I will follow it with a post detailing the software in greater detail.
Schematics
The schematic capture and layout was done in Eagle, and broken out into pages. It’s not perfect, by any means, but it’s clean enough.
Anyway, let’s go through the sections.
This section has:
The Raspberry Pi itself — note that the footprint says “Raspberry Pi Model B+”, but is actually sized for the Pi Zero W. I recycled an existing symbol because the header pinout is the same across both versions of the Pi, and simply forgot to rename it in Eagle. It also specifies a 7805 5V regulator to power the Pi off the input 12V bus. In practice I used a drop in switch mode replacement for the 7805 from Murata.
The button interfaces — supports two options to connect buttons. The first one, Buttons A, is for directly connecting to the motherboard. I used this option in the first two prototypes and decided to keep the option open here in case the button breakout board had problems, since I had the board space. The button connections here include a provision for +12V to illuminate the buttons, a shared switched ground line to control button illumination, resistors to pull up the buttons and caps for debounce.
Buttons B is a header for the button board, shown later. It breaks out the I2C bus connected to the RPI as well as a 3.3V rail for powering an offboard IC and a 12V rail for powering button illumination. Finally it has an interrupt pin so that the Pi can detect when the button board needs to be polled.
The next page of the schematic is a direct copy of my IN-13 VU Meter circuit. I won’t go into a full description of the theory, but it uses a quad rail to rail op-amp to save parts (I usually populate with an LMC660), and MPSA42 high voltage small signal transistors to drive the IN-13s. There is also an ATTINY85 micro running this code to make it act as a log converter. This saves parts and board area vs an analog implementation as well as allowing the VU meter to go to sleep if there’s been no audio for a couple of minutes.
The third page of the schematic covers the Nixie display. This design was inspired by Dave Jones’ (of EEVBlog) Nixie tube driver design, which attempts to save transistors by using multi transistor ICs. Ultimately, I’m not very happy with that part of the design as there seems to be enough leakage that minor ghosting is visible on the tubes. I’ll definitely revisit it for my next Nixie project.
The controller for the display is a Teensy 3.2 which accepts commands to display values on the Nixies and INS-1 neon lamps via I2C and supports crossfading between digits.
Finally, The button board uses an I2C GPIO expander IC to provide the same functionality as the individual button headers shown earlier, but without having nearly as many wires. The downside is that it requires an extra IC to do the job, and once the buttons are in the case, they’re soldered to the PCB and are pretty much stuck for good.
Layouts
The UNIAC mainboard layout is pretty compact. There’s not too much to talk about. Most of the size was defined by the need to have the Nixies at the top, bargraph tubes in the middle, and buttons at the bottom. Except for the routing around the Nixies themselves, there were no space constrained areas. I did choose to put the Teensy and RPi near the edges, so that their USB ports were practically accessible, however.
I went to great lengths to calculate minimum creepage distances and trace widths, which I used as design rules to ensure the Nixie display would be safe while being as small as I could make it. When routing my HV traces, I assumed 200 V DC and used a calculator like this one. I ended up using approximately 16mil or 0.4mm as my minimum trace clearance.
For trace width, I used 4PCB’s calculator, and found that even 600 mA would only cause a 10˚C rise for a 6 mil (0.15 mm) wide trace, way more than any of my HV traces were going to carry.vI also chose to keep the ground plane far away from the HV areas for added safety. Given that the Nixies are multiplexed and connect to ground only at a few points, it made sense and decluttered the design.
Finally, we go to the ‘Button Board’. The front panel control buttons are mounted to the front of the case and then soldered to this PCB. It’s a fairly simple design, but it has a couple of notches to clear the standoffs that mount the mainboard and speakers to the case.
The biggest pain about this board was getting it fabricated. The buttons have wide pins that need to be fabricated as small slots. This is because the pins are so wide and closely spaced that large enough circular holes actually overlap each other.
It took three tries to get the boards fabricated. I had to make sure that the slots were on the correct layer in the footprint and had to specifically reach out to the PCB vendor in advance to ask them to send checkplots to confirm that the board would get fabbed correctly.
The first order was from AllPCB without asking in advance and they simply milled the small circular holes instead of slots. The second time, they promised that they would send me checkplots, but just fabbed the board without doing so. They also ignored my customer complaint.
It was at that point that I switched to PCBWay, who provided checkplots as requested, but they actually had the slots correct on the first try, resulting in great boards. My only regret is that their matte black soldermask is slightly shinier than AllPCB’s so the boards don’t quite match the mainboard.
The bill of materials, that is, the list of all the components used, is fairly long. It lists all the components that go on the main board, as well as the button board, and all of the off board components that I could think of. Since it’s a big, ugly table, I’m just going to attach it as a csv. The major parts themselves are detailed in the first UNIAC post.
Making the enclosure was a blast. My workflow is terrible and costs me several pieces of plastic on each new design I come up with, to be honest. I design the acrylic pieces as 2D Inkscape images and handle the ‘3D Modeling’ in my head. It’s even lower rent than DaveCAD!
One of the most problematic parts of the UNIAC project has been the music playback software. The original software used the Mopidy music player for command line playback. Mopidy-spotify provided Spotify connectivity to the software. The mpd python library then allowed me to control playback programmatically.
This had several problems.
Mopidy-spotify is partially broken. Spotify themselves no longer support this interface, and haven’t since 2016. To get it working at all requires a hacked fork of Mopidy-spotify which might break forever at any time.
Response between Python and Mopidy can be really laggy and requires a continuous ping (every 30 seconds) to keep the connection alive.
Loading a new playlist in Mopidy requires significant caching and can have tens of seconds of lag, making the whole system unreasonably slow.
This was all a legacy of the fact that I had designed the software for UNIAC in 2015 and the Mopidy workflow was the only one I could find for getting Spotify playback on a Raspberry Pi. In early 2020, after hearing about Spotifyd from the Diskplayer project, I was awoken to more modern alternatives.
After some rework, I ripped out Mopidy and mpd, and replaced it with raspotify as a player and Spotipy to interface with Spotify.
This has several advantages.
The control API that Spotipy uses is actively supported by Spotify
Raspotify makes the Pi show up as a Spotify speaker, meaning active playback can be bounced between devices.
Spotipy is controlling my Spotify state, not Mopidy, so it can actually control playback of other devices that are actively playing music.
By the same token, pausing and unpausing on other clients (phone, laptop, etc.) works seamlessly.
Music is streamed, not buffered. This means that loading a new playlist is as instant as it is on the desktop client.
All in all, this means that the switch resulted in a much more pleasant user experience. On top of that, the system is generally more stable than it was before.
Plus, setting up Raspotify was orders of magnitude less difficult than Mopidy. Raspotify managed to work automagically after apt-get installing it and setting it up as a service. This was unlike Mopidy, which took forever to point at the right sound card and get working.
There were some hiccups in figuring out how to connect to Spotify with Spotifyd, but the biggest tricks were:
Learning that the credential saving path should be a full filename, not a path to a directory.
Realizing that the redirect URI could be “http://localhost”. To make that work, all you have to do is run the login script from the command line on your Pi and then copy the URL it feeds you to a browser on a desktop machine. Once you accept the terms, all you have to do is copy the ‘broken’ URL that it takes you to back into your Pi command line and hit enter. Things should work from there.
If you’re looking to build a Raspberry Pi / Spotify player, avoid MPD and go for a Spotipy / Raspotify combo!
What is UNIAC? It is the Ultimate Nixie Internet Alarm Clock. It’s a Nixie alarm clock / boombox.
It uses a Raspberry Pi to stream music from Spotify.
It has integral IN-13 VU meters to visualize the music.
It’s got a robot voice to relay information that the Nixies cannot.
It’s got clickety light-up buttons on the front.
It’s got a translucent clamshell case made of smoked acrylic.
It’s a piece of the future that never was. In short, it’s cool.
Motivation and Background
I built my first Nixie Clock in 2006, which worked, but I was never satisfied with the design. I soon began fantasizing about what my dream Nixie clock would look like. It would replace my dusty old RadioShack alarm clock.
Unfortunately, life got in the way. The project got shelved, and grad school came along, but the idea hung in the back of my mind. By 2015, the technology landscape had changed and my hands on electronics skills had grown. I had new options, and came up with a new plan using a RaspberryPi. The ultimate Nixie clock would have:
Clock
Alarm
Calendar
Spotify as the music/alarm source
To tackle this relatively complex project, I decided to break it into parts. After tackling each subsystem individually, I had a reliable, tested circuit and was able then to integrate them into a unified system.
Two Builds
The first version was built in late 2015. It was a cube of laser cut acrylic sheets with the various subsystems mounted to an internal backplane with standoffs. The internal structure was built from square 3/8″ dowels which held the sides together. This version has served well on my electronics bench since it was put together, but it always bothered me that it was extremely cumbersome to open up and service. Additionally, the acrylic backplane was just inelegant.
In 2019, with this in mind I decided I could do better. I integrated all of the components (except the front panel buttons and speakers) onto a motherboard. With a single board, I decided on a boombox form factor. This version isn’t really a good fit for a bedside alarm clock, but it is extremely satisfying.
To enable this, I built an acrylic bending jig, and designed a clamshell case to hold it all. The case was made from two pieces of laser cut acrylic. The back panel is solid black to keep ambient light out. The front is smoked grey and hides the electronics but lets the Nixie goodness shine through.
Getting the acrylic bent at the right spot took a few tries — the first test (using cheaper clear plastic) put the bend too close to the button cutouts. This caused the holes to deform and become teardrop shaped. I still think the clear case has a cool 90’s feel to it, but that doesn’t fit my general design tastes, so I stuck with the plan to go to a smoked front panel.
After a couple of revisions, the final two piece enclosure came together nicely. I was worried that lifting the unit by the handle would cause the acrylic to flex, but it’s actually reasonably sturdy. I might consider some additional brackets to more firmly attack the front to the back in the future. For now, I think mounting the two haves together through motherboard standoffs is sufficient.
The VU-Meter
When audio is playing from UNIAC, it really needed to show some “activity” — something like an oscilloscope would work, but in keeping with the Nixie theme, I decided to use the IN-13 bargraph tubes to display the sound levels on the left and right channels. No digital trickery here, the module takes analog line-level audio as a passthrough and displays the amplitude level of the audio channels on its IN-13 bargraph tubes. I’ve seen lots of mono IN-13 VU-meters, and I’ve seen a few standalone modules, but I’ve never seen them combined with normal Nixies before.
While I originally designed the VU-meter module intending to use it as a drop in component in UNIAC, the circuit has seen more service hours as a standalone module in my hi-fi (it’s been in near-constant use since late 2015). Nonetheless, it looks great in its intended role as a component of UNIAC.
I described the design of this component in detail in a series of previous posts, which includes some theory, design decisions, and schematics.
The Nixie Display
Because UNIAC is a media player, it needed a general purpose addressable Nixie display, not just a Nixie clock module. This part of the project was actually the first I began to tackle, back in 2009. I had nearly finished a display module using an 8051 and written in assembly, but stopped work when I went back to school. With cross-fading and all sorts of neat features, it was more or less what I wanted, but it had minor ghosting issues that I was unwilling to tolerate. Therefore, version one (2015) used Smart Nixie modules from Taylor Edge with a modified backplane.
For the final version (2019), I based the design off a four tube Nixie display module using a Teensy 3.2 I had built for another project. When I finish that project, I will describe it in detail in a post. Until then, you can see the prototype at the right. The chief advantages to this design are a reduction in cost versus six Smart Nixie sockets, and the ability to integrate it onto the new motherboard without using risers. The UNIAC version of the display supports six tubes and uses IN12As, but is otherwise broadly the same design.
Input is via USB serial, TTL serial or i2c inputs and supports both dimming and crossfading.
Admittedly, multiplexing by 6x instead of 4x leads to a slightly dimmer display than the previous Smart Nixie approach, but it’s good enough. If there’s a future build, I’ll likely split it up into two banks of three tubes to increase the brightness (at the cost of board area and complexity).
The Motherboard
With the Nixie display circuit and the vu-meter circuit validated, it was time to build a full system.
Version 1, built in 2015 prototype was a ‘wired together modules’ build. Using a laser cut backplane, the various modules were mounted to both sides with standoffs. The backplane then slotted into a cube made with an internal wooden frame covered with laser cut panels. This design worked well, but the rats nest of wires made it an absolute nightmare to open up and work on.
For the final version, I decided I had to replace the backplane board with a PCB. The new motherboard would have an integrated copy of the Nixie display and vu-meter circuitry. A footprint The Raspberry Pi, audio DAC, and amplifier would be on board as well. It would take 12V in, and the only off board connections would be the speakers and to the front panel buttons. Because all my peripherals used serial interfaces, the actual board design was actually pretty sparse, and most of the work was in routing the traces for the Nixie display in a way that maintained sufficient creepage.
Taking a look at the front side of the motherboard (above), it’s primarily the cosmetic components. We see the six IN-12A tubes, eight INS-1 neon bulbs, two IN-13 tubes. Also of note are the unpopulated pads along the bottom for connecting the buttons directly to the RaspberryPi, which are unused in this build in favor of the i2c button board (described in the next section).
A Tour of the Motherboard
On the back side of the board, we can see a ton of components.
Next, in green with a raspberry symbol, is the main CPU, a RaspberryPi Zero W (hereafter RPi), which is the core of the system.
To the right of that is a rainbow ribbon cable going off to the button board.
Next, at the right is a TES-1364H boost module. This provides HV for the IN-13s. It is twinned with another -1364 at the top right, which provides HV for the numbers. I chose to keep the two supplies separate not because I was sure I was out of current, but because the two sets of tubes call for different striking voltages, and I didn’t feel like adjusting the values of the two display circuits to compensate. In a future revision, I’ll absolutely address that.
The group of components just right of center are the components for the IN-13 display, which are described in more detail in the IN-13 VUMeter posts, but the two DIP ICs are a quad op-amp and an ATTINY85.
The two tiny green three-pin boards are Mu-rata OKI-78SR modules. These are more efficient drop in replacements for the classic LM7805.
Connected to the sound card is a blue Adafruit class-d amplifier board at the bottom left. It was chosen because it is relatively low-noise, has a mute pin, and can use an external pot for volume control — here you can see the wire for the pot running off to the knob on the side of the rear panel.
Finally at the top left is a Teensy 3.2, the CPU for the Nixie display module. This is gross overkill to drive a display, but it was convenient to code up quickly, and I was able to set it up as an i2c slave, simplifying communication with the RPi.
The Button Board
For the control panel interface I chose some clicky 12V illuminated momentary buttons that were intended for industrial applications. Very satisfying. They were about $1.30 per each, so not cheap, however. Given that the buttons are the main user interface, having something that satisfies the retro vibe satisfactorily was worth it.
The 2015 version used a single GPIO pin on the raspberry pi for each button, and used a single GPIO (through a FET, obviously) to switch the lighting on them all on together. This, again, led to a tedious amount of manual wiring, so I designed a button board using a MCP23017 GPIO expander to connect to the buttons. The board itself is very simple, although I had the first boards manufactured by AllPCB, and they failed to route the slots, despite saying they’d confirm the slots with checkplots in an email discussion beforehand. This triggered my switch to PCBWay who correctly provided checkplots and produced the right board. I have been using them since, and who have treated me well — no they aren’t sponsoring me, I’m just pissed off enough at AllPCB to mention it, since they ignored my customer complaint that I filed after the fact.
The Battery Problem
Okay, it’s time for full disclosure, I’ve been calling this project portable, but throughout the build process I treated a battery as “something I would figure out later” — It turns out the BMSs are no joke, and there wasn’t much out there that would suit my needs. The fundamental problem is that there’s a large burst of current on power up, despite the fact that the overall system only draws a few hundred mA when fully up and running. I tried a few low cost boost converters and they all browned out before the system booted. As I wanted to share the portable UNIAC with my friends at PAX 2019, I ended up punting last minute and taping a 12V battery pack from Amazon to the back of the unit.
Music Playback
To play music, I am using the command line media player Mopidy and its Spotify plugin, Mopidy-Spotify. This requires a premium Spotify account to work, and is brittle. The API Mopidy-Spotify uses is not supported anymore. I’ve found that the repo fails to load my playlists unless I use the fork mentioned in this thread.
Getting the audio itself to work was also a massive pain, as the various Linux audio subsystems like to fight as is, and the I2S audio card I was using made things more difficult. I could go into more detail here, but I think it merits its own post…
For the first version of the UNIAC with TES SmartNixie modules, I whipped up a quick python library to interface with them. It might come in handy for someone else, so I have published it here.
For the final version, I was using my own i2c display module, so I wrote a (nearly) drop-in replacement library for the SmartNixie library, so I could minimally modify the main UNIAC application to support the new display. It is published here.
It supports some fun features like dimming, cross-fading, blanking, and blinking.
The UNIAC Application
The main UNIAC application is a python script. The main loop probes the interface buttons and then calls a python god object, which maintains various states, drives the displays and voice, and sends audio commands to Mopidy. There’s a lot to this application, but that’s an entire post in and of itself. Until I get around to a full writeup for it, you can find it published here.
Conclusion
At the end of the project, UNIAC is probably the most satisfying hobby project I have yet made. Due to the brittle nature of the Mopidy-spotify, my next task is to move the Spotify interface to spotifyd, which I discovered due to reading Dino Fizotti’s excellent Diskplayer writeup. The other glaringly obvious improvement is adding a proper, internal battery system.
Longer term, I’d like to try to integrate it with a voice assistant to really supercharge interface, but that is more software work than I’m willing to take on in the immediate future.
The sad irony however, is that I’ve spent so long listening to the crappy buzzer of my Radio Shack alarm clock that I actually don’t want to give it up now. I’m conditioned to wake up to it quickly, and it takes up little space on my nightstand. Oh well. Maybe the next project will be a UNIAC Mini with an alarm buzzer feature.
I know this has been a long post. Thanks for sticking with me!
My fascination with Nixie tubes began around 2006. These beautiful retro tubes make amazing displays and have been made into hundreds of well documented clocks. At that time I bought a handful of tubes and got permission to build a Nixie clock as project for a senior level undergrad EE lab course. I actually built it as two separate boards, a serially addressed Nixie display and a serial output clock module.
Both the display and the clock were built around an AT89C4051 microcontroller, with direct drive using one K155ID1 per chip. The high voltage supply was a switch mode module from LEDSales (I have since moved on and all my more recent projects use the Taylor Edge 1364). The tubes themselves were Burroughs B5750s, which I got on pre-made break out cards with edge connectors, two tubes to a card.
The clock module also used an AT89C4051. The very simple timekeeping circuit took an AC input through a voltage divider and zener clamp and counted pulses. This is actually a surprisingly stable way of keeping time, as at least in the US, electric utilities will actually slow down or speed up frequency slightly overnight to make up for irregularities during the day. This means that while line frequency clocks are worse than cheap quartz clocks hour to hour, they are actually generally more accurate month-to-month.
For the display board, I didn’t have a saved copy of the routed PCB, and as it was one of the first boards I ever laid out, it wouldn’t have been good anyway, so I just re-downloaded PCB123 (again, I was a ‘young player’ as Dave Jones would say) and ran the autorouter to give you the just of the board. Each 40-pin header drove a dual Nixie card (god, the inefficiency!)
I was never really happy with the clock design, from a user perspective, so it got put away pretty quickly. The display module, on the other hand was really satisfying. It ended up at my first full time job. Because I worked at the local power company, and had access to real-time SCADA data for the grid, it was used to display the power consumption of the city we were in (in MW).
The code ran in Python and used a command line utility to extract the various datapoints, which it then drove to the display, updating every five seconds or so. The final version would rotate between showing power consumption for two cities that we served, and the temperature (˚F) in each of those places.
It definitely got a few looks over the years that I had it running, and I still have the display in a box somewhere, but I’ve moved on career wise, so I don’t have the cool data to display in real time anymore.
Oh well, not much of a story, but I thought I might as well document it and share.
Every year I like to do some sort of artistic project as a gift. Historically they have been unique one-offs that I have yet to post here. This year however, I decided to do something a little more traditional — a Christmas ornament. I figured I could ‘mass produce’ them, and give one to everyone relevant, including sending them along with my annual holiday cards.
The first challenge was coming up with a circuit. My primary requirement was that it should be able to last a whole season on a single coin cell (CR2032). Obviously, even with high efficiency LEDs, that would be nigh impossible, and giving up and going to 2AAs would have made the board too heavy to realistically hang on a tree.
I therefore decided that it would start to blink when triggered by a human somehow and would then shut off after a few seconds. I briefly considered using a passive infrared (PIR) motion sensor, which would have been affordable from the usual Chinese suspects on ebay, and would have met my power requirements (they can be incredibly low power in standby) but they also are rather bulky compared to size and weight requirements of an ornament.
The second (and obvious fallback option) would be a simple tactile switch. This has several advantages:
Cheap
Easy to implement
Low parts count
Unfortunately, it has one fundamental flaw: To activate it requires a non-trivial amount of force. Not exactly a problem for most devices, but for an ornament dangling from a tree, it wouldn’t do, to require the user to grab and hold it (possibly with two hands) to make it do something. This left one more option: Touch switch.
The design is extremely simple — since I can afford to expose bare copper (well, tinned), I can float the base of a transistor to act as a switch when a touch to the exposed metal pulls the input to VCC
For the metal plates, I designed a pair on interdigitated polygons, as below, with one side pulled to VCC and the other connected to the base of the transistor.
Note that this design would not work with even the thinnest of gloves, is prone to corrosion, and might not even work for someone with extremely dry skin. BUT, it is cheap, simple, and extremely low power – wasting less than 1 µA quiescent current.
For the main circuit, I started out with an all analog design. The touch switch would have triggered a mono-stable oscillator, which turned on a bi-stable block, which in turn would drive the LEDs through a buffer transistor. There were several problems with this approach however.
A jellybean 556 cannot run down to 2V (the dropout voltage for my single lithium cell) reliably.
More sophisticated timer ICs are similarly priced (or more expensive) than a microcontroller.
The standby current would at least as high as what I could achieve with a microcontroller in deep sleep.
Since I already had the tool chain set up to develop with the ATTINY85 microcontroller, I chose it – if I had more time to develop, I would likely have spun up the ATTINY10 (and indeed, I grabbed a handful of them) since they’re so low cost.
I chose run the ATTINY on its internal 1MHz oscillator, for absolute minimum power consumption. I also chose a variant which could run down to 1.8V, which would let me run my single CR2032 pretty much dry.
The final design, shown below was criminally simple. I tested it on a breadboard while I developed code and was able to drop it onto the PCB with (essentially) no changes.
I decided I was going for so low parts count that I even chose to omit the decoupling cap on the micro – I figured since it was the only active component, I could get away with saving the penny.
The biggest omission, however, was using only a single current limiting resistor for each color of LEDs. This is obviously bad practice and you should never, ever do this (TM), but given that my power supply is a high ESR lithium battery and the LEDs were grouped from a single batch on each board, I decided to take the risk. The reason for this is simple, it saved me 22 resistors and realistically, needing to find a way to handle a double sided load in the hobby reflow oven (or more realistically, soldering down by hand 4x as many components as I already was planning to, per board).
Code
Writing code for the ATTINY85 is almost criminally easy given that it is supported by the Arduino environment. Programming can be done with my trusty Sparkfun TinyAVR programmer, which I used with an SOIC adapter clip to program the SOIC parts I used in-circuit.
The underlying code is, unsurprisingly simple, but I am pleased with the design. After boot, the system goes to deep sleep (SLEEP_MODE_PWR_DOWN) until awoken by an external GPIO interrupt. When triggered, turns on one phase of the LEDs (e.g. red), goes back to sleep, after setting the watchdog timer, which awakens it a half-ish second later. On wake, it toggles to the alternate LED phase (to green or back to red), and repeats until the requisite number of cycles has been completed. Then it goes back to deep sleep.
The layout is fairly straightforward. I laid out the board outline and silkscreen in inkscape, and then following various tutorials imported the outline and silkscreen into Eagle. Sizing the two correctly was a guess-and check experience. I didn’t take comprehensive notes on my import process, so unless someone asks for it, or I do it again next year, I’ll leave the details out of this post.
I am somewhat proud of removing all but a handful of visible vias and one trace on top of the board by hiding most of the vias underneath the LEDs.
Conclusion
I did take some measurements, and the device draws about 5mA while blinking and about 2µA when off (Not that much worse than the self discharge rate of the CR2032), so I’d call the design a roaring success. It certainly was a hit at the holidays!
This was a fun, quick and dirty Christmas ornament project and I will be revisiting it in the future. Expect a 2020 Christmas project post.