Saturday, August 20, 2011

Welcome Andrew James

Just wanted to take a moment to welcome my new son, Andrew James into the world - or at least the world of my blog. Andrew was born just over a week ago on Friday August 12th, 2011, at 6:59 pm. He weighed in at 7lbs 5oz and was 21 inches long. Overall he's very healthy and doing well in every aspect.

The past week has been a busy one, bouncing back and forth between the hospital for my wife & newborn son, and back home to spend time with Nathan and sleep in my own bed. We came home from the hospital on Sunday and introduced Nathan to his new little brother. Thanks in part to our work preparing Nathan for a new baby, he took to Andrew very well. Nathan loves to say hi to Andrew, urges his mother to "feed the baby" more often than necessary, and has been known to get upset if he can't see Andrew well enough from time to time.

Thus far Andrew has been a great baby. He rarely cries, only if he gets really hungry or needs a change, and he's been sleeping well at night between feedings. We thought we lucked out with Nathan being a good baby, and I think we lucked out even more with Andrew. I'm sure some of the ease is due to the fact that we've done this all before, and we're pretty easy-going parents. Either way, in the short week he's been with us, I think we've all adjusted to being a family of four fairly well.

I took two weeks vacation from work, and the first week has flown by already. One more week to go and we'll step back into real life. Although judging by our first week together, I think we'll be alright.

Now I'm looking forward to raising my two boys to be happy healthy and well-adjusted young men. Not sure yet how exactly I might accomplish that but I'll do my best, and if nothing else try to set a good example.

Friday, April 29, 2011

Fabrication brings TinyChuck5 to life

After some time spent re-acquainting myself with circuit board manufacturing and laser cutting, my "TinyChuck5" project is complete, looking more like a finished product than a breadboarded mess of wires. Here it is, happily blinking away:



At the time of my last post, I had finished my circuit board design and had some boards on order. The circuit boards were manufactured overseas through the Seeedstudio Fusion PCB service, great for small prototyping runs of small boards. Thankfully my design just barely fit within the 5cm x 5cm maximum size. To get 10 boards for only $20 is a steal, much cheaper than just one board through most other services. They also have a 10cm x 10cm option for $40. Despite the low price, the boards turned out quite well, the only drawback being the long lead time. They also added some identification/serial numbers to the silkscreen on each board to keep track of the order, but that's hardly anything to be concerned over. I also ended up with some additional boards, 12 in all, with 8 of them tested (they promise at least 50% testing, 100% costs extra). All in all a perfect service for the hobbyist engineer.

With boards in hand, I headed for the workbench to assemble my first prototype. After much soldering and clipping of leads, it was time for the ultimate test... would it work? Was my circuit board designed correctly? With the programmed chip pressed into its socket I hooked up power through a couple alligator clips and viola! It worked! Blinking lights! Not terribly exciting I know, but it was personal validation for the work and attention to detail I had put into my little trinket.

Next step was to give this little piece of electronics a proper enclosure. I wanted to have it set up on my desk and look nice & clean. While the exposed electronics look was interesting in its own right, I wanted to take it up a notch.

Years ago, I was fortunate enough to have access to a laser cutter/engraver in my high school's metal shop, and I was appointed to be the resident expert and operator of the machine. I learned a lot that year and had fun cutting and engraving all sorts of parts and materials. Having access to that kind of creativity-driven hardware was a lot of fun. So when it came time to make an enclosure for this project, I wanted to laser cut something. Thanks to their partnership with SparkFun Electronics, I found out about a company called Ponoko, an internet-based "digital manufacturing" service that creates parts from digital files. 2-dimensional designs can be cut from a variety of materials, and 3D designs can be turned into physical parts using 3D printing technologies. They make it easy and affordable. In college I also got to use the rapid prototyping machine to "print" 3D objects, but that's a different story. Needless to say I love the whole digital fabrication concept, and the creative freedom it enables.

