Programming with physics

Programming is the art of working out the logic needed to obtain some desired behavior from a system, such as a computer. I’m so used to achieving this with symbols, variables, and control keywords that it hadn’t really occurred to me that the same process has been used since long before computers were invented. Mechanical devices are “programmed” by specifying their physical design, and their behavior is “executed” with physics, not a CPU.

This came to me while I was reading a children’s book describing how a toaster works. What is the job of a toaster? To lie dormant until bread is inserted, then heat up for an appropriate amount of time, then automatically turn off and pop the toast up for easy removal. If I were going to create my own toaster, I’d go at it from a computer-logic perspective: acquire a sensor to measure the current toastiness of the bread (perhaps just its temperature), and then program a tiny embedded chip to respond when the sensor exceeds the desired threshold, at which point the toaster would send a command to the release lever so that the toast would be ejected. But is that how toasters are designed? No!

Toasters are a complete marvel of physics-based programming. There is no embedded chip, no logic to specify, no commands. Instead, the toaster relies on a bimetal bar, which bends to the left or right depending on the temperature, because its two metals expand at different rates. (I first encountered bimetallics when I asked my dad how our thermostat worked.) The same current that heats the toaster coils flows through this bimetal bar, and it gradually bends to the side, until it nudges the “heat-up lever” out of contact and instead engages the “cool-off lever”; as it cools back down and straightens, it then releases the cool-off lever which allows the spring-loaded release to pop the bread up.

Got that? There is no timer in your toaster! (Unless you have some new-fangled version that does in fact use a computer chip.) The timer effect is achieved by simple physics. This is an entirely different kind of programming which must have originally required a lot of trial and error: how long should the bimetal bar be? How thick? Which metals should be used, to get the right differential lengthening? And then there’s the clever puzzle of how to set up the system of levers so that the bending of the bar triggers them in the right order, purely mechanically.

I had always wondered why toasters don’t let you specify a toasting duration, instead of trying to figure out what a unitless dial that goes from 1 to 10 really means in terms of toastiness. Wikipedia relates that early toasters did have timers you manually set, but this caused problems because the first piece of toast needs longer than subsequent ones to achieve the same done-ness. Using the bimetal bar as a toast-proxy works better because it reflects the thermal properties of the heating elements and naturally adjusts the toasting time to fit.

This cleverness isn’t just about toasters: it’s alarm clocks and vending machines and cameras and all sorts of other devices. This kind of “programming” reminds me of dominoes: setting up all the pieces so that they fall into the right places at the right time. What contraints under which to operate! What an interesting development environment!

Maybe I’ve been living in the computer world for too long.

Next up: The transparent toaster.

Who reads this blog

StatPress is a WordPress plugin that tracks site visitors and which pages they visit. Over the past couple of months, I’ve learned that this site gets 1000+ visitors each month (not necessarily unique) plus about 5000 visits from spiders (!). On April 22, there were 474 visitors in a single day. Slow world news day, perhaps?

Who are these visitors, and what do they come to see?

In aggregate, visitors to this site use:

  • Operating system: Windows XP dominates the list, at about 50% of visits. It is followed by Mac OS X (17%), Windows Vista (15%), and Debian (9%). I’ve also had 3 visits from a BlackBerry, 1 from WebTV, and 1 from something called Symbian.
  • Browser: Firefox 3 handily tops the list (36%), followed by IE 6 (20%) and IE 7 (19%). Next is Iceweasel (9%), which is a rebranded version of Firefox.

It’s fascinating to browse the search terms people typed that led them to my blog. The ten most recent were:

  • what did i learn in psychology class
  • touch sensitive dimmer stuck on
  • what i learned today blog
  • touch lamp won’t turn off
  • Basketweave knit pattern
  • what I learned today
  • Reverse Corte
  • problems with touch lamps
  • indent négatif latex
  • how much baking powder to add?

And overall, the most visited pages are:

