Friday, February 25, 2011

Preferred Parking

A little perk while out on nursing home visits:



Still gives me a little thrill!

Wednesday, February 23, 2011

How Not to Make Oatmeal

Brynna occassionally enjoys having oatmeal for breakfast. She particularly enjoys it with Deen - it's one of the things they do together. Sometimes I attempt it, and Brynna is, usually, receptive.

When I do it, here's what's in it and how I make it:

  1. Oats, about 1/3 cup dry

  2. A few raisins or craisins for taste

  3. boiling hot water

  4. stir

  5. If using rolled oats (not instant), cook in the microwave for about 20 seconds

  6. 1/2 tsp maple syrup

  7. 3 T unsweetened soy milk to cool things off and get the consistency right

Mark Bittman, who used to write minimalist recipes and cooking techniques for the NYTimes, has a weekly opinion piece on food policy. This might seem a dry subject, but what we eat, where it comes from, how it's made, and how we eat it is no small matter. In today's piece, Bittman describes the travesty that is McDonald's take on oatmeal. Some of the highlights:

They’ve made it more expensive than a double-cheeseburger: $2.38 per serving in New York.

I use oats from the bulk food section, possible five cents' worth. My other ingredients are pricier, but the infallable back-of-the-envelope tells me I'm still below $0.40.

“Cream” (which contains seven ingredients, two of them actual dairy) is automatically added; brown sugar is ostensibly optional, but it’s also added routinely unless a customer specifically requests otherwise. There are also diced apples, dried cranberries and raisins, the least processed of the ingredients (even the oatmeal contains seven ingredients, including “natural flavor”).

I'll admit that soy milk is hardly a naturally occurring product: it takes some work to turn raw soybeans into a healthful beverage. Even so, I can follow and understand the ingredient list, and the first two are filtered water and organic soybeans. Our maple syrup comes, unsurprisingly, from NH. The cranberries are sweetened, but it's with orange juice.

Incredibly, the McDonald’s product contains more sugar than a Snickers bar and only 10 fewer calories than a McDonald’s cheeseburger or Egg McMuffin. (Even without the brown sugar it has more calories than a McDonald’s hamburger.)

When Brynna and I want to get crazy, we'll add some chopped walnuts.

Monday, February 21, 2011

TwinklePIC video

Parts 1, 2, 3, 4, 5, and 6

This will be the last post in the series - I promise. But someone pointed out to me that despite the (too) great pains I had taken to describe the twinkling effect, no one has actually seen it. So, ok, here's a quick video.



The videography is total crap: low resolution, poor dynamic range, overexposed in the dark, flicker from aliasing between the LED PWM and video framerate, streaks from the lens, etc. etc. But it does get the point across.

Saturday, February 19, 2011

TwinklePIC, part 6

Parts 1, 2, 3, 4, and 5

I now had a board, and I had a display. So it was a simple matter to just plug the board in and some USB power.



And lickety-split, it all came together.


Brynna is intrigued by it. I look forward to explaining this all to her (in about 10 years) in as much agonizing detail as she can tolerate. Unfortunately, as far as the original goal of the project goes - to create a twinkling nightlight - I'm afraid that it may not quite come to pass. There are a few reasons:


  1. Although LEDs are efficient, you have to remember that, on average, I'm converting less than 1 watt of electrical power into light. You'd get as much, or more, from an LED headlamp. The display is quite bright to look at, but it doesn't illuminate a room very much.

  2. These particular LEDs emit light in a fairly narrow cone. So in the dark they throw a very directed light across the room, but not much to light to the rest of the room. A different display construction, with more diffusers and scatter, could ameliorate this, but my appetite for that kind of tinkering is pretty limited.

  3. Brynna has gotten very used to the steady, soft-soft-white glow of the low-wattage CFL in the lamp in her room. She's been sleeping to that for over 18 months. She's pretty unwilling to let these LEDs replace that, although she may consent to let them augment. Recall that I'd first conceived of this project nearly three freakin years ago, before Brynna was even born. If I'd somehow managed to finish it before she could formulate opinions on her sleepytime lighting, I might have had a shot


