Not content with just attending Defcon 2019, I decided to also purchase a ticket to the Too Many Games convention in Philadelphia this summer. This was partially because a lot of the streamers from my favorite Twitch group, Vinesauce, were going to be in attendance for a couple of panels and meet and greets. Another convention means another custom badge, so I decided to make a really simple Vinesauce themed “blinky badge” to show my support. Compared to the badges I like to make for Defcon, this one would be much simpler. Just a simple LED lightshow on a themed circuit board.
The major difference in this project was I wanted to make over 20 of these badges, not just 3 or 4. A lot of people I spoke to wanted one for the convention, and I want to be able to give them to Vinesauce streamers as well. I ended up making a small assembly line in my bedroom to churn these out, more on that later.
At the heart of this badge is a super low powered ATTiny20 microcontroller. It has a measly 2KB of program memory and 128 bytes of SRAM (same as the Atari 2600!), but it’s cheap. At the time of writing, it’s 57 cents per chip. It also has a fair amount of IO pins, which is what I really need to do an LED lightshow. It takes a wide range of voltages, which would allow me to drive it directly from a couple of AA batteries without any complicated power management circuitry.
I wanted a massive amount of LEDs on the badge, so I decided to create a charlieplexed LED array. This allowed me to drive 30 LEDs from only 6 IO pins on the microcontroller. Charlieplexing would make the final code a bit more complicated, but it’s completely worth it for the IO savings.
Since I would be giving these out to around 20 people, I wanted some kind of reverse current protection in case someone put a battery in backwards. I tried to design a circuit that would use a mosfet to cut off current to the rest of the board if it detected backwards batteries. I wasn’t entirely sure of this design, so I also integrated a simple diode that wouldn’t allow for reverse current. The diode solution used more power and was more expensive, but I was 100% sure it would work. The protection method could be changed by cutting and bridging a couple of jumpers on the board.
The mosfet circuit ended up not working and I had to use the fallback diode protection. Using mosfets for reverse current protection seems to be the industry standard so I probably could have gotten that circuit working, but it would have required another expensive order of new PCBs.
I’m completely devoid of any artistic talent, so I enlisted the help of Jerge to create the art for the badge. She created a simple Vinesauce shroom that ended up working really well. PCB art needs to be really simple since circuit boards are such a limited medium. There are only a couple different colors to work with, each corresponding to a different PCB layer (copper, silkscreen, soldermask, etc) on the final product.
I ended up adapting her design in as follows. Unfortunately, some of the shading had to go.
This was the design that I ended up sending to the fab house. Unfortunately for me, the ATTiny variant I was using had some kind of nonstandard package size and I had to do two board runs to get a PCB that worked. I ended up really regretting using that tiny package size, it was a huge pain to solder and I had the board real estate to use a larger chip. Hand reflowing a chip smaller than a grain of rice is not fun.
There was no way I was going to hand solder 22 of these. I probably would have eventually gone blind trying to attach all those tiny surface mount components. Here’s an example of what how big the ATTiny is next to a grain of rice.
Surface mount boards like this are usually reflow soldered and machine assembled. This involves using a stencil to spread liquid solder paste onto the board, pick-and-placing each individual component, and finally baking the whole assembly in an oven to melt the solder. I have a (hacked together) reflow oven, so I just needed to create a solder stencil so I could squeegee on the solder paste.
It’s possible to order solder stencils for your design online, but I really wanted to create my own for this project. Stencils are usually made out of steel, but for short runs its possible to use plastic or kapton (polyimide) tape. I had large sheets of kapton already, so I ended up using those. I enlisted the help of one of my professors at my University and got access to the art department’s laser cutter.
We ran a couple of test runs and it worked beautifully. The cuts were super precise and cleaned up nicely.
I also cut a jig out of scrap wood to hold the boards in place while I squeegeed on the solder paste.
Compared to manually applying the solder paste, this method was about 5 times faster and a lot more precise. Solder only went where it was supposed to, which meant almost zero post reflow cleanup
I don’t have a pick and place machine though, so I still had to hand place all the components myself. Still, just placing them is way better than hand soldering them.
Once everything was placed on the board, they go into the reflow oven. This actually melts the solder and creates all the electrical connections.
Time for a smoke test. Lets see if the new techniques worked
Success! The board lights up. Now it’s time for programming
The full source code is here on GitHub. I had to use a couple tricks to get everything to work in the limited RAM space, but I’m pretty happy with how it turned out.
The board basically cycles through a couple different animations when the user presses a button on the back. Each one of these animations is programmed in as a function, and each animation is stuck into an infinite loop. When the user presses the button it triggers an interrupt that tells the ATTiny to play the next animation.
The charlieplexing is handled via a couple of lookup tables burned into the program memory, these tables handle the direction and port bit for each LED. I talked directly to the ATTiny IO registers to make sure this routine was fast. Since charlieplexing only lights up one LED at a time, I wrote another function that lets you cycle through 32 bit framebuffers (one bit per LED) really fast so persistence of vision kicks in and it looks like more than one LED was lit up. You could then string these together to create an animation
The Final Product
This was a really fun attempt at the famous “garage assembly line” that’s ingrained into silicon valley culture. I’m amazed that I was able to hand assemble a product that I could actually see myself selling. That being said, I never want to do it again. It’s extremely tedious work and there are plenty of services that will assemble your boards for you for a fee. When I have a bit more money, I’d like to give that a try.
Clip of the badge on the Vinesauce art segment:
- When hand assembling boards, pick the largest components possible. The small amount of board space you save is not worth the hassle of a complicated reflow.
- AA’s are overkill for lighting up LEDs. I’ve left one of these badges on for two weeks straight and it hasn’t lost any brightness yet. Button cells are more than enough.
- Print a scale mockup of your board on a sheet of paper and make sure all the components fit properly.
- Test your circuits before you order your PCB!
- Laser cutters are awesome