Stop. Hammer Time.

Posted in Projects on September 17th, 2012 by Andrew – Comments Off

I got a new hammer in my toolbox the other day — a Raspberry Pi single-board computer. Runs Linux. Pulls power off a micro-USB connector. It’s got two USB ports for connecting keyboard and mouse (or USB hub for connecting other USB things like an external drive, or a webcam, or…), HDMI for hooking up to a monitor, audio out. Hell, it’ll even output composite video if you’ve got a thing for analog video.

In addition, it’s got GPIO pins on it for making LEDs blink and stepper motors step and other fun “real world” things do whatever it is they do. The Linux distro — Adafruit’s Occidentalis v0.2 — I put on the SD card it boots off of contains two flavors of Python (2.7 and 3.2) with NumPy already installed for hardcore mathematical computing (I also installed gfortran just in case, and because I could). Git is already on board (and now, so is the bash script for the Uber Git Prompt).

It’s a great little hammer. I constructed a tray for it to sit in out of LEGOs because a quick Google search proclaimed it the thing to do for a Raspberry Pi, and building it was a lot of fun.

Raspberry Pi in Serving Tray

Now all I need is an appropriate nail.

A Most Delicious Fruit

Posted in Projects, Software on May 16th, 2012 by Andrew – Comments Off

My son is in the beginning stages of learning arithmetic. Being the Internet savvy father, I immediately hooked him up with the Khan Academy videos. In the Basic Addition video, Sal Khan uses circles as items in the set whose value is expressed by the given integer. He calls these circles avocados — a most delicious fruit.

I like the idea of counting avocados. The downside is their prohibitive cost due to short shelf life, and how much space they would take up in the kitchen. My son took to counting on his fingers to solve addition problems, but that only gets him to 10. I figured I could help him out and get him more comfortable with deliberately pressing keys on the computer keyboard by writing a short Python script to quiz him on basic arithmetic that displayed sets of avocados for each of the values. Being old school (or just really lazy), I wrote it to run on the command line. It looks something like this when run:

¢ python
   1    o
+  6    o o o o o o
? 7
   3    o o o
+  2    o o
? 5
   3    o o o
+  6    o o o o o o
? 9
   1    o
+  2    o o

Since I want him to be able to use it for more than a few weeks, I made it configurable via command line arguments. You can set the maximum value that the augend and addend can be (–max [n]) (1- and 2-digit numbers work best for the display routine). Beyond addition, you can configure it to do subtraction (–subtraction) (non-negative differences only), or both addition and subtraction (–both). And you can configure the number of problems to ask (–count [n]). Type in a wrong answer and the problem is repeated.

Soure code is available on GitHub. It’s not Earth-shattering programming. But then, not everything has to be.

I hope he likes it.


Posted in Fauna, Flying, Insects, Photography on August 15th, 2011 by Andrew – 1 Comment

In flight, not from the rear. Those of you who read this blog regularly (both of you, as of last count) know this to be my Holy Grail of photography. What you may not know is that for the last year or so, I’ve had a particular target in mind: the tarantula hawk.

This is a male. They're big.


Why, you ask, would I want to photograph a 4 cm long wasp that ambushes tarantulas at their burrows, paralyses them, drags the spiders back into their burrows to lie, unable to move, waiting to be consumed by the wasp’s larva when it hatches from the egg laid upon them? I find them striking. And with their iridescent blue bodies and orange wings (and sometimes, antennae), under the right light, it would make an awesome photograph. Plus, there’s also the Everest answer.

What I didn’t fully grasp when undertaking this quest was how truly disconcerting it is to have large wasps winging around your head at close distance (I’ve only got a 55mm lens to play with, so I have to get really close, even with big bugs). Not to mention the females I saw are closer to 5 cm in length. Plus BugGuide says tarantula hawks, while generally non-aggressive, are reputed to have very powerful stings — Don’t want to accidentally bump into one and find out.

This is a female. They're even bigger.


The easiest place to photograph tarantula hawks around me is at the Wild Animal — er, San Diego Zoo Safari Park (don’t know if I’ll ever get used to the name change). The first covered picnic table on the Garden Trail is situated right next to some plants that tarantula hawks absolutely adore. They will hang out on the blooms, drinking nectar for minutes at a time, oblivious of intrepid photographers willing them to take flight.

Like this, only in focus.

And yet fly they do. I had better luck catching the inbound tarantula hawks than waiting for one gorging itself on nectar to take to wing. Though when they fly directly at the camera lens, it’s really hard to stay composed and keep the bug in frame, let alone turn the focus ring and squeeze off some shots.


Stupid Arduino Tricks – Logic Analyser

Posted in Arduino, Projects, Software on May 16th, 2011 by Andrew – Comments Off