This is not to say that it's all a failure. I learned some things and kept some of my electrical engineering skills from atrophying too much. Even if it doesn't work well as a night light, it is still an interesting curio in a lit room. The core design allows for some interesting possibilities. For instance, the LEDs needn't be all white. With a red, a blue, and a green LED, one can reproduce most any color. RGB LED clusters can be had, and I could use three channels from the TwinklePIC to drive em, and get a light element with a randomly-changing color. (As a matter of fact, I read about such a project in the latest issue of Make: magazine a few nights ago). I can use the TwinklePIC as a logic-level signal input to a much beefier LED driver, permitting arbitrarily large light output. The design is modular, so I can have two boards driving 16 channels, 3 boards for 24, etc. I have seen set ups where small plastic or glass fibers have been embedded in ceiling plaster, than sanded and exposed, with a remote light source to light them up, By bundling the fibers in random arrangements back to some number of TwinklePIC boards, we could give the B an entire twinkling night sky!

How very typical of me: to think up a dozen potential projects that I'll never have time for just as I reach the finish line for one.

Friday, February 18, 2011

TwinklePIC, part 5

Parts 1, 2, 3, and 4

So after making my first hand-wired prototype, I decided to make a printed-circuit-board version of the same. Why? Well, a PCB is a whole lot cleaner and more durable. It also is a whole lot faster to assemble (populate), because all you need to do is solder the components in place - all the wiring between components is contained in the board. The downside is the extra time to lay the circuits out on computer, the time to get the boards made, and the expense.

Strictly speaking, because this whole project is likely to be a one-off, I didn't need to go this far. I could have just boxed up the prototype board and called it good. Sometimes being an engineer is knowing when to do just that and move on. I do take pride in my work, though, even my at-home projects, and I wanted to produce a clean result. Part of this whole project was to flex some seldom-used skills, too, like circuit layout. Plus, there was (still is) the off chance that someone might see the results and say "Neat! Where can I get one?" in which case populating a PCB is a lot easier than hand-wiring another. One more aspect of it is that, if I ever wanted to share this project with the wider Maker community - open-source it - a complete design with PCB is much more attractive than a code listing and a half-assed circuit schematic.

Although I have access to some very powerful PCB layout programs at my office, the learning curve on them is steep. I have tinkered around with the free Eagle program before, and could use it on my laptop at home, so that's where I did the design. You start by creating a circuit schematic, then find or create PCB footprints for each component, then arrange the footprints on the board, then draw the traces to connect the pins together.


Being a perfectionist, I tend to tweak such things a lot more than is necessary. Also, because the place that makes my boards charges by the square inch, and because I'm a cheapskate, I strove to shrink the overall board size down, which requires more tweaking. I was able to get this design down to about 3 sq in, or about $7 ($10 with S&H). My Eagle library didn't have footprints for most of the components I used, so I had to create them. All-in-all, it was a huge time suck. But the results are nice:


Some notable additions I put on the board that were lacking from the hand-wired prototype. First, I added a USB-mini connector, so that I could power the thing from any USB source. I still have pins where I could wire in 3-5.5 V from, say, a battery, and a jumper that would allow me to select between sources. As a protective measure, no matter the power source, I added a 500 mA fuse. The white connector along the top edge is my ICSP (in-circuit serial programming) header, which lets me reprogram the chip while its still in the circuit. The layout of the resistors is such that one can, as I have done, solder in each resistor, or replace it with a resistory array chip, or replace that with a chip socket, which allows easy swapping of resistor values. Why would you want the resistors to have different values from each other? The resistor value, more or less, sets the maximum brightness for each channel. So if you wanted a create a constellation of "stars" with different magnitudes, you could do that without customizing the program on the chip.

Some may notice that I have stuck to the 0.1"-pitch thru-hole components. I didn't need to. In fact, I could have probably cut the PCB size in half by replacing the PIC, connector, and LED resistors with surface-mounted components. But I still like the flexibility that I have here with the larger components. Sticking the PIC in a chip socket, for instance, allows me to easily replace it if I blow one up.

I kept the same large connector so that I could interface to the existing LED cable I'd made. Another person could solder the LED leads directly to the board and skip the connector.

Thursday, February 17, 2011

TwinklePIC, part 4

Parts 1, 2, and 3

So, I had a circuit that worked and a program that made the LEDs twinkle nicely. But that is only part of the story: I also needed to dress it all up into a pleasing display. In truth, the soldering and programming were fun little exercises; industrial design is not something I would claim to have any talent with.