Any other favorites?

In addition to people-visits, this site also sees a lot of spiders. Interestingly, although referrals from google dominate all other search engines, I see many more spider visits from yahoo. Could it be that google has a more efficient spidering strategy, requiring fewer visits? Or yahoo is more fond of my site? We may never know. I also learned about search engines I’d never heard of, including Moreover, Naver (South Korea), Searchme (a “visual search engine” that just went offline today due to lack of venture capital), and Radian6.

Where my watts go

I like to conduct experiments and measure things. My monthly electricity bill tells me how many kilowatts I’m consuming, but not at a very interesting or useful granularity. Which devices consume the most? Where could I make the most impact, in terms of turning things off or putting them on timers? What I really want is the equivalent of top, but reporting electricity consumption instead of CPU usage, for all currently active processes (devices).

Since no such thing exists, I instead went out and bought a Kill A Watt, which monitors all consumption of anything that is plugged (through it) into the wall. This is a nifty device; not only does it give you instantaneous consumption, but it will also record the total usage over time. The packaging contained a bit of over-selling, though:

Perfect for detecting voltage drops and brownout conditions before they damage delicate equipment.

Perfect, that is, if you’re sitting there ready to yank it out of the wall if the line quality drops below 120 V. It doesn’t have any automatic shutoff or power surge protection.

Once I got the Kill A Watt, I went around the house plugging everything I could find into it. Here are some of the highlights of what I learned:

  • The largest instantaneous consumption comes from my microwave, at 1600 W.
  • I confirmed that CFLs really do consume less energy than incandescent bulbs. :)
  • My stereo uses about 40 W, whether playing the radio or playing a CD—and this amount increases with volume, as more power goes to the speakers. Same with the TV (a 19″ Samsung, 40 W, increases with volume).
  • My laptop consumes 2 W when sleeping, 27 W awake with low load, 36 W charging (asleep), and 60 W charging (awake). My wireless router consumes 14 W.
  • My front-loading high-efficiency washer uses 20 W when filling with water, 100 W when tumbling, and 460 W when spinning. The total consumption for one load is 0.14 kWh, which costs me all of 1.7 cents (not including the cost of the water).
  • My gas dryer uses 750 W when first heating (and tumbling), then settles into 260 W once it’s hot. One load consumes 0.17 kWh, or 2.1 cents (not including the cost of the gas).
  • Bottom line: I was surprised to realize that, based on this data, my biggest ongoing consumption might well be my dining room light fixture (2 75-W bulbs = 150 W), which has a dimmer switch and therefore isn’t amenable to regular CFLs. It might be worth the (more expensive) dimmer CFLs to address this, once the current bulbs burn out. However, my study was not comprehensive; I was unable to measure my fridge’s consumption, for example, nor do I have numbers for the oven, water heater, or air conditioner (which I know is a heavy consumer simply based on the seasonal change in my total bill). More study is merited!

Philip Torrone has posted instructions for how to convert your Kill A Watt into a Tweet-a-watt. That’s right, you can now tweet your consumption, for the edification of all. From the project description: “We feel there is a social imperative and joy in publishing one’s own daily KWH.” I’m content just sharing the preceding analysis, thanks!

Point a telescope without moving a thing

Radio telescopes allow us to listen in on distant sources and learn about fascinating objects such as pulsars, quasars, and even (maybe?) extraterrestrial civilizations. Directional antennas for these telescopes have greater sensitivity than omnidirectional antennas, but then they must be pointed in the appropriate direction. However, large telescopes can be prohibitively heavy. Arecibo, which at 300 meters wide is the largest dish in the world, doesn’t even try; it sits in a depression in the ground and lets the Earth’s rotation sweep it around on a daily basis. As a consequence, there are areas of the sky that it cannot study, and everything else can only be imaged for a short time each day. Other facilities such as Green Bank and the Deep Space Network use massive motors and gears to rotate their telescopes to reach other regions in the sky or to focus on a specific target for longer periods of time.