Checking the values of the digital pins on an Arduino is best done with a logic analyser or oscilloscope. But scopes are expensive, and while logic analyser prices have come down a lot since I last looked, they’re still expensive enough to give pause before purchasing one, especially when the thing you want to attach it to is a $30 microcontroller development board.

The solution? Write a logic analyser in software! Others have done this on the Arduino, but those were meant to make a traditional, external logic analyser. This Stupid Arduino Trick is meant to be embedded in other projects to read the digital lines directly while the other project is running, no probes required.

There are down sides to doing this, of course. The added software load from the logic analyser will mess with the timing of the software. And data collection sucks up a lot of RAM — the Arduino only has 2 KB to play with to begin with.

To address the first problem, the best you can do is write tight code. Data collection happens on a periodic basis in an interrupt service routine. Since in general, I don’t know the environment that the logic analyser will work in, I decoupled the logic analyser from any specific timer. It’s up to the user to add a call to the logic analyser’s timer event. This way, the logic analyser can be given its own timer ISR, or it can piggyback on an in-use timer ISR in the project code.

The sampling rate of the logic analyser is configured in the same way — the user is responsible for setting up the timer ISR period manually.

The logic analyser does offer an interface for setting up which digital lines to trace (up to eight), and the trigger conditions that will start the thing collecting data. Trigger conditions include rising edge, falling edge, high, and low for up to eight lines.

To address the second problem, pin values are stored as bits in a character array. Characters being 8 bits wide on the Arduino, the logic analyser can sample 8 digital pins each interrupt.

The logic analyser runs a simple, three-state state machine.

After configuration and the issuance of the start command, the logic analyser enters the WAITING FOR TRIGGER state, where it checks the sampled inputs for the trigger conditions on the specified digital lines. Once the trigger condition is met, the logic analyser enters the TRACING state, where it collects data until its trace buffer is full. Once it’s full, the logic analyser enters the DONE state, where it does nothing each interrupt. The DONE state is also the initial state of the logic analyser.

Once data is collected, it can be sent to the host computer via the serial / USB port on the Arduino. The data is formatted as comma separated values for easier import into your favorite spreadsheet application for analysis and will look something like this:

Source code for the logic analyser is available on GitHub. The Arduino sketch there includes the unit test for the logic analyser. To use the logic analyser in your own sketch, either copy LogicAnalyser.cpp and LogicAnalyser.h to a folder called LogicAnalyser in the libraries folder of your Arduino projects directory, or include the two files directly into your Arduino project’s sketch. The second method is probably preferable since it will allow you to change the trace buffer size to fit your needs and memory restrictions.

One Little Dragonfly Sitting in a Tree

Posted in Fauna, Insects, Photography on May 8th, 2011 by Andrew – 1 Comment

Sometimes, autofocus actually works.

Walking around the backyard, I stumbled upon this dragonfly resting on a tree. Since I had gotten pretty close without it flying off, I figured there was a better than normal chance that it would still be there if I went and got my camera. And it was.

Knowing how skittish these hunters of the sky are, I bumped up my ISO setting and slowly approached, photographing as I went. When I got as close as I dared, I started inching the camera closer, peering through the viewfinder, keeping the center autofocus point on the insect’s thorax. Oh, for a camera with a large LCD and live view (not to mention a large macro lens)!

I got nearly full arm extension before the dragonfly got fed up with my shenanigans and flew away.

The original photo has the full body of the dragonfly in frame, but I think this cropped version is much more interesting.

Mircrowave Poached Egg

Posted in Cookery, Projects on April 26th, 2011 by Andrew – Comments Off

On 25 April, Scott Heimendinger posted a link on his Seattle Food Geek Facebook page to Nancy Leson’s blog on the Seattle Times website. In this blog entry, Nancy replicates a recipe (if you can call it that) from Bon Apetit magazine for poaching eggs in the microwave. The procedure is this:

In a small bowl or teacup, crack the egg into 1/2 cup water. Cover the bowl with a saucer and nuke for about a minute.

Nancy’s palate and microwave settled in on 50 seconds for a perfectly poached egg.

The time of year being what it is, I had a lot of eggs sitting in the refrigerator to experiment with, so I gathered the tools and ingredients. 120 mL of water went into a mug followed by one extra large egg. The mug went into the microwave, which was programmed to cook on high for 60 seconds.

57 seconds later, I found out what the saucer was for.

Definitely not good eats.

Okay, take two. Clean mug, clean microwave, more water, another egg. And the saucer. Nuke for 60 seconds. After removing the egg from the mug with a slotted spoon, I cut into it to find part of the yolk had coagulated into a solid — overcooked.

The third attempt was for 50 seconds. This egg wasn’t cooked enough — there were a good bit of albumen that hadn’t turned opaque. I tried again and let the egg sit in the warmed water for a couple minutes to see if carryover would finish the whites for me. No luck.