For laser cut parts, I simply had to upload my design as an SVG file, and choose the material I wanted. I opted to do my design work in AutoCAD where I feel most comfortable, having made mechanical drawings in the software for four years at college. I saved my design to an AutoCAD R13 DXF format, imported it into Inkscape, placed it within Ponoko's design template, and sent the design off to Ponoko to be cut from 3mm thick white acrylic plastic. Some time later the parts arrived at my door, and it was back to the workbench.



One thing I noticed after assembling my first unit was that my LEDs didn't all line up perfectly in their 4 x 5 grid. The holes in the PCB were bigger than the LED leads, so each LED had some wiggle room. This resulted in a few LEDs that looked "off" from the rest of their respective rows. I had some space available on my Ponoko design, so I had them cut me a template for placing my LEDs. I cut holes for each LED just big enough to fit the lens, and included mounting holes that lined up with the circuit board. This let me place all 20 LEDs in a near-perfect grid and hold them solid while I soldered each one. The results look much better than my first attempt, with perfectly aligned rows & columns of lights.

With soldering complete, I began assembling the new enclosure:



Here's a view of the back of the unit. The back piece included cutouts for my power cord (a USB cable), and for a small T-shaped button I made for pressing the reset button inside on the circuit board.



And here again is the finished product. These days it sits on my desk at work, quietly blinking away, occasionally drawing me into a hypnotic zen-state, and serving as inspiration for my next more ambitious project.

Sunday, February 6, 2011

Diving into Microcontrollers - My Tiny Charlieplexed Display

Welcome! Thank you HackADay for publishing my project, and thanks for coming and reading :-)

For those of you who are used to reading about my usual exploits in cooking, fixing things, and family, be forewarned this post gets a bit long, technical, and geeky! :-)

I've been interested in electronics since I was a kid, and have always enjoyed experimenting, building, and learning something new along the way. With the growing popularity of microcontrollers in the hobbyist community, it's become easier to get started in what used to seem too complicated to approach in my spare time.

Since microcontrollers are essentially tiny computers in a chip, you can do much more than you would be able to do with a handful of passive electrical components, and making changes to your device usually only requires making changes to the software that runs on the chip. While I can write software on the computer to work with data, there's something more satisfying about being able to write software to control objects in the physical world like sensors, motors, lights, etc.

I've actually been picking away at this project for several months, in the limited time I have available to me as a parent of a 1-year-old. I'm intrigued by how much can be accomplished by some of the tiny chips available. I decided to start learning with something small, the ATTiny85, with a mere 8 pins to work with. I was also intrigued by what I had read about Charlieplexing LEDs. Basically controlling many LEDs with only a few pins. For simplicity, I wanted to avoid any extra hardware/chips for my first project. To see how much I could do with only a few pins, I decided to take the 5 output pins available to me and make a charlieplexed LED display. Technically I could have used 6 pins, but that would mean losing my ability to reprogram the chip easily. By wiring up my LEDs just right, I could control up to 20 LEDs with only 5 pins.

So I have a tiny chip driving 20 LED lights, but I have no source of input since I used up all my pins. I might as well try doing something interesting... random blinking isn't very intellectually stimulating. I decided I would make a small 4 by 5 grid which could run Conways Game of Life, a simple simulation of cellular life invented by a mathematician in 1970, and a simple programming exercise for me to learn to program my microcontroller in C. By turning on a set of random LEDs, you can let the "colony" evolve based on a set of rules, and see how long it lasts. Sometimes the colonies die off quickly, sometimes the right configuration will get into a loop and survive forever. It's a bit abstract, but interesting to watch.

Setting up the wiring was a bit tricky. I wanted 20 LEDs in a 4x5 grid, all aligned the same direction on the board, and had to run 5 wires to the 40 different connection points. I ended up running bus-lines for each wire on the top and bottom of the board. One side of the board would run to the positive side of each LED, and the other side to the negative leads. After some sketching I ended up with my basic concept for wiring the array and it ended up conceptually simpler than I had expected.

