Learning the Custom PCB Design Process: My Pet Firefly

This post is a project update designed to share my experience making something. The information inside is not designed to be a complete tutorial for the project, but to discuss a milestone or achievement, and talk about the learning experiences (mistakes) I’ve had along the way. Please refer to the Projects page for links to full explanations/tutorials of my finished projects!

Introduction:

So I made a thing. It’s not a very complicated thing, but I thought it was pretty cool, so I made it.

The thing is a Firefly Mason Jar Circuit. It’s not a particularly original idea, you can find them pretty easily if you Google “Lightning Bug Circuit.” That being said, I took this project as a challenge to see if I could make a fully integrated, custom PCB (Printed Circuit Board) design, that kids could use as a Learn-2-Solder project!

ba956b7bf797c526a191c3e16f5f2365.jpg

This is my first time writing a blog post about a project, so I think I’ll use this as an opportunity to break down my thought process, and how I went about designing and fabricating this board.

DANGER! Technical Jargon Ahead!

When the idea originally popped into my head, it was actually to create as a gift for my girlfriend at the time. I wanted to create a lightning bug necklace pendant, that would hold a single firefly year-round. My inspiration came from projects like these:

  • https://www.instructables.com/Lightning-Firefly-Bugs-Jar/

  • https://www.instructables.com/Jar-of-Fireflies-animated/

 

Stage 1: Pretotyping

Before I begin building anything, I always start with a Pretotype. Pretotyping (not prototyping) is a term coined by Alberto Savoia in his book “Pretotype It.” It is defined as “Testing the initial appeal and actual usage of a potential new product by simulating its core experience with the smallest possible investment of time and money.” Basically, it’s the “pre”-prototype, a very rough mockup of the MVP.

For this idea, I started by sketching out a basic circuit diagram for this project. This involved lights, a power source (batteries), and some sort of IC. To decide on these components, I looked at the form factor and power requirements I had to follow. I knew I wanted something “pendant-sized,” so I made a trip to the nearest crafts store and found these little mini mason jars! I liked the design, because if you’ve ever caught fireflies in the South, you’ll know mason jars are the go-to trapping device. This gave me my size requirements. I also wanted to decorate the inside to look like a mini terrarium so I picked up some lichens and moss, normally intended for making plants in a diorama.

20201027_184022.jpg
20201027_184514.jpg

Once I had the container, I had to make measurements, and I found that my size constraints was a cylinder with a diameter of 0.5” (12.7mm). Somehow, I had to fit batteries, a light, a resistor, and an IC into this tiny width, and I wanted it to all fit under the lid. Batteries came first. I needed 3 Volts for the LED’s, but because of size constraints, AA’s & AAA’s were right out. I wanted something rechargeable with a plug, so I started looking for LiPos. Sadly, the smallest 3V LiPo I could find was 0.45” wide, but 1” long, so I switched gears to hunt for coin cells. I found that your standard 1.5V LR44 watch battery had a diameter of just 0.45” (11.5mm), and had just a height of 0.2” (5.1mm)! I could easily stack two of these to meet my 3V requirement, and fit them nicely into the neck of the jar (with room for wires).

The next step was to pick out an IC, because I needed something that had a tiny form factor, with the ability to use PWM to flicker the LED. I was already familiar with the Atmel AVR Microcontrollers (the IC’s that power Arduino and the like) and I knew they had many form factors, like the Mega, the Micro, and both featured both DIP and SMT versions. I originally wanted to use the ATTINY10, the smallest of the bunch, but it was honestly too small to deal with, so I went with the next size up, the 8-pin ATTINY85. With a quick google search, I found the pinout for the chip. The 85 has two PWM pins, which allows for two analog outputs (this comes in handy later on). It also has a voltage rating of 1.8-5.5V, which makes this perfect for our project. Now that I had researched the parts, I sketched up the schematic and began the assembly.

52713d5b757b7fc0658b4567.png

First, I had to figure out how to program the ATTINY85, which was pretty easy using this USBasp V3 programmer, and the Arduino IDE. I found this tutorial to be quite helpful. I wanted the light blinking to resemble a firefly’s blink, so I referenced a bunch of YouTube videos to see how a firefly blinks.. and what I learned was so cool! Did you know that fireflies actually contract their abdomen when they glow, almost like cracking a glowstick?

oYQWyGW.gif