The fifth attempt was for 55 seconds. The whites were almost completely opaque, and the yolk was nice and runny. Probably about as close as I was going to get to success with this method, I figured, so I stopped there and made myself a snack.

The things I do for science.



Modernist Cuisine: Unboxed

Posted in Cookery, Projects on April 9th, 2011 by Andrew – Comments Off

Unboxings seem to have become passe on the Internet, but since there are only 6000 copies of Modernist Cuisine in existence as of this writing, and (most likely) not all of them have been delivered yet, I thought I would get more bang for the pulled back muscles, bloodied toes, and hernia from lifting Modernist Cuisine en masse by posting just that*.

Hey, at least it’s not in video form.

After months of deliberation as to whether I should actually purchase Nathan Myhrvold’s magnum opus, and almost two months of waiting after pulling the trigger and pre-ordering a copy in mid-February, a large, cumbersome cardboard box was left on my doorstep (apologies, UPS guy). The weeks leading up to this momentous occasion were gut wrenching.

When I placed my pre-order, Amazon listed my expected delivery to be in March — immediately after the book launch date. Having followed the Modernist Cuisine blog, I knew better than to expect to get one of the first couple thousand copies, so when the expected delivery date came and passed, I wasn’t worried. Shortly thereafter, Amazon informed me that when they had a new estimated delivery date, they would let me know. No problem.

In late March, the Modernist Cuisine blog let the world know that all of the first printing books were somewhere between the printer in China and 6000 early-purchasers’ shelves, with delivery of all the books expected by mid-April. Amazon was slated to get a substantial delivery of books by 29 March to their service center in Arizona — the most likely center where my book would come from. I started to get anxious.

The end of March came and went. “How long does it take to fulfill 600 orders at an Amazon facility?” I wondered. Worst case, not more than a couple of days, I figured. I stoically prepared myself for the long wait till mid-April, doing my best to ignore that creeping fear that I had not ordered early enough to receive a first printing (I don’t care that it’s a first printing — I just didn’t want to wait for the second printing to start delivery, which I was guessing would probably be in June).

On 5 April, I received exciting news in my inbox:


We now have delivery date(s) for the order you placed on February 17 2011:

Nathan Myhrvold, et al “Modernist Cuisine: The Art and Science of Cooking”
Estimated arrival date: April 11 2011 – April 15 2011

15 hours later, I got a shipping notice from Amazon. Delivery would be the next day!

Sensing how excited I was to receive the package, UPS decided on an afternoon delivery. Around 3:30 Thursday afternoon, the UPS guy ding dong ditched 21 kg of books on my doorstep. Lifting the box to get it inside involved maneuvers I’d previously only seen in clean and jerk weightlifting. Once inside, the unboxing began.

From China to my doorstep


The box knows of which it speaks.




As it turned out, the food theme extended beyond the content of the books. The packaging around the books was like an onion — layer after layer of cardboard. Inside the first box was another box. Inside that, a small box containing volume 6 of Modernist Cuisine. Under that box, white shipping paper surrounding the plexiglass bookcase for the remaining five volumes of Modernist Cuisine.

Inside we find... more cardboard.


...And more cardboard...




The conundrum at this point was how to get around 21 kg of books out of its packing material. Wedging my fingers under the books didn’t seem like it would work. Instead, I opted to lift the box-within-a-box out onto the rug, tip it on its side, and slide the paper-wrapped bookcase out onto the rug.

Well, at least it's not more cardboard.


That which will consume all my forseeable free time.


First impression: The books are a lot taller than I expected. The first five volumes are the size of coffee table books. Fitting them and their slipcase on a non-adjustable bookshelf would be challenging. Fortunately, I have an adjustable bookshelf. I find myself wondering what the weight limit of the individual shelves is, though.

Second impression: They’re not immaculate. My copies have wrinkles and folds on the spines of volumes 2 and 3. While this doesn’t affect the usability of the books, when you fork out $461 for books, you really want them to show up in mint condition. No doubt I’ll get over it.

Third impression: The ink and glue are still outgassing. Reading Modernist Cuisine may put you to sleep, but it won’t necessarily be due to the writing. I’m going to have to read these books in well ventilated areas until the smell goes away. Also, the books were bound before the ink completely dried, I think. I’m finding some pages are sticking together in spots. So far, separating them hasn’t caused any problems, but I still catch my breath when I come across such pages.

Fourth impression: Food porn!

Fifth impression: These books are information dense. Word for word, there’s more information about cooking in Modernist Cuisine than there is in the culinary school textbooks On Cooking, or the CIA’s the Professional Chef. Scanning the tables, I found myself wishing they were available as PDFs so I could print them out and keep them in my kitchen for quick reference. I’ll probably end up transcribing them onto a spreadsheet to do just that.