Next step was prototyping. I did some simple experiments with 2 or 3 pins and a breadboard to prove out the charlieplexing concept. Only one LED can be lit at a time. To do this, you have to set one side of the LED high on an output, set the other side to ground on an output, and set all other pins on the array to an input mode. Setting the others to inputs prevents current from flowing and thus keeps all the other LEDs dark. This was perhaps one of the more complicated prototypes I've built, since it involved so many jumper wires on the topside of the board, and such complex wiring in a tight space. I could handle it for 20 LEDs, but probably wouldn't have the patience for much more.

Programming was a new challenge in itself. I've written software in a variety of languages and knew enough to start playing around with some low-level C language with the help of other people's sample code. Getting the programming on the chip required some extra hardware. Awhile back I picked up the USBTinyISP AVR Programmer from Adafruit. The kit was easy to build and in the end I had a top-notch programmer for getting software into my chips. I downloaded the WinAVR development environment and got familiar with it, and after much reviewing of datasheets and other people's software posted online, I started to get simple programs running on my ATTiny85. One big drawback was in-system programming. The AVR chips allow you to program the chip while it's plugged into the rest of your circuit. However, due to the wiring of my board, where basically every output pin is connected to every other with little in between... this interfered with the programming data. I could only get programming to work if I pulled the chip and put it in my dedicated programmer. Not a major issue, but a bit of a nuisance. This also meant I wouldn't be able to include a programming header on my final board design.

I actually started developing my Game of Life software while on vacation in northern Minnesota. I had the WinAVR software working on my laptop, had my prototype hardware built and working, and with this vacation I had plenty of pockets of free time where I wasn't responsible for doing anything in particular. I developed some routines for lighting specific LEDs, storing the current grid, calculating the next generation, and did a little "software PWM" to make it look like the LEDs were fading in and out. I'm sure there are dozens of ways my code could be improved/optimized, but as a first project I'm pretty proud of what came out of it.

As I am always learning, and willing to learn from others, I've posted my code & schematic as an open-source project on GitHub:
https://github.com/benbrandt22/TinyLife5
I just installed Git and just signed up for GitHub, so hopefully I did it right! But my files are there, so that's a good sign.

Detecting when to reset the simulation was an interesting programming exercise as well. The simple ways didn't take much effort. If the next generation has all lights out (dead), then reset. If the next generation matches the current one (steady state) then reset. Detecting a loop was a bit more complex. I didn't want my device to get into a loop and stay there until the power was reset. I didn't have the memory to store an endless record of previous grids to compare to. So, at a certain interval, I saved the grid, and subsequent generations would be compared to that past one. Once the software detected that it's next grid matched one we had seen before, it would know a loop had occurred, and would reset. But how often should I record the grid? How many generations back should I look? I wanted to know how long of a loop I could expect. Since I was only dealing with 20 LEDs, my grid could only display 1,048,575 (2^20) possible combinations of lights, relatively small for a computer to deal with. I wrote some software in VB.NET to run through every possible combination and see how each would play out in the Game of Life simulation. What I found was that about 8.13% of the possible combinations would loop in one way or another, and the longest loop I could expect was 18 generations. Based on this, I knew that if I looked at every 20th generation, I should be guaranteed to catch every possible loop eventually. If my grid were larger I'm sure it would get much harder to analyze every possible configuration, but this worked well for my small setup.

Here's how it looks running on the breadboard:



