Category Archives: fabrication

Hackable ornament: my circuit and code remix


Glowing demo with ShiftPWM and ATMega328P

After first coming across the Dangerous Prototypes Christmas ornament design in the summer, I’ve been thinking about how I might build on the design to make the light show a bit more exciting. One aspect that stuck out for me was how all 10 LEDs flash on and off at once. I decided my goal should be to have individual control over as many LEDs in the Christmas tree as possible.


Two shift registers connected to an Arduino

My first experiment solving the problem envisioned one or two 74HC595N Serial In Parallel Out shift registers. A nice glowing PWM effect is achieved through PWM via a CTC interrupt function. While I was able to wire this up with my Arduino’s Mega328, the Mega-only ShiftPWM library is too bloated for the tiny13’s 1K. Although the tiny13 Arduino core does have untested ShiftOut() functionality, the shift register idea is out, as the necessary program at my skill level puts it outside of time constraints. Although unsuitable for now, but shift registers have been added to my list of fun future projects.

Another option I considered was charlieplexing, or using the tri-state properties of MCU i/o pins to control 3 LEDs per pin, set up in an array. However, this would also mean current flowing through i/o pins. Scratch this idea,  but add it to the experiment list, as it might come in useful later.


How to groups the lights up with transistors

Ultimately, I decided to keep it simple and divide the 10 LEDs into groups of two, expanding from a single transistor switching 10 LEDs to 5 BJTs switching groups of 2 LEDs each. The same interrupt-based PWM technique as mentioned above is used on all 5 tiny13 pins. PB5/Reset is kept free for ISP access. Why not drive the LEDs directly from the tiny13 i/o pins? After all, the combined max current from the LEDs is 40mA, and the max current on a tiny13 pin is also 40mA. Good question.

When approaching hackability from a design perspective, maximizing the useful life of a device is a key focus. Future needs change, and if your design lends itself to being adapted along with that change, it will continue to serve a useful purpose for a long time. Building in tolerance and redundancy above the bare minimum requirements increases resiliency to the unforeseen.

Let’s ignore for a minute the fact that a simple code change to open up all 5 pins puts the tiny IC dangerously close to its 200mA limit of VCC to GND. While the two parallel LEDs on each pin might be enough for our current purposes, what if the LEDs are replaced with a heavier load? The i/o pins would probably be okay with the 2 LEDs at the duty cycle as programmed, but the pins would surely fry driving a motor. On the other hand, the NPNs can handle 600mA of continuous collector current, and might one day the board could be repurposed to power a little robot to amble along for our amusement. Plus, they’re insanely inexpensive. BJTs FTW!


Original schematic with my grouped LED remix

Another concern is the ISP port, which shares the serial lines with two groups of LEDs. The 40mA demand of the LEDs could potentially disrupt the flash programming sequence or damage the programmer. Isolating the load from the serial lines keeps things safe for reprogramming the tiny13.

match footprints with printout

Pro tip: printouts can be used to match footprints

Minor design changes included moving most of the cluttered components to the back of the board, arranged in a fashion to allow for a small area for a handwritten message at the top of the board. When designing PCBs, using a block of silkscreen can be handy for writing notes on boards. The switch and battery clip were swapped for components I had available. The switch fit an existing part in Eagle (Omron 1000), which made light work of swapping out the original design’s SMD switch in favour of the through-hole I had on hand.


Creating devices from scratch in Eagle is a 3-step process

The battery clip had no datasheet and no part that came close. Out came the caliper and a notebook, then the SMD pad size and spacing were created in Eagle’s package editor. The placement silkscreen with chamfer to indicate polarity was also created. A tip: when replacing components in Eagle’s schematic view, make sure the polarity of the new part matches your diagram. While it wouldn’t have broken the circuit, the silkscreen indicator for positive would have been reversed, creating future confusion.

