Introduction: PCB Christmas Tree Card
This September I saw the instructable about PCB Christmas Trees and thought they were pretty dang cool looking. As with most cool looking things, to me the effort for a one-off does not seem to be worth it. I think bluqesh would agree, after all he made 10 and gave them to family as gifts, which seems like a fantastic idea to me. So, for this years Christmas I wanted to do the same!
With that in mind I redesigned the PCB Christmas tree from scratch. Most notable, this version can be packed flat to fit into an envelope so I can send it to everyone I don’t meet in person on Christmas! The design includes a custom Christmas card which contains brief and simple building instructions and offers plenty of space for a custom hand written note.
For you, dear reader, I’ve prepared step-by-step building instructions and included all files required to make as many PCB Christmas trees as you like.
Whether you are just here for the pretty pictures or actually read a bit, I hope you enjoy this instructable. (Late) Merry Christmas and Happy New Year!
Several people have asked me if I offer this as a kit. I planned to offer a few for this year's Christmas, but the year has been a bit chaotic for me. If you want one for next year, please send me an email to put you on the list!
If you only need the adapter, I have a few improved ones available on reddit.com/r/moneromarket, so come and take a look :)
Step 1: Design Goals
As mentioned in the introduction, the major reason for the new design was to improve the shipping process. Sure, you can send a box with an assembled tree, but they accepted by the recipients at their doorstep. I they are not at home, they have to pick it up at their local post office. Considering how stressful the last few days before Christmas can be, I’d rather not waste their time with stupid things like this. And besides, who doesn’t love finding an unexpected letter in their postbox?
Another important thing to consider was that most recipients are not anywhere as interested in tech as I am. Therefore I wanted the new design to look aesthetically pleasing and be intuitive to use. Here’s my check list:
The tree must ship flat and thus can’t be fully assembled. A flat envelope allows it to fit into a standard post box and produces less packaging waste.
- Assembly & Usage:
The assembly must be trivial with minimal possibility of accidental damage. Try and error can be intimidating to non technical people so I wanted to include brief, yet sufficient instructions.
The design must look good from most angles, with and without colorful blinking LEDs. I also want it to keep standing on its own.
The aforementioned card should contain the individual parts so that they don’t rattle back and forth in the envelope. It should also provide enough support to be robust enough for transport.
Step 2: Design: Sliding Connector
The most interesting challenge was to connect the two main PCBs that form the tree. It requires a good mechanically stability and at least 3 electrical contacts (2 for power, 1 wire for data). The original design used right angle headers, which are unfortunately through hole components and too large overall.
The mechanical design is quite easy and inspired by 3D cardboard sculptures. Each part has a slit in the middle through half of the length, so that both parts can slide into one another. The electrical connection is more tricky. You could probably put a single pin in each corner and have the mating parts on the other board if you could accept the extra 5mm thickness. I also considered using a small cable, but quickly dismissed this idea as it would be more complicated to assemble then I’d like.
In the end I used PCB mounted spring contacts. These are usually installed vertically to make contact with an antenna or a vibration motor embedded into the case of the device. Quite often you’ll find similar parts to make contact to other metal parts to improve shielding and pass FCC regulations. After a lot of research I settled for the springs shown in the picture above and soldered them onto their side to convert them into sliding contacts. It worked well on the small mechanical prototype, so I implemented it on the final PCBs as well!
Step 3: Design: Electronics
Most of the functionality stays true to the original, however the implementation became a lot more sophisticated. Besides converting everything to SMD (including the battery holder) I also wanted to reduce the parts count to the absolute minimum. More parts take more time to assemble and take up precious space on the PCB.
The first choice was to replace the AA cells with a CR2032 coin cell. In addition to the smaller size they also have flatter discharge curve making an additional regulator unnecessary. They also rarely leak and have a shelf life of a decade or so.
With the 3V supply voltage set, I could not use WS2812B addressable RGB LEDs or similar parts. For normal multiplexing I’d need to many connections between the PCBs, so I went with charlieplexing once again. Similar to my last project, the series resistors to the LEDs are not required as the IO provide enough resistance on their own. At 3V the typical output resistance is about 30Ω each, so the current through the LEDs is limited effectively by a 60Ω resistor.
For the button I used a TTP223 capacitive touch sensor IC. This dedicated part consumes way less power than the microcontroller running code for the same function, so the touch button can be used as the power on/off switch. It also reduces the programming efforts required, which I'm honestly quite thankful for.
Step 4: Design: Look & Feel
As I’ve mentioned before I like the original and wanted to preserve its overall look. A big part of that are the snow covered branches which is in my opinion a clever and elegant design, especially since it is included for free anyway. The shape of the branches was slightly modified has now a slight natural curvature.
Unlike the original however I wanted to reduce the visible electronics to make place for some decorations. The Christmas ornaments are just round patches of exposed metal which can be either silver or gold depending on your surface finish. The traces connecting the LEDs to the microcontroller are carefully routed and mostly in the center region where the tree trunk would be. This way they blend in nicely.
To make the lights visible from more angles I decided to embed them into the PCB: There are cutouts in the PCB with contact two solder pads on the top and two on the bottom side. The LEDs I’ve chosen measure 1.6mm across and the PCB 1.2mm so when soldered in a right angle there are 0.2mm on either side left. The final result not only works, but looks absolutely gorgeous! The downside is that it’s quite trick to get right and certainly a lot of manual soldering work.
Step 5: Design: Firmware (+Video)
With the simple electronic design most of the functionality relies on the microcontroller and the code it’s running. This step provide a rough overview about what’s going on, more details can be found in the source code and the comments within.
How to use:
With only one button the controls are obviously limited, so I used long button press as a separate input:
|touch||cycle through animations / chance color|
|hold||turn on / off|
|turn on + hold||enter color change mode|
|turn off + hold||save settings to EEPROM|
In the color change mode the LED next to the button will blink with the selected color. Turn the light of to exit color change mode. Saving settings preserves them even when the power is removed, which is especially useful if powered from USB.
It was surprisingly hard to write the code for the animations. Sure, blinking some LEDs is easy, but archiving the balance between "boring" and "annoying" is not. That’s why I ended up with only six animations:
- base color
- base color + 1 contrast
- base color + 2 contrast
- full random
The first three animations dynamically use neighboring hues besides the base color. This effect is subtle and IMHO best suited for a Christmas decoration.
Although he colors are vivid in person, they don’t show up well on camera. The relatively bright LEDs over saturate the sensor which in turn only picks up white light instead of the color. If I bring up the ambient light until the colors are right, they appear a lot dimmer than they are. In the title image I used exposure blending to get the best of both worlds, but for video it’s not possible. Instead I opted for out-of-focus video which preserves the light color but sacrifices the sharpness.
Most of the heavy lifting is done by the charliplexing code I wrote for the tiny LED cube I build years ago. With fewer LEDs to control, the refresh rate could be increased to 1000Hz and thus the brightness increases as well. To get even more light only the hue of the color is changed, never its brightness. The hues are taken from the HSL color model and are 8 degrees apart. The conversion to RGB values was done with an online converter, the gamma correction in matlab. The final values are then stored in a LUT (look up table) within flash memory.
The code has a bunch of small and larger optimizations to reduce power consumption and flash usage. Notable optimizations are:
- Sleep modes are used wherever possible: When the LEDs are turned of, it goes into power down mode reducing the total current consumption to about 3uA. Between frames the idle mode is used to decrease active power consumption.
- The button uses an interrupt to wake the device from power down sleep mode and has debounce in software to account for its high sensitivity and false detection.
avr/fuse.hthe fuse settings can be embedded into the code and allow true 1-button programming, which greatly speeds up production.
- The mode of operation is primarily controlled by some flags, which are single bits in memory. Accessing these usually requires three instructions for read-modify-write. However the attiny44a has 3 GPIO registers where single bits can be modified. With GCC these registers can be bound to a variable thus allow GCC code optimizations resulting in faster code and less flash usage. It also allows the usage of "naked" ISRs which further improves performance.
Step 6: Design: Card
It was important to me that the card wasn’t just the packaging, but an actual passable Christmas card. It shows that I’m not a graphic designer, but I wanted to have at least a folding card similar to a store-bought card with some space to write some greetings.
The final design has two folds. The first opens like a normal card with all the greetings at their usual place. On the left side are the short building and usage instructions. Turns out writing things short yet complete is surprisingly tricky. The first draft had about four times as much text and it took me a few hours to boil it down to the essential parts. Below the PCBs are illustrations so the instructions are clear even when the boards are taken out.
The electronics hide behind the second fold and are protected by a layer of cardboard. This cardboard also accommodates the thicker components, provides a uniform thickness and some vertical stiffness, all of which is great for shipping.
Step 7: Tools
All required tools are listed below, in brackets are further details about my specific tools.
- soldering iron with a fine tip (TS80 with the 0.4mm tip TS-B02)
- hot air soldering station (optional, I use the AYOUE 852A+)
- soldering iron cleaner (dry brass/copper)
- solder wire, 0.5mm (for normal soldering. Sn60Pb38Cu2 from a name brand)
- solder paste (for hot air. fresh paste recommended, but one year old XG-50 "mechanic" brand paste worked ok. Store in fridge after use.)
- flux liquid (for normal soldering. Easiest to use is the flux in a pen)
- flux gel, Amtech NC-559-V2-TF (for hot air. I’ve tried many cheap alternatives and fakes, but only the original is good. You can get it from Louis. Store in fridge after use.)
- desoldering wick, about 1mm wide (optional)
- silicone mat, heat resistant
- tweezers with fine tips
- kapton tape
- solder paste squeegee (or old credit card)
- isopropyl alcohol (to remove flux residue)
- antistatic brush
- wipes (paper wipes are ok, but lint free are better)
- microscope, stereo (optional, I use the Amscope SM-4NTP)
- small vice
- small file, various
- dremel (optional, to speed things up)
- multimeter (to find shorts etc)
- micro USB cable
- ISP programmer, I use the AVR dragon
- ISP pogo pin adapter 1.27mm pitch; either DIY or get a similar adapter on tindie
- printer (check the maximum suported paper thickness)
- paper cutter (alternative: utility knife + ruler)
- folding board (alternative: backside of a dull knife)
- hole puncher (⌀12mm & ⌀26mm, optional) + hammer
- pens (ink, gold or whatever else you like)
Step 8: Materials
- PCB assembly
- 1x set of PCBs, gerber files are attached below. Select 1.2mm thickness, green solder mask & optional ENIG finish.
- 1x set of components, see BOM attached
- 1x CR2032 coin cell (optional)
- 1x DIN A4 card stock, 200g/m² weight. The required final dimension is 297mm x 165mm.
- 3x glue dot, removable (name brand recommended, dots from aliexpress are not well removable)
- 1x envelope size B6
- cardboard from a shipping box
- double sided tape or other glue
- optinally additional packaging for shipping
Step 9: PCBs: Solder Parts
Apply paste and place all parts except the LEDs. Be careful to not add to much paste to the spring footprints as it can block their movement range. I don’t have a soldering oven (yet), so I used my hot air rework station to reflow all parts.
If you don’t have a hot air rework station you can assemble all parts with a normal soldering iron as well. Pay attention to the horizontally mounted spring contacts as solder can block their movement range. The battery holder can obstruct access to other parts, so it’s best to solder it last.
Step 10: PCBs: Separate From Panel
As mentioned before I’ve designed a 10x10cm panel version to reduce costs, but ended up making a larger panel. The smaller panel uses mouse bites which can be cut with side cutters. I recommend to use the cheapest pair with a flush cut you can find as the FR4 material will cause some damage to them. You should end up with a total of 4 different PCBs.
Step 11: PCBs: Refine Shape
In this project the PCB is an integral part to the mechanical design and therefore require tighter tolerances than guaranteed by the manufacture. Some PCBs in my order were ok others required a little rework to make the slot in the middle fit.
As a last step I removed all remains of the panel support structures and smoothed out the edges. This can be done with a file, but you may want to use a dremel to speed up the process.
Step 12: PCBs: Prepare LEDs
To guarantee that no copper gets damaged, the manufactures remove anything that gets too close to the edge of the board. This is ok for most projects, but the gap makes soldering the LEDs almost impossible. It is much, much easier if you remove the excess board material with a file.
Step 13: PCBs: Solder LEDs
With the unusual in-board placement the LEDs can not be reflow soldered with any standard process but must be soldered in place by hand. For one or a few trees this is totally ok and doable, if you want to have more I wish you a steady hand and a lot of patience.
After a lot of experimentation these are steps for best results:
- Generously tin pads on one side of the PCB.
- Mount the PCB vertically in the vice.
- Grab an LED with tweezers and hold it with the pads facing up so that gravity helps to push solder in the right direction.
- Reheat the solder and attach the LED. The polarity and positioning of the LED is more important than the quality of the solder joint.
- Insert the tweezers into the hole and let it loose so it pushes the LED closer to the solder joint.
- Reheat the solder once again. The LED should now sit flush against the PCB.
- Solder the other side. This should be quick and easy because everything is aligned properly.
- Reheat the fist side once again to clean up the solder joints.
- Inspect for shorts and remove any that you find.
Take a look at the image gallery for details.
nopnopnop came up with an alternative soldering method and documented it in a comment below. Please try it as well and use whatever is easiest for you!
Step 14: PCBs: Assemble Adapter
One layer of PCB material is to thin to make good contact with the battery holder. Therefor a second round part is included which has to be soldered to the negative side of the larger piece (see pictures). The height offset also gives space to the components under the adapter and for most micro USB connectors.
You can’t access the solder joint with a soldering iron, so hot air is necessary for this step. However you do not need solder paste, you can just make a solder dot on one side and apply some additional flux. You only need very little solder, if you have to much it’ll wick through the tiny vias connecting both sides. In my first prototype the contact between adapter and the PCB contact under the holder was unreliable, so I added a tiny solder dot in the center of the negative side of the adapter. It looks best if you reflow a tiny amount of regular colder to the center with some additional flux.
Step 15: PCBs: Program & Test
In most cases the microcontroller on this PCB will only be programmed once, so I didn’t include a physical debugging/ programming connector. Instead there is 6-pin ISP footprint with a 1.27mm spacing between the pads. For programming, the tree must not be yet assembled.
Press and hold the adapter into the footprint and ensure that all pins sit in their correct position. Pin 1 is marked with the square on the silkscreen. It is best to power the tree through the ISP connection during programming. For this, the battery must not be installed yet. Otherwise the reverse current may heat up the battery and can cause it to leak or explode.
Anyway, once you’ve made the connection hit upload and verify in your programming tool of choice. Once it is completed, it will automatically launch the test code. This causes all LEDs to blink in order and you’ll notice any mistake or broken LED directly. If a single LED is off that usually means it is broken or has a bad solder joint, if random LEDs are on you likely have a short somewhere. To exit test mode remove the power supply. If you want to reenter the test mode short the "RST" and "GND" pin of the ISP connector.
If the yellow hues have a red or green tint you can adjust the calibration values in the
color_rg.h file to match your particular LEDs. See comments in the source code for more info.
Step 16: Card: Customize (optional)
Changing the card is a great way to give it your very personal touch. you can find the template as word file attached below. For example you might want to…
- Change the cover picture to something personal
- Translate the instructions to your native language
- Add a computer typed text to the greeting section
Step 17: Card: Print
For a nice card it is important to use high quality card stock. A typical greeting card is printed on 240g/m², but the 200g/m² I’ve used feels almost identical. Before purchasing thick paper, make sure your printer can handle it. For printing I had to select "thicker paper" and "manual feed".
The positions of the folding lines are fixed and the design of the card takes these into account. Unfortunately your printer probably doesn’t and shifts the design by up to 1cm around. All printers are a bit different so you’ll have to modify the margins in the word document by yourself.
Step 18: Card: Cut
The card uses the full length of the A4 Paper (29.3cm) but only 16.5mm in height to fit a standard B5 envelope. Cut of the remaining paper either with a proper paper cutter or an utility knife.
Step 19: Card: Score
Heavy paper and card stock requires scoring to get a smooth and professional fold. To score paper drag a folding bone (or the backside of a dull knife) across the paper where you want to fold. This creates A valley on one side and a bump on the other.
For this card you need to score a total of five times at 3¾", 4", 7¾", 8" and from the other side ⅛". Look at the picture for reference. Do not fold the card yet.
Step 20: Card: Write Greetings
If you want to use a pen that requires some force (i.e. roller ball type), then its properly best to write your greetings at this step. If you have an ink-based pen you can write later and reduce the risk of smearing.
Step 21: Card: Fold
Counter intuitively the bump should be in the inside of the card and valley on the outside. If you’ve never tried this before I’d suggest to practice scoring & folding a bit with blank card stock first. For this card it is best to make 90° folds which will create a little bit of space inside the card.
Step 22: Card: Cut Cardboard
Inside the inner fold are the PCBs as shown by the print on the card itself. Most components are very flat except the battery holder and micro USB port. To make up for the difference I used a piece of recycled cardboard.
It should measure about 16x9cm so it covers the whole card without sticking out. The internal "waves" should run from top to bottom to provide vertical stiffness and protect the card from bending during shipping. The aforementioned battery holder and micro USB port need some cut outs; they can be made with an utility knife or hole punchers (if you have them).
Step 23: Card: Glue Cardboard
Before gluing the cardboard in place, do a quick test fit to ensure everything is ok. Then cover the long sides with thin double sided sticky tape and leave about 2mm of overhang on the left side as shown on the picture. This little overhang attaches the tiny flap on the card to side of the cardboard to hide all the roughness.
Step 24: Card: Attach PCBs
The glue dots I’m using are similar to the glue that hold credit membership card to the letter they are shipped in. Even though they can be peeled of easily, they are quite strong and can hold a PCB each.
Stick a total of 3 glue dots to the card, on in the center of each PCB print. Press them down firmly with the carrier tape they came on. This ensures the glue sticks to the card and does not come loose with the PCBs. Now attach the PCBs and close the card.
Step 25: Card: Packaging
Put card into envelope and seal. If you want (and your postal service allows it) you may decorate the envelope.
Originally I planned on sending the card in the envelope only. Even though the card fits the size and weight limits of a normal sized letter (amazing, isn’t it?) it can not be bent and thus not handled by machines. I wanted to test the theory so I send a card to myself well in advance. Turns out the card does arrive, but got some marks from the sorting machine. I assume it went through unchecked and then got stuck inside the machine requiring manual assistance.
Technically it is not my problem that the post can’t sort their post correctly. I mean it even has a matrix code so it shouldn’t be too hard to automate. However I did not want to take the risk and shipped out cards in an additional and noticeably larger bubble wrap envelope (but for the same shipping cost).
Step 26: You Are Done!
If everything went right you now have one or a few mini PCB Christmas trees just as pretty as mine. Congratulations!
Now, that everything is done I’m super happy how it turned out. However the process was challenging to say the least. Part of reason was the high build quantity (and quality) I committed to, but also the short time frame, broad range of tasks to do and things to learn. Honestly I’ve thought about scrapping everything more than once, but I’m glad I didn’t.
Participated in the
Make it Glow Contest