Now I could have stopped here, but there was more to learn, and after all, I like to make things. I wanted to turn this into a little trinket I could have running on my desk that looked nice & clean. It was time to tighten up the design and put it on a circuit board. Moving my project off the breadboard into a finished product is the perfect way to wrap it up. I haven't done any circuit board designing in about 7 or 8 years since I created my VU-Meter Kit back in 2003. I designed that in ExpressPCB, a proprietary software package, so this was the perfect excuse to teach myself Eagle CAD, with some help from the excellent tutorials at Sparkfun. Once I got rolling, Eagle turned out to be a nice piece of software, and was easy enough to use. Bringing my schematic to a board design was a smooth intuitive process. I arranged my LEDs into a tighter grid, and added some extra circuitry to regulate a 9v power supply to an even 5 volts, and added a reset button. The whole thing fit into a board just 1.95 inches square. Since my board was a charlieplexed LED display running off 5 pins of an ATTiny, I named the board design "TinyChuck5". In the future I can modify my software to do other things besides the Game of Life simulation.

Before committing my design to a board, I ran through some checks to make sure it would work, besides double-checking my traces in Eagle. I printed out my design on paper and taped to a piece of styrofoam, and proceeded to insert the components. This allowed me to make sure everything would physically fit, and that everything lined up properly. I then generated my gerber files for having the board manufactured. As a last check, I viewed the gerber files with ViewPlot, and discovered that my voltage regulator included a drill-hole that I wasn't aware of, which put a hole right through one of my traces. I didn't see this in Eagle, so was thankful I could catch it by reviewing the gerber files. I moved my trace to avoid this hole and the design was finished!

At the time of this writing I have a few boards on order. Once they arrive I can solder some together and make it look nice. I'd like to put my LEDs behind some semi-transparent white plastic. In the end I may have a useless blinking gadget, but at least I can say I created it from scratch, and I have the ability to make it do whatever I want. With the knowledge I've gained in this experience, I can move on to another more elaborate, more interesting project.

Monday, January 17, 2011

Inside Dad's Toy Workshop - Toy Repair and Creation

While my basement workbench has served many purposes from wine making to laptop repair, I periodically find myself at work in the basement on one of our son's toys.

Tonight I set out to repair a music-playing toy shaped like a star. Each point of the star is supposed to play sound or music, but one hasn't worked since we got it. Even though he's only one, he knows that button should work. So, as The Dad, I need to fix it! Not sure if it came from a garage sale or the thrift store. The offending item was a squeezable cloth item, so it could be tricky getting at the switch inside the plush part.

Fortunately this one wasn't too difficult to diagnose. After removing a few screws, I was able to test the working switches with my multimeter. This gave me a basis for comparison to the broken switch. While prodding around the problem showed itself... a broken wire. Oddly enough this seems to be a trend. I fixed a musical toy book some months ago which also had a broken wire. This one I was able to strip and solder back together. In a pinch the strands of CAT5 ethernet cable works well as a small gage wire. Thankfully my wife knows me well, and has brought home other non-working toys from garage sales, knowing that I'll enjoy working on them, and hopefully getting them to work. Lucky for me the last one was only dead due to some battery acid corrosion on one of the battery contacts. A little sanding & scraping and we have a nice electronic drum and Nathan loves it.

Speaking of things Nathan loves... he loves turning light switches on and off, and loudly exclaiming "ON!" when the lights come on. I headed to the hardware store a couple weeks ago with the goal of giving him a way to play with light switches where we don't always have to lift him up. What I ended up finding was a WireMold light switch and enclosure made for mounting to brick walls. It's a small enclosure that holds the light switch and has just enough room inside for a little more. I had considered a normal electrical junction box, but the switch plate sticks out far and this presents a number of sharp edges. Not so kid-friendly. I drilled out a hole in the switch plate for a light. The light was purchased from Radio Shack as a 12 volt automotive indicator light, but I only bought it for the nice plastic lens which snaps easily into a 1/2" hole. I tore out the bulb and wired in a blue LED, a resistor for limiting current, and hooked it up to 2 AAA batteries in a battery enclosure I had in my bin of electronics supplies. Normally I wouldn't call so much attention to something as simple as wiring up an LED to a switch, but the application as a kids toy made it more fun.