The Cosmic Nightlight that was the original inspiration for this project embedded its LEDs in a clear epoxy resin, into which was mixed streaks of color and children's glitter. The LEDs were arranged into the constellation Leo.

The results were very nice, and originally I planned to do the same. But in the end I decided to take a different approach. The epoxy was more labor-intensive than I wanted - and permanent! The author's nightlight was 3" x 6", dictated by the mold he used. I wanted something larger. In the end I decided on the following construction: I would embed the LEDs into a piece of 8" x 10" black acrylic, and set that into an ordinary picture frame. Much easier to just drill some holes!

I pondered what constellation, if any, to base the work on. I decided to make the Pleiades cluster:


It's beautiful, it's visible to the naked eye, it's a little off the beaten path, it has tons of history and legend associated with it, and it's the inspiration for the Subaru logo. Plus, I was using white LEDs for this project, many of which tend to have a slightly bluish tint to them, so a constellation filled with blue giants seemed appropriate.

Since my presentation was going to be pretty spare - no glitter or extraneous coloring - I at least wanted to go for fidelity. I could perhaps have found measurements of where each star is located in the sky, then transferred that to my 8 x 10 acrylic. I could have done it freehand. Instead, I went a much easier route, and made an 8 x 10 printout that I could tape to the acrylic, using the star locations as my drill locations. I found it much easier to first invert the image and print it black and white. It is well known that humans are better at picking out black spots on a white background than the other way 'round. This saved a lot of ink, too.


This then was the pattern I used to drill holes in the acrylic. I plugged the holes with the LEDs on wires that I showed in the previous post.

One thing I soon realized, however, was that these particular LEDs shone their light in a relatively narrow beam. In the dark, they were dazzling when viewed head-on, but didn't throw much light off-angle. There are things I could have done to combat this, including just getting different LEDs. But laziness won out, and I have just decided to live with it for now.

One thing I did to ameliorate the narrow-beam effect: I replaced the picture frame's original piece of clear plate glass with a piece of frosted glass. It doesn't do much for illuminating an entire room, but it does produce a nicer look from the side.

You'll notice that the stars in the cluster are not all the same brightness. I could have adjusted the program so that some of the stars were always brighter than their fellows. A better way would be to adjust it in hardware: each LED has a resistor in series with it. The resistor value has the effect of setting the maximum brightness: a greater resistance would result in a dimmer LED. The apparent magnitude of all the stars are well known. It would have been trivial to figure out what resistor values to use to get the relative brightnesses of the LEDs to match. Again, laziness won out, and I haven't gone to that length yet.

My intention originally had been to power this device from batteries. Based on testing I did with my prototype circuit, a fresh pair of AA alkalines would nicely light Brynna's room each night for just over a week. In that case, I planned on routing out a groove in the wood of the picture frame, and installing metal contacts at either end, so that I could indeed have the batteries as part of the frame. But then I got to thinking about all the batteries I'd be using over the years: it's unconscionable. Rechargeables were an option, but with shorter runtime. Plus, as the batteries drained, the LEDs would get dimmer.

Instead, I decided that the best long-term solution would be to power it from a high-efficiency AC/DC converter. A USB power adapter would do the trick nicely: they're easy to find, relatively inexpensive, can be really tiny, and can be extremely efficient. I'm presently using the adapter from the current generation of iPhone: it's >90% efficient, zero vampire current, and less than one inch cubed. The USB cord, and required proximity to an outlet, are a livable compromise.

You may recall that I also installed a mode-selecting switch, which would toggle the LEDs from twinkling to solid to off to twinkling again. This I planned to install on one corner of the picture frame. If I installed it on the front it would be easy to find, but a bit of an eyesore. Instead, I planned to install it on the back side of the frame, so that to activate the switch all one need do is push that corner of the frame as it hangs on the wall.

How does it look? You'll have to wait for the 6th and final installment. Before that, we'll revisit the electrical circuit, and how I transformed it into a printed circuit board.

Wednesday, February 16, 2011

TwinklePIC, part 3

Parts 1 and 2

So I had a program running on the microcontroller I was happy with. I had a circuit that worked well on a breadboard. The next step was to package up into a more permanent form - something a bit more durable, and a whole lot smaller.