But why move if you don’t have to? Engineers have developed a clever way to simulate a directional antenna from a collection of smaller, stationary, omnidirectional ones. Given multiple antennas in a line, if you shift the phase of each one progressively more, then combine the signals together, the result is the same as if you had rotated a single larger antenna to point to the side. If you have the ability to digitally change the phase shift for each antenna, then you can “point” your array anywhere you like without moving anything physically. This is called “digital beamforming.” (Technically, beamforming permits the manipulation of both the phase and the amplitude of each component antenna’s signal.) The Allen Telescope Array in northern California is an example of an array that uses beamforming (e.g., to listen to the New Horizons spacecraft).

Even more exciting is the recent advance in adaptive digital beamforming. Here, each of the phase (and amplitude) shifts (weights) are modified on the fly to maximize the resulting signal quality. Apparently, some radio transmitters even send “training sequences” to help an adaptive receiver quickly identify the best weights to use.

Thanks to Toby Haynes for his excellent “Primer on Digital Beamforming,” which is both exceedingly accessible (even for those of us without a formal signal processing background) and satisfyingly detailed (with field strength diagrams for different antenna types and component diagrams for beamforming).

Women in Technology: Missions to Mars and Internet Identity

Yesterday was Ada Lovelace Day, accompanied by a large-scale blogging exercise in which people around the world blogged about women in technology they admire. Yesterday was also a rather busy day for me, so I’m writing my entry a day late. I’m sure Ada would understand.

There are volumes to say (and that have been written) about Ada herself. She was gifted in mathematics and reasoning, and developed the first computer programs — before any computers actually existed. (She was developing hypothetical programs for Babbage’s Analytical Engine, which didn’t exist either.) Today it is challenging enough to learn languages already developed for machines that anyone can use; imagine starting from less than scratch to accomplish computational magic!

I’d like to draw your attention to two women who’ve made more recent contributions to the field of computers and technology. The first is Donna Shirley, a key player in the JPL Pathfinder mission to Mars in 1997. She led the team that built the Sojourner rover, as chronicled in her enjoyable Managing Martians autobiography. She was a trailblazer for women in high-profile (and high-stress) mission positions, but also remarkable for her accomplishments regardless of gender. She flew airplanes, became an aeronautical engineer, worked on the Mariner 10 mission to Venus and Mercury, raised a daughter, and more. I recommend this fascinating interview with her from 1998. I had the opportunity to meet her years later, when I was interviewing for jobs with my shiny new Ph.D. in 2002. At the time, she was the Associate Dean of Engineering at the University of Oklahoma, and I had a wonderful lunch with her. I didn’t end up taking that job, and she moved on a year later to start her own speaking and consulting business to encourage innovation and creativity in tech fields. There’s so much more to say about her delightful personality and her passion about space and innovation. I encourage you to take a look at her book.

Another fascinating woman in technology is Sherry Turkle. Her background is in psychology, which she’s applied to good effect in analyzing the world of technology. She wrote a book called Life on the Screen: Identity in the Age of the Internet about how people interact with computers (and the Internet), and the effect that interaction has on us in return. What’s even more remarkable is that this book was published in 1995, when the Internet was still something of a foreign country that only a fraction of the population had visited. She has some very interesting things to say about identity in a virtual environment and the challenge involved in drawing a clear separating line between events in the “real” world and events that happen online. She’s put forth a host of other interesting ideas, including:

I love new ideas and thought-provoking inventions, regardless of the gender of their source. Ada Lovelace Day is a chance to put the spotlight on female contributors, with one goal being to combat the perception that tech advances are produced solely by men. So far, they’ve collected a phenomenal 1,112 posts by bloggers (men and women) about these ground-breaking possessors of double-X chromosomes. Go ahead and browse, as a list or a world map. So many of these were new to me!

« Newer entries · Older entries »