With the enclosure snapped together, the electronics soldered up, and the switchplate screwed on tight, it was done! Nathan loves his personal light switch. I have some ideas for a better design if I could custom-manufacture the toy, but for now it works well and he enjoys it, so that's what matters.


Sunday, November 28, 2010

Happy Thanksgiving

Happy Thanksgiving! I'm thankful that I'm still here to celebrate it with my wife & son and everyone else in my life. It's been a good long weekend and we managed to fit in quite a bit. We enjoyed our Thanksgiving meal with Beth's family this year. The food was excellent. Nathan wasn't so sure about some of the food but had a good time, especially playing with his cousins. I ventured out Friday morning for some Black Friday deals like I do most years. It's crazy but I get a kick out of the experience. Friday afternoon I put up our Christmas lights after finally finding the right hardware to hang them up. Most normal hooks won't work with our new leaf-guarded gutters. Saturday morning we made Lefse with Beth's parents like we do each year. However, we decided to do it at our house this time which worked out well for Nathan and his nap schedule. The Lefse turned out great and will be enjoyed through the holidays and the rest of year whenever we decide to pull some out of the freezer. Saturday night we got together with my parents and my sister and her family for some Thanksgiving leftovers and good family time. We wrapped up the weekend with my niece's 5th birthday party on Sunday night. Overall a busy but good weekend. Happy Thanksgiving!

Monday, November 22, 2010

Wine Label Honorable Mention

I'm happy to report my Apple Wine label got an honorable mention in Winemaker Magazine's label design contest. The latest issue of the magazine arrived at the house with the results of this years label contest. The competition was good, and the winners had some fun label designs. They awarded some big prize packages to first, second, and third place. Mine was one of 16 other honorable mention labels. According to the magazine I won a Carboy Cleaner, so I may be receiving a package in the near future. Thank you Winemaker Magazine!

Friday, November 19, 2010

Wheel Cake!

Growing up in a family of artists has instilled a creative drive in me that cannot be ignored. I enjoy opportunities to be creative and make things, and baking is no exception. Growing up it was always fun to have my mom's creative cakes at our birthday parties, and now that I'm a parent I want to do the same for our children. Besides, it gives me a chance to be creative and have more fun than I would have going to buy a cake at the store.

For our son's first birthday party we had to feed 12 adults and 9 kids, so we would need a big cake, or maybe two, and one small cake for the birthday boy would be fun. At one year old, there's not necessarily much that a baby is "in to," but I can say for sure he likes spinning things. Mostly the wheels on his toys. So why not cake(s) shaped like wheels? Seems simple enough. Not quite as complex as his Baptism Cake, but that's OK by me. I'll save more complex designs for the future.

I made two boxes of cake mix, but divided up the batter evenly by weight so I could make three round cakes. Our only round pan had angled sides, so I used a springform pan instead, which worked very well. Bake-Even strips made a big difference too, keeping the cakes fairly level, and not too rounded on top. The cakes are much easier to work with, cut & sculpt, and frost when they've been frozen. So I made my three cakes ahead of time, wrapped them in plastic wrap, and froze them overnight.

Why three cakes? Two would be the base of each wheel. The third would have the center removed, which would become the birthday boy's personal cake. The remaining "donut" shape would be cut in half, and placed on the first two cakes as the raised shape of the tire. The picture at the right shows this in better detail.

Decorating was fairly straightforward. I used white frosting from the store and used black coloring to make different shades of gray. The base cake got a coating of light gray which would separate the layers and give color to the "hubcap" area. The outside of the cake got a dark gray frosting, and at my wife's suggestion I added some blue to the hubcap for a splash of color. A Monochromatic gray cake wouldn't be as fun, right?



With the help of a ziploc bag and cake decorating tip I put lettering on the cakes and we were done! I would have enjoyed adding more details, but my time and energy were limited, as being a parent can sometimes do to you. Still, it was fun and I think it turned out well.

Everyone thought the cake was wheelie good.