The first real prototype I spun (completed in early summer 2010) was done in what is called perf board, meaning that it is perforated with a grid of holes spaced evenly apart. Most perf board is done with holes on 0.1" centers, which matches the pitch of a lot of thru-hole components. This is a good scale for hand-soldering, prototyping, and reworking, because it is a decent match for the unassisted abilities of human eyes and hands. Most circuits produced today are done with components that are fantastically small and really only workable by machine.

You can see that, when it comes down to it, there isn't a whole lot to the circuit. There's the chip running everything, a crystal to provide a clock signal, a resistor for each LED channel, a header for all the LED connections, and a button for mode-switching. Power comes in at either the male or female header above the chip. The big empty space to the left is there to let me zip-tie a holster of AA batteries for power.

The actual wiring isn't all that bad, either.

The connector really dwarfs everything else. There are lots of smaller connectors I could have used, but this one was handy, and it was easy to attach a bit of ribbon cable with the LEDs soldered at the end. Why even have a connector? Why not just solder the LED wire leads directly to the board? Well, this was still a prototype, and I liked the notion of being able to swap out one board for another, or make the cable longer or shorter, with resoldering everything. Modularity is good.


And it works! Hurray!

But while this bundle of LEDs looked nice when taped to my monitor at work, it still wasn't what I was aiming for. I still needed to assemble them into a constellation.

Plus, while this prototyped board worked pretty well, there were still things I wanted to do differently with it. Like the ability to power it from USB. Or cutting down the assembly time of the next unit (if there ever was one) to less than an hour. Or making it a bit tidier and compact overall. For this, I would need to get away from a hand-wired prototype and enshrine it in that most preferred of circuit media: the printed circuit board.

Tuesday, February 15, 2011

TwinklePIC, part 2

Wait. Part 2? Was there even a part 1? Only the most devoted readers, endowed with prodigious memory, will remember that, oh, about a year ago, I started writing about a little electronics project I was cooking: a device that would have a number of LEDs in a constellation, each of which would twinkle - randomly fade in an out. The project has, throughout its entire 3-year existence, moved in fits and starts. As I have just about finished it, it is clear that documenting it has faired even worse than the actual doing of it. I hope to get it all out to you, dear readers, in the next few days.

To adjust the brightness of an LED is a straightforward task in electronics: just turn it on and off very fast. By varying the ratio of On time to Off time (also called the duty cycle), you can adjust the apparent brightness (your eyes and brain blur it together). This is a technique called pulse width modulation (PWM) and, as I said, is a straightforward task to do with a microcontroller.

What's a microcontroller? Think of it like a really small, very limited computer. Microcontrollers run small computer programs that are burned into the device itself (no hard drives here). There's a general-purpose microcontroller in your TV remote control, and one in your microwave. Is the brain of your cellphone a microcontroller? Or the latest screamer from Intel residing in your laptop? That is largely a matter of semantics and degree.

Microcontrollers are made by lots of different chip manufacturers, with feature sets and price points that run from the very mundane to "holy shit." For this twinkling lights project, there are hundreds of models that would do the job in the range of $1-15. At the time that I started tinkering (Dec 2009), I was already using some products from Microchip in my job. So, I went with what I was then familiar with and chose a member of the PIC16 family. Nowadays I am using some snazzy chips from Texas Instruments, and were I to do this overagain I might consider using a low-end member of the MSP430 family.

I also considered using an Arduino. For those that do not know, the Arduino is an open-source platform that is very popular in the Maker community. The Arduino is, essentially, just another microcontroller (made by Atmel), but it is very user-friendly and has a shallow learning curve. It is made to be accessible to novices - much of the nitty gritty is glossed over and made easy for you. A complete board (not just the bare chip) can be had for $30 - all the other tools (including a vast library of community-developed example code) are free. I decided against it in part because, in the goal of making it user friendly, they add a layer between the user and the silicon. That is handy if you know nothing about it, but I specifically wanted to run close to the silicon.

There are three timing tasks involved in getting an LED to twinkle. The first I have already mentioned: using PWM to set the brightness. The next is to vary the brightness by changing the duty cycle. This causes the brightness to change in time: fade in and fade out. The final task is to change the speed of that fading in and out over time, so that one minute the LED will fade slowly, and the next minute quickly. Figure this out for one channel, and you can scale it up to any number of channels. Put enough channels together, and I'd have a constellation of twinkling stars.