SO COOL. Anyways, male fireflies use blinks to communicate to the females in a surprisingly complicated mating ritual (talk about foreplay!) and that gave me an idea. What if I could make the firefly blink in Morse code? This sent me on a huge tangent and a good extra two hours of programming to write the most complicated blinking program that would take in a message, translate it to Morse code, and then blink it in a way that looked semi-natural. The end effect was wonderful!

Soldering the parts proved to be difficult because of how small the form factor was, and I ran into several major issues with how to house the batteries. I couldn’t get the batteries to stay together, so I ended up using electrical tape to connect them. Then I had to attach the wires somehow, which created another dilemma. Solder doesn’t like sticking to the polished contacts of the batteries, and batteries will deteriorate (and even catch on fire) if they are heated too much. I tried to drop molten solder onto the contacts, which seemed to work, but the joint broke almost immediately. In the end, I had to (don’t try this please) use sandpaper to rough up the contacts of each battery, then drip solder on it, and finally cover it with a layer of hot glue to keep it in place. This was the biggest difficulty caused by the size constraints. Soldering the resistor, LED, and ATTINY85 were very easy, and once it was all put together, it glowed quite nicely!

ezgif.gif

After completing the project (and having to re-solder the battery connections many times in the process), I realized that the pendant was still not small enough. I knew I couldn’t scale it down any more with the tools I had, so I began to think about making a full sized (or half sized) mason jar. As-is, the project served as a very cute little nightlight, but it only lasted a few hours due to how much power the ATTINY consumed. (It also didn’t have an off switch). This is why pretotyping is so important, because you find so many issues with your original idea. These issues created the improvements you see in the final, full-sized Mason Jar design.

 

Stage 2: Designing the Custom PCB (w/ EAGLE)

Time to go back to the drawing board. I took all of my complaints with the original idea, and wrote them down. Then I also put down solutions for those problems:

 

Problems:

  • Too Small

  • Short Battery Life

  • No Off-Switch

  • Janky Battery Connections

Solutions:

  • Larger Case (Full-Size Mason Jar)

  • Bigger Batteries (AAA’s)

  • Add an Off-Switch

  • Use a Real Battery Clip

 

Now it was time to open up EAGLE.

The first step was to create a new project with a wire diagram, and then add the new parts. In terms of what parts I chose, I based that (again) off size constraints. The average inner diameter of a standard Mason Jar is 2.375” or ~ 60mm. This gave me my board size, which allowed me to choose the right batteries. My options were two AAA’s or one 9V, but the 9V seemed overly complicated due to the fact I would have to use a voltage regulator to knock it down to 3V, and most cheap 9V batteries are essentially six AAA’s on the inside. I was very lucky too, because the length of a plastic battery clip for 2 AAA’s was just under the diameter of the circuit board. I added a basic SPDT slide switch, and I used green 0602 LED’s that were rated for 3.3V. (Most LED’s are 1.5V, which is why you need a resistor to protect it from burning out.) I also added a 6-pin header for the USBasp programmer, which would allow me to program the chip on-board, instead of having to program it before installation.

The difficult part about this step was finding libraries online for each of the parts I need, which mostly involved going to vendor websites like Mouser or Digi-Key, and looking through their catalog to find ECAD schematics. Once I found all the parts I needed, all I had to do was drop them into EAGLE’s libraries folder and activate them in the control panel (which requires clicking the grey dot, so it will turn green) Then I used the “Add Part” tool, and placed all of my parts in the workspace. After all of the parts are placed, I used the “Net” tool to connect wires from each of the points.

Schematic.png

Now that all the components were nicely arranged and connected, I went to File>Switch to Board, which prompted me to generate a board from the wiring diagram. EAGLE automatically places the parts and connects them with guide wires that tell you which joints are connected. Using the Circle tool, I switched to the Dimension Layer (20), and drew the outline for the board. Then I placed the components in a logical manner (so as not to cross over each other), and connected all the points using the Airwire tool. Then I drew another two circles using the Polygon tool on the Top and Bottom layers, which created a GND (ground) and VCC (power) plane, that the pins could automatically connect to. This prevents a huge mess of extra power and ground wires from cluttering up your board. (Big thanks to Professor Chris Coulston for teaching me about that little trick!)

