• USB Status Light: Prologue

    Stephen Holdaway05/12/2019 at 10:04 0 comments

      Writing firmware for the v1 USB status light in 2016

      A couple of years ago I was part of the site-reliability team at Xero - a squad of in-flight cyber mechanics outnumbered 100 to 1 by a fleet of production servers. To cut through the daily noise of alerts, logging and system metrics, I figured a simple light on my desk to say "something's not right" would be a useful novelty. The catch? This was my second electronics projects, and I had no idea what I was doing.

      Searching for "usb controllable led" in 2019 lists a bunch of devices you can outright buy, but back when I started this project in 2016 there didn't seem to be much around. At the time I referenced a single article about a "USB status cube" someone had built, but searching for that article now turned up numerous projects doing exactly the same thing as I ended up with: an AVR chip, V-USB and a bunch of programmable LEDs. I have no idea how I missed all of these at the time, but we can chock it up to blissful ignorance.

      In any case, this is the story of my first PCB and how it's still a useful tool almost three years later. This isn't a build guide, but if you're building something similar you can use this as an example of what not to do.

      How not to draw a schematic

      In my first electronics project I'd skipped a schematic and PCB and simply used point-to-point wiring and some strip-board to hack it together. For the status light, a PCB was needed to arrange 9 surface-mount LEDs in a fixed pattern, along with the SMD WS2811 chips and microcontroller.

      Now keep in mind at this point I had never laid my hands on any EDA software. I grabbed a copy of Eagle (because that's what I'd seen other people using - I recommend KiCAD now) and set to work bashing my fists on the keyboard until this monstrosity came out:

      An awfully bad schematic made in Eagle - my first schematic

      Among the overlapping, diagonal wires, lack of decoupling capacitors, lack of meaningful labels (what are those USB pins!!?) and haphazard organisation, I'd give this an F for "functional but utterly terrible". It definitely captures the "I have no idea what I'm doing, but I have a goal to achieve" spirit that comes with being a total newbie.

      The crisscrossing wires were introduced during layout to make it possible to route the board single-sided, but it's a gross schematic regardless. Also note that the LEDs were desoldered/borrowed from a 12V WS2811 strip that used groups of generic RGB LEDs with separate driver ICs, so even though this design has 9 LEDs it's only three addressable columns.

      For reference, here's the USB part of the schematic recreated to be actually meaningful:

      Recreated V-USB circuit for the USB status light

      PCB layout

      Choosing to create a single-sided board with 50+ connections for my first PCB layout experience taught me two things:

      1. PCB layout is a really fun puzzle.
      2. People who do PCB layout professionally are the unsung heroes of this era.
      This layout also graded F for "technically functions". It follows no rules other than "pads on a net must be connected".

      You might notice that the layout pictured is version 1.2. The first attempt (picture) ended up a complete mess of bodges as I'd missed a reset pull-up for the AVR, had multiple unconnected ground pours, and had mirrored the ISP header. The original version also had one less LED in the centre column, which gave uneven brightness so a third was added.

      I won't go into detail about making the PCB at home other than saying it taught me to avoid making PCBs at home unless absolutely necessary. Sure, do it once as a learning experience, but then you'll understand why it's usually better to pay someone else to do it.

      Home-made PCB: not recommended.
      The application of solder to the entire board was 50% mess from soldering, 50% trying to hide said mess by covering the whole board in solder.


      The firmware for this original version of the project isn't particularly interesting or good, but you can download...

    Read more »