If anyone is interested in the details of the code, let me know. I might, at some point, find a place to put the entire design: circuit, PCB, and code listing. For now, let me summarize how I do each of those three tasks.

1) PWM. Many microcontrollers have special circuits that make this almost auto-pilot. Not many low-end microcontrollers can do this for, say, 8 channels at once. So, I brute forced it in software. I have one variable that counts up and up. When that timer value, T, reaches some maximum (65,000, or 2^16, if you care), it rolls over to zero. An LED channel has a number associated with it, which I'll call D. Since I have multiple LED channels, I'll call them D1, D2, etc. When the timer T rolls over to zero, I turn all the LEDs on. When the timer has counted up to D1, I turn that LED off. If D1 happened to be, say, 30,000, then that LED will end up spending about half of the time turned on, for a duty cycle of 50%. To make it appear convincing, the amount of time I spend on or off must be very short, otherwise the eye will catch it. So, I turn the LEDs on and off about 120 times per second.

2) Fading. If at some point I decide to change the value of D, I will change the duty cycle of that LED. If D becomes 10,000, the duty cycle will drop to about 15%, and the LED will appear dim. If I change it to, say, 43,000, the duty cycle will be closer to 75%. To make a convincing fading effect, I need to adjust D gradually and smoothly. So, about 10 times per second, I add or subtract a small amount, call it F. I'll increase D, in increments of F, all the way up to the max brightness. When I hit that ceiling, I'll turn around and start subtracting F from D. I keep decreasing D all the way back down to zero, then start increasing it again.

3) Change the Fading. Steps 1 and 2 are enough to make an LED smoothly get brighter or dimmer at a regular pace. If you've ever seen an Apple computer sleeping in the last 10 years, you'll see the power light doing this. The third element is to change the pace of that fading - make it happen faster or slower. To accomplish that, I need to make F change over time. This I do by, unsurprisingly, adding or subtracting a small, random, amount to F a few times per minute.

Scale this up so that I'm doing steps 1-3 on eight independent channels at once, and I get a pretty constellation of stars. Each channel fades in and out with its own speed, which is different than that of all the others, and which itself changes over the course of minutes. The resulting effect is, I would say, pretty nice.

Believe it or not, this is a very long winded explanation of what, in reality, only takes about 50 lines of computer code. This gets translated into a stream of about a thousand 1s and 0s, which gets imprinted onto the PIC16F684 microcontroller. This chip has 14 pins, costs less than $2, and can be used to drive 8 LED channels. Here's a prototype circuit I put together in early Jan 2010:

To the center-right there is a small pushbutton. This can be used to switch the display mode. The default is for each LED to twinkle randomly. Other modes set all the LEDs to a steady brightness (100%, 50%, etc.). The last mode is a sleep mode where everything is off, and the circuit draws next to no power. This is handy for battery-powered applications.

Coming up in part 3: how I take this prototype circuit and fancify it!

Monday, February 14, 2011

Thanksgiving in CT

Another anecdote from our backlog of holiday postings. This one from Thanksgiving. Hilary actually had most of that week off, including Thanksgiving day, but did have to work Friday. So, she spent most of that week with her folks in CT, drove back here to NH to see me (the working stiff) on Thanksgiving day (and take in Harry Potter 7), then drove back to CT with me on Friday, so that we could all have a proper thanksgiving with her family and my family on Saturday.

A highlight of the dinner itself were the headgear that Brynna and Deen has craftily made in the preceeding days. Some wore pilgrim hats, and others wore Indian headbands.

She had also made a turkey centerpiece with Miss A. a few days earlier. It was a hit!

Sunday, February 13, 2011

P is for Parents

For lack of any news, here's a little anecdote from Christmas:

Brynna has now reached new heights of iPhone skill. This new trick actually involves using the phone as a phone, believe it or not.

B is not a great conversationalist on the phone—given her early experiences with iChat, she prefers to wave hello instead of actually talking. But recently she's started to participate in the occasional call with her grandparents, mainly to ask them to go get on their computer and have an iChat with her! A few weeks ago, she wanted to help me actually place the phone call, so I explained to her that in the list of contacts on the phone, M and Deen were listed under "Parents," and then she touched the word that started with P to connect the call.