The final result is a slightly larger (5 * 8 cm) remixed work, with most of the unsightly components moved to the backside. The battery clip and switch are slightly different. The code has been replaced with the interrupt software PWM implemented by funkfinger based on Atmel Application notes. The sleep function from Ian’s code rounds things off to replicate the battery saving functionality. Here is the code from the original Dangerous Prototypes ornament (hopefully those links work for you. If not, please let me know):

Here’s my frankencode:

The effect of my circuit and code remix is 5 groups of two LEDs glowing on and off, all at different rates. This produces a pleasing twinkling effect, and is sure to light up the season. As of my writing this, my DirtyPCBs order has been batched and sent to the board house. With any luck, I’ll have an update before Christmas.

Original design, bottom layer

Original design, bottom layer

Circuit remix bottom later

Circuit remix bottom later


Leave a comment

Filed under Battery power, C++, code, DIY, fabrication, Hacking, ICs, Lights, PCB design

At the dirty board house in Shenzhen

Through the marvels of globalization and modern technology, my solar charger design, dubbed the Solar Stage, has been sent off to a board house in China for low cost production. Thanks to DirtyPCBs, and its sassy yet functional website, I placed my order for 9 to 12 boards of my 10 * 10 cm 2-layer design for only $25 (including Hong Kong Post — no tracking). Yes, that’s no typo. $25. Oh, and a pick from 6 colours (I chose red). 5 * 5 cm is a jaw-dropping $14.

Front of the image generated by the DirtyPCBs website. After countless revisions, the board is ready. A Dangerous Prototypes Bus Pirate and a self-designed SD/flash combo board occupy the space unused by the Solar Stage.

According to the DirtyPCBs website, my Gerber files are transmitted through their automated system to a board house in the high tech heart of China, where it’s batched up with other boards and given the full treatment. The boards are then forwarded on to the DirtyPCBs agent, to be sent on to me. The whole process takes 6 to 8 days, not including the postage time (1 to 8 weeks for Hong Kong Post, dependent on your country). Amazing!

Back of my board order.

One feature I really appreciated is DirtyPCBs unlimited file revisions. Up until the point the board design is sent to the board house, the site accepts a re-upload of your design files. In the 31 hours before it was batched, I submitted five (5) updates. In my post-submission high, I noticed little bits I could improve and went over everything with a fine-tooth comb. Nothing like the thrill of working against the clock! Granted, it might be a bust, but at least I have some useful boards out of the experience.

To be honest, I enjoyed the cheeky language that peppers the website. Apparently the website was originally made as a joke poking fun at people complaining about the quality of a new process. Or a very clever dirty marketing. Either way, the results are impressive for the cost, so I decided to give them a shot. Tonight I received a notification saying my board has been batched up. Stay tuned for an update when my dirty boards arrive.

Leave a comment

Filed under Battery power, DIY, fabrication, ICs, micro-controllers, PCB design, Solar Stage, Teensy

Progress on solar MPPT board

My first stab at PCB routing, using the design rules from

Perhaps overly complicated, but the challenge of routing a bunch of pins so close together was pretty fun. I will post a final schematic later, but here is what I have so far. Don’t mind the cramped nature of the drawing, for I am contending with EAGLE’s freeware limitations & paneling to cram other useful stuff onto the remaining 10*10cm allows.

Top layer

Bottom layer

Leave a comment

Filed under Battery power, DIY, fabrication, ICs, PCB design, regulators, Solar Stage, Soldering, Teensy

Z-axis built


Confronting the design challenges in constructing the Z-axis was daunting at first. Given the vertical aspect of the stage, the force of gravity cannot be relied upon to keep the stage from coming off the rails. To address this challenge, additional bearings were installed on each side to secure the stage and prevent it from falling off when it moves up and down.

IMG_20140621_211117686_HDRIMG_20140621_211220063_HDRAvoiding any new part designs was an important factor. Existing designs were adapted and improved. The end result is a strong and sturdy linear motion that should be able to support a rotary tool.IMG_20140621_211153434_HDR

Leave a comment

Filed under CNC, fabrication