At this point, the board is complete, but any good PCB designer worth their salt should know how important the silkscreen is! (At least, that’s what I’ve been told.) The silkscreen is a layer of (usually white) material that is printed on top of the board once it’s finished being fabricated. This is the white text you see on many boards that label the components, their orientations, and provide useful identification information, such as the type of component, or creator of the board. I’m still new to silkscreens, so I may violate some best practices, so bear with me. This was my approach.

First, I labeled all of the components with their names. Most people don’t seem to do this, and it really bugs me, because you have to assume what component fits in which hole. This makes it very difficult when it comes to transistors and ICs. In my opinion, if I pick up a random PCB someone designed, I should be able to immediately infer how it works and what it does.

BoardFinal.jpg

Next, I labeled the terminals of the “polar” components (e.g. the battery terminals and the LEDs) with +, -, and/or GND. I labeled the 6-pin header with it’s respective programming pins, and I also labeled the switch with the On and Off positions. Lastly, I added the name of the board, creator (me), and date created. (I also added a very small Easter egg, but we’ll see if it turns out good. :P)

Now that the board is finished, it’s time to export the Gerber files. Gerber is the format that PCB Manufacturers can use to fabricate your PCB. With EAGLE, this is very simple, all you do is go to File>Generate CAM Data, and it will export a .ZIP with everything inside.

 

Stage 3: Fabrication & Manufacturing

This was the part I found most intimidating. I’ve never actually ordered my own PCBs before, so I didn’t know who to use, or what rules I needed to follow. My friend recommend JLCPCB, because of their (downright insane) 2$ for 5 boards deal. JLC also has their very own Gerber Viewer, which allows users to upload your .ZIP (from the last stage) and view a rendering of the board. This is very useful to check for errors in the PCB Design, and I went back to EAGLE several times to make revisions until I was happy with the design.

Gerber Viewer.png

The rest of the ordering process is fairly straight forward. JLC lets you pick a custom color for your PCB, as well as providing many advanced options, but the default options are usually sufficient. One thing I would like to note is that JLCPCB will put an Order Number on your board, but they provide a Specify Location option, so you can specify where that number should go, which I recommend doing. My first prototypes came out with the number right on the front of the board. (Gross!) After I was happy with the design, I placed the order, which started the review process, and I got an email as soon as they began production. Lead time is one day for Green PCBs, and three days for any other color.

Speaking of Lead Time, what about our parts? I still need the components for the board itself! To find these, I just used AliExpress, searched up the parts, and made sure they were the right ones. Then I placed an order. One thing to note about ordering parts from China, they take a LONG time to ship, sometimes 30-50 days. On top of that, you have this concept of lead time that most people outside of industry don’t know about.

Lead time is the process of producing and packaging a part before it is sent to a business. Lead times will change depending on the item, the time of year it’s placed, and their location. This was the reason I went through AliExpress and not a “more reputable” source like DigiKey. Not only are the parts way more expensive, the lead time for DigiKey was 10 weeks! That means I’d be sitting around, twiddling my thumbs for three weeks just to get a few components. AliExpress didn’t have a lead time, but the shipping would take a few weeks. This was still half the time DigiKey would take to get me my parts, so I went with AliExpress. Moral of the story, always pay attention to the lead time of your parts, because this will be a huge influence to your design when time is a priority. I had to change battery clips last minute because of this exact problem.

 

Conclusion:

Looking back, designing my first custom circuit board wasn’t actually that bad. It seemed really scary at first, but I just broke the process down into little achievable steps, and asked lots of questions. I think the most important thing I’ve learned when it comes to PCB design, is to just start making. You learn so much just by doing! I hope this blog post has inspired you to go out and create something. Just know that you don’t need all the answers before you start to solve a problem, otherwise there wouldn’t be a problem to solve!

Other thoughts:

  • When designing a project, always consider the projects constraints, whether that’s time, money, or physical requirements.

  • JLCPCB provides a lot of forgiveness when it comes to cheap prototyping because of their inexpensive and rapid production process.

  • ALWAYS pay attention to lead time!

And that’s it for this project. All that’s left is to see if the PCBs work once they arrive! (ETA: mid-November)

Also, if you’re interested, you can preorder your very own Lightning-Bug-In-A-Jar kit (Pre-assembled or Assembly Required) in our Store!

PCBRenderAngle.png
If you’re interested in learning how I made this 3D render of the board, let me know!

If you’re interested in learning how I made this 3D render of the board, let me know!

Previous
Previous

The Book that Started It All.

Next
Next

First!