So, we were driving down to CT to visit my parents on Christmas Day. Brynna was in the back, refusing to nap and instead playing games on my phone, when we turned off I-84. I turned around.

Me: "B, may I have my phone please? I need to call M and Deen and tell them that we're nearly there."

B: "No! I do it all by myself!"

B pokes around for a moment, says to herself "P is for Parents," then holds the phone up to her ear.

A moment later, B says "Hi M!" a few times. With some coaching Brynna did eventually say "We off da hi-way" before a quick and over-loud "Bye!", followed by hanging up.

At this point, I decided I should collect my phone back, lest Brynna get it into her head to call China.

Tuesday, February 8, 2011

Making Bread!

I worked 82.5 hours last week.

I haven't eaten a proper meal for two days. (No, people, I am not pregnant...did I mention the 80 hours at work? Just viral.)

And the call schedule just gets worse and worse, as we continue to lose residents to illness/maternity leave/alien abduction left and right.

So...it's time for random cute kid pictures!

Here's Brynna making bread with Auntie Sara at New Year's:






I think she's going to be quite the chef when she gets a little older. She loves to watch us in the kitchen (oh, who am I kidding? Alex is the only one cooking around here these days) and she also spends a lot of her time pretend-cooking in her play kitchen. Tonight she spent ages baking, frosting, and distributing her Melissa and Doug cookies.

Monday, February 7, 2011

Two Sides of a Conversation

This morning Hilary wasn't feeling well. So she sent me a textessage asking if I, too, was feeling crummy.

Later in the morning, Brynna asks to talk to Dada. So Hilary types in a text message into her phone and lets Brynna send it off.

Here is the conversation from my perspective:

9:06 AM: how're you feeling today? I'm so nauseous.

9:42 AM: hello daddy!

This damn near gave me a heart attack!

Sunday, February 6, 2011

Packaging Waste

Amazon.com has made some limited progress with its Frustration-Free Packaging program. This is a good thing by many measures, and I wish it were more widespread. I wish they could extend it to all their subsidiaries, like Diapers.com

As most of you know, Brynna has been in gDiapers practically since she was born. We had many reasons to go this route over traditional disposables, and one of those reasons was the green-ness of it: processing diapers via the toilet and washing machine was much better than simply throwing diaper after diaper in the trash. We have for a long while received bulk shipments of gDiaper inserts directly from the manufacturer. Recently, they discontinued this direct-by-mail program, and shifted the service over to Diapers.com. We shrugged our shoulders and switched over too, and began receiving our shipments from them, instead.

By and large, the change has been transparent to us, but for one large frustration: the packaging. gDiapers would send us four packages of inserts packed tight into a 12" x 12" x 15" cardboard case. We've got a lot of those boxes in storage: they're a good size and very sturdy. Diapers.com, on the other hand, feels compelled to send us the exact same gDiapers case inside of a bigger box!



The Diapers.com outer case is another sturdy cardboard box, 16" x 16" x 19", and the space between is taken up with bags of air. If you work out the volume, you'll find that the Diapers.com case is, literally, twice as large.

And why is Diapers.com adding considerable expense to send off a pre-packaged product in a large and redundant box? I wish I knew. I could think of a few reasons, and none make much sense. The first is that they needed a place to put the packing slip, and couldn't simply stick it inside the the already-closed gDiaper box. This is a fairly ridiculous reason, since they could just slap it on the outside of the box in one of those plastic envelopes. Not a great solution, true, but better than sending off an extra few dollars of packing materials. A second possible reason is that sending gDiapers is new for them, and they simply haven't set things up properly yet. But this is a business, and I'd expect them to have their act together after a few months. The third, and most craven, reason I can think of is that Diapers.com is so vain and so insecure in their branding that they couldn't bear to ship a box that has someone else's logo on it.

For what little it is worth, I have contacted Diapers.com and told them about the absurdity of this situation. The customer service rep was very polite, and told me she'd send it on up the line. I'm not too hopeful. I think this irks me enough that I'll drop them entirely and source our gDiapers locally. We can get the same case from a local store, it just costs a bit more.

Saturday, February 5, 2011

Big Steps!

Two big events in little B's life today:

She went all the way underwater at her swim lesson today

and...

She pooped in the potty!

Jeez, before you know it she'll be shaving...