As you might suspect, I am thrilled to be a proud owner of Modernist Cuisine. I look forward to applying the information contained therein to my cooking. Whether or not it’s actually worth $461 remains to be seen, but my initial impression is, yes.

One thing I am pretty sure of is that like all expensive purchases (houses, cars, etc), this one will lead to more spending. An immersion circulator is the first order of business.

Oh, and by the way, all the packing material that came in the box make great toys for young children.

"Low waste"


* Injuries sustained from ordering, unboxing, and reading Modernist Cuisine may be exaggerated for literary effect.

DIY Clay Pot Smoker

Posted in Cookery, Projects on February 2nd, 2011 by Andrew – 2 Comments

In season 7 of Good Eats, Alton Brown builds a do-it-yourself clay pot smoker for $47.32. Skip ahead seven years to January of 2011.  Over the course of a few weekends, I hunted down parts and built my own.

Things were surprisingly difficult to find. Neither the Home Depot nor Lowe’s had clay pots of sufficient size that would work as a base and a lid. I ended up at an actual nursery for those. The grill grate was purchased at a Barbecues Galore. Again, the home improvement centers were a bust.

The hardest part to find, by far, was the hot plate. Nobody local sells them anymore, I ended up purchasing one off Amazon (this one, to be precise).

Parts is parts

The square hot plate did not fit on the bottom of my clay pot, so I ended up disassembling it. A lot of people on the Internet did the same when building their own smokers. The heating coil is easily removed from the hot plate once you open it up. Except for the wires, a metal bracket is all that’s holding it in there. Some pliers made quick work of the bracket, and the wires joined to the heating element with 0.25-inch disconnects, so they pulled right off. The disconnects on the heating element are press-fit, so while I was at it, I spun them around 180 degrees so they would face the hole on the bottom of the pot.

Some stranded patch wire (I used 14-gauge because that’s what was available — again, not at the local home improvement stores. The hot plate used 18-gauge, thermally insulated), a couple wire nuts, and some more 0.25-inch disconnects, and I was ready to go.

Alive! It's alive!

When splicing in my extension wires, I kept the hot plate’s temperature control in the circuit. The temperature control works by changing the spacing between two thin metal leaves. Turn the knob towards high, and the spacing increases. Turn the knob towards low, and the spacing decreases. These controllers work because one of the leaves bends when it gets hot. The hotter it gets, the more it bends, until contact is made between the two leaves, interrupting power to the heating coil. When things cool down, the leaf straightens, and power once again flows to the heating coil.

Placing the base of the hot plate away from the heating element as I did should obviate the temperature control — it simply should not work. However, the knob does have an off position, which forces the contact closed, turning off the heating element, making interrupting the electricity to the heating element a bit more convenient than reaching for the power cord and unplugging the thing. Plus there’s the phantom sense of control the knob gives — akin to the door close button in an elevator, which doesn’t actually do anything. Temperature too high or low? Turn the knob. If nothing else, you’ll feel better.

I should say the temperature control shouldn’t do anything. Playing with it, however, showed perceptible adjustments in the temperature range inside the smoker. Cranked to high, the smoker cycled between 250F and 280F. Turned down to low, and the smoker cycled between 220F and 250F. As they say in inconclusive scientific papers, more study is warranted.

The completed smoker

The chips are down

To test the smoker’s ability to generate smoke, I placed a pan of soaked apple wood chips on the heating element, and turned it on. Sure enough, once the temperature hit around 230F, appreciable amounts of smoke were generated. The smoke lasted for around 90 minutes, after which all that was left in the pan were ashes and embers.

The test chicken that bathed in the smoke tasted pretty good, too.


The remains of the day

What’s Next: Figure out why the hot plate temperature control appears to work.

Also, the smoker needs reliable temperature control. Even if the hot plate control works away from the heating element, the observed 30F swing seems a bit much (should I dare test my kitchen oven?).* A thermocouple, PID controller, and power relay would do the trick, but would add significant cost to the project. As it stands, the clay pot smoker cost around $80 (not including purchase of tools I needed to move the heating element and gas used driving around looking for parts). Quite a bit more than Alton Brown’s quoted price of $47.32, even adjusting for inflation.

* If I were to do this project again, I would forgo purchase of a grill thermometer. My remote digital probe thermometer worked just as well, if not better, and with it I was able to keep my head out of the smoke while checking temperature.

Asocial Bee

Posted in Fauna, Insects, Photography on January 24th, 2011 by Andrew – Comments Off

“Find your own flower, bub.”

News: Users Registration

Posted in News on January 23rd, 2011 by Andrew – Comments Off

The bots have won, at least for now. They’ve managed to defeat the CAPTCHA on user registration, so I’ve disabled registration. If you’re human, and you want to comment publicly on my posts, email me (see the About page), convince me you’re human, and I’ll create an account for you.