Thursday, December 11, 2008

How Do You SolveRepresent A Problem Like Mariaechanics?

First, this. (Explanation)

It would be cool to make something like that, but more general. A wider scope of problems, more construction elements, more universal attachments, etc.

The standard method of genetic programming is to represent your algorithm/whatever as a tree. The leaves are data and the nodes are operations that the "universe" supports. Then two parents producing a child via "sex" is just trading subbranches. Mutation is random changes.

That works for a linear sequence of steps because there's a standard way to traverse a tree. The question is, how do you represent a machine in a tree? It's (usually) not a linear thing.

Take a wheel and a stick. They are two leaves, I guess. The node is the operator "attach"? But where? I need to know where on the stick AND where on the wheel. And if the connection is rigid, floppy, powered or what. Where is all that knowledge stored? How can I "break out" each of those things to allow them to mutate separately? Also, you can't have a whole-organism coordinate system, for instance, because a single mutation messes it all up.

Another idea is to use an algorithm to build the machine and represent the algorithm as a tree. But what's the advantage of that? I didn't realize until this morning: This is exactly what embryology is. A machine isn't a linear object, but constructing a machine is a linear process.

So to attach a wheel and a stick, I'd have an embryology something like this:

1) Place stick
2) Locate end of stick
3) Locate center of wheel
4) Attach

Or maybe:

1) Place stick
2) Advertises marker at X
3) Locate marker
4) Locate center of wheel
5) Attach

The marker system would be key. If there's more than one stick in the structure, "locate end of stick" is ambiguous. Whereas if the stick knows that it is, say, the left shin, it can hang out cards saying "I'M THE LEFT SHIN" and "HERE IS MY LOWER EXTREMITY" and the wheel can look for that.

Could one of my graduate students get on this and give me credit so I become rich and famous but don't have to stop the N projects I'm working on to get it done? Kthx!

Monday, December 8, 2008

Invention Idea #3/Story Idea #1

It's the future. Computers are unimaginably fast. Like, 8th generation Pentium fast! We want to recreate an historical figure, let's say da Vinci. All we have are the collected works.

Step 1: Recreate da Vinci's environment as closely as possible as a computer simulation.
Step 2: Assign a good guess as to what da Vinci's genes would have been.
Step 3: Simulate his life.
Step 4: Compare the output of his simulated life with his real output.
Step 5: Mutate the DNA, keeping any improvements.
Step 6: Until simulation is "close enough", goto 3.
Step 7: Instantiate DNA as a real human.

If the environment were perfect, we could get arbitrarily close to the real da Vinci. And if we had even faster computers, we could get arbitrarily close to a perfect simulation of the environment (which I leave as an exercise for the reader).

I'm going to waive the ethical considerations of steps 3 and 7 in favor of linking here.

Wednesday, December 3, 2008


  • The biggest difficulty in making something like a Stirling engine without access to a machine shop is how to make the power piston. The piston has to be precisely sized to fit inside the cylinder. However, via a YouTube video, I have discovered that it is possible to use a pair of PVC pipes to get the same effect. I made one and under breath power it worked so well it nearly knocked my teeth out. I haven't done any real testing yet, so I don't have all the construction details worked out, but basically you just get two sizes that differ by 1/4" and sand down the smaller until it fits in the larger.

  • The way I'm going to test the piston is to build another Stirling. Need a bigger displacement chamber for a piston this big. Should be metal, not too thick-walled, largish, easy to make air-tight. A paint can would be perfect, except you don't want to combined leftover fumes and high heat. Turns out Lowe's sells empty paint cans! Quart- and pint-sized. That means you can even remove the lid to work on the innards and then reseal it.

  • What with one thing and another, the flywheel on the new engine has to be mounted differently. I need a whole crankshaft dealie (which is something else it would be easier to make with a machine shop). Once I realized this, I realized I'd also need some kind of bearing. Idly reading something completely unrelated, I came across a mention of "skate bearings". I was thinking inline skates, but skateboards have the same thing. They are only like $1 each! And I even had an unused skateboard at home, from which I harvested 8 of them. ID ~8mm, OD ~22mm. Cute as a bug's bearing.

  • I've had these drawing pencils for a while now. The leads are 2H, HB, 2B and then some high B one, I dunno what. The problem is you have to keep sharpening them like every 15 minutes. The other day I realized this is already a solved problem: mechanical pencils. The only question was, do they sell mechanical pencil leads in hardnesses other than HB? Answer: Yes. So now I have 3 mechanical pencils, each with a different lead. Makes drawing so much less of a hassle. Can't shade with the side of the lead, of course, but I never did that anyway.

  • I'm not going to meet my Xmas diet goal. Scale is still going down, but too slowly to make it in time. Maybe I should aim for the secondary goal (an additional 10 lbs) at the 2 year mark (March?).

Monday, December 1, 2008

Invention Idea #2

Red increases the pulse and heart rate, and raises your blood pressure. It increases the appetite by increasing your metabolism, which is why red is such a popular color in restaurants.
("color red metabolism" gets hits mainly for People Magazine-level science info, so I don't know how well-established or bunked this is.)

The office across the hall from me just got "natural sunshine" fluorescent bulbs put in. They are much whiter than the regular bulbs, which are reddish-orange. It is causing me to wonder what effect constant immersion in red light is having on office workers. Obesity? Or is the above effect only a differential one? Has this even been studied?

Anyway, my invention: blue-tinted "diet" sunglasses.

Thursday, November 20, 2008

Invention Idea #1

My kids go to school and (probably) never wash their hands. I imagine 90% of the colds I get started their path to my nose on some doorknob there. How can we sterilize children more effectively?

I thought about blasting them with ultraviolet, but that leaves them leathery and tough. Good for character but hard to chew. How about just blasting doorknobs (and the like) with UV? How would you mount such a light to reach all the crevices? Well, you could make the knob out of glass and mount the light inside.

But it turns out you need a minutes-long exposure to kill bacteria with UV. And glass blocks it anyway. And even if it didn't, it would still be shining out into the room and eyes of students.

However, I just recently came up with another solution: Ultrasound. So a kid grabs a knob and leaves germs behind. He lets go. A sensor notes this and gives a brief blast of ultrasound, dismembering any organics. The next kid grabs and she doesn't pick up the nasties.

Google says this works, but talks about being immersed in liquid. Maybe that can be worked around. Or a gel coating on the knob. Or fill the school with water and equip the kids with scuba gear.

Monday, November 17, 2008

Magic Smoke and Mirrors

The task is very simple. I have a solar tracker. I have a microcontroller that knows what direction the tracker should be pointing. I have a cordless drill that I've taken apart to do the actual work. So why is it taking me WEEKS AND WEEKS to get this working? I can't even turn the drill on yet, at least not without threat of releasing the magic smoke.

It should be extremely simple. Here is how a drill works.

OK, so it should be easy to just replace the human-operated switch with a microcontroller-operated one.

The microcontroller replaces the human and relay replaces the switch. It's a high-amp relay because on the very first magic smoke release test I found that the drill draws 20 amps (or more!). It's also a 15V battery, so I managed to remember the resistance of the motor as being .7 ohms which makes the V=IR math work out.

However, when I almost melted my entire apparatus on the second test I realized that the motor is only about .1 ohms. How on earth can I be feeding 15V to .1 ohms and only drawing 20 amps? Including a current-limiting resistor doesn't improve things much, since it just wastes a bunch of power getting really, really hot. After a little thought, I decided to actually look at the drill switch. I can't get it open, but I was able to confirm this much:

I don't know how, but that magic box is somehow limiting the current. One thing I can see in there is a transistor, which could definitely do the job....except it would have to be awfully high power to handle 20 amps. Or maybe it isn't? Maybe the 20 was transient and it normally feeds more like 2-3 amps? No idea. Which leads me to think maybe I need to give up and do something like this:

Which is stupid. If I knew how it worked, I could probably hook the microcontroller directly to the magic box and forego all my rubegoldbergian relay stuff (which should be a post on it's own...). It's also annoying that I know this can't be an unsolved problem. But I must not be thinking of the right keywords to find the solution.

Friday, October 17, 2008

"School Tools"? "TooLibrary"?

Statement of Problem

I don't have the tools I want. Nobody I know has the tools I want. I don't have the money to buy the tools I want. And even if I did have the money, I don't have space for the tools I want. (The tools I'm thinking of are machine tools, such as a lathe, milling machine, etc. But it could also apply to automotive, woodworking, electronics and other things.)

Proposed Solution

I know I've seen at least a couple of businesses on this concept, but I can only find one now: TechShop. It's like an gym, but for tools. You pay a membership fee and you can go use their space, stuff and expertise. (For a more non-profitish take, there's also the MIT Hobbyshop.)

Of course, one could argue that if you are paying even as low as a mere $20/month (TechShop's actual lowest price is $100/month), you'd eventually be paying more than if you bought the equipment yourself. However, you still gain these advantages:

  • lower startup cost - Instead of having to save up $N to buy the next tool, I immediately have access to all of them after the first membership fee.
  • access to specialty tools - It would probably be pretty rare for me to need 5 axis CNC milling machine. But when that's the only thing that will work, it would be nice to have it.
  • access to experts/help - This is either someone that works at the shop and gives classes or just the other users. Synergy, people.
  • space - Unless I start throwing out family heirlooms, I'm not fitting more than one more power tool in the workshop.
However: Statement of New Problem

Places like TechShop tend to be in locations of high population concentration, particularly of a high-tech nature. The Bay Area. Research Triangle Park. And even at that there still isn't (or going to be) one in Boston. Plus $100/month is pretty expensive. The MIT Hobbyshop is only available to MIT students, faculty and staff. Other restrictions apply, void where prohibited.

Proposed New Solution

Almost every town, no matter how tiny, already has a high school with a shop. Some of them also have area vo-tech type schools. This is space that is already set up to

  1. teach
  2. a large group
  3. of complete n00bs
  4. to get immediate results
That's perfect, right?

Of course, you can't go during the school day. But nights, weekends and summers are plenty. This is especially true if you imagine where you might be storing your half-completed project. If it's something big, you might store it at the shop and then you are locked out when they are closed. But if it's small, you can work on it at home with what you have, then bring it to the shop during open hours. (Other hours possibilities would be just weekends, twice a week, etc.)

Another potential issue is whether insurance restrictions or byzantine school regulations would prohibit this. Apparently not, at least in my state. I thought of this idea when I saw the courses offered at my local high school. No shop classes, but according to the coordinator they have done so in the past. These are 8 one-evening-a-week sessions, generally. So you'd really need to just need to extend the class "indefinitely" and done. (I don't know how the instructors for these classes are chosen and/or paid. Maybe they are volunteers? Maybe they get some portion of the proceeds?)

Then we come to the little matter of the bill. How much would this cost? Here's where I think this plan could really work. The tools, space and (some of) the personnel are already paid for! It's part of the school district funding. The venture doesn't have to pay for the entire cost of everything, only for the marginal cost of expanding the hours. That marginal cost isn't zero, but neither would the membership fee.

Just throwing random numbers around: Shop classrooms are typically set up for about 10 students at a time, so let's call that a max nightly number. Let's also say the place is open twice a week and every member wants to attend on average twice a month. That's 8-9 open nights per month or 80-90 person-nights. So the entire membership could be 40-45. That also seems like a reasonable number of interested people living within a radius of a given high school. If each one is paying $20/month, that's around $10k/yr. Not a huge amount of income for the school, but perhaps enough to pay for itself? Some of the 8 week classes are listed at $100, so maybe $50/month is more reasonable.

Of course, I would be remiss in mentioning only the financial side. For instance, book libraries were not actually started purely as a cost-cutting measure, although they serve that function. They were started as an educational measure. Even if I'm well-educated myself, it makes sense for me (in terms of enlightened self-interest) to pay for the education of others. That's because the society I'm in will be better overall, including near me, if everyone else is smarter. If you consider knowledge a mental tool, then my idea is simply an extension of this.

Friday, October 10, 2008

Go Is A Game Of One Network

Both videos are amazing but imagine a gaming server using the technology from the second one (chess is demo'd at the end). Go stones would cast even less shadow than the chess pieces do. The only problem is that projectors aren't household technology. Although maybe you could use an LCD screen laid flat as your board?

Thursday, October 9, 2008


  • I've been working on various projects but none of them is to the point of being documentable. But I feel like I should update my blog so it doesn't look like I'm dead. I am. I'm a Montharian. (For explanation of this and the post title, see next item)

  • I'm "reading" Anathem and it's really great so far. I "read" The Name of the Rose a few months ago and had the idea of scientific monastics then, so I'm a little cheesed off that Stephenson beat me to the punch (not that I was going to write a book, but now I can't talk about how cool it would be without sounding like a fanboi). I've seen some complaints about the made-up words, but I don't think that's really fair. For one thing, a lot of the words like "fraa" and "reticule" aren't made up, they are just less common. For another, shut up.

  • Is it just me, or is the YouTube subscription system completely broken? My concept of that list on the front page is that they are supposed to be new, unwatched videos from my subscription list. Instead, they seem to show a random selection of new videos from my subscription list, watched or unwatched, and only one from each subscription. So if, say, New Scientist puts out 3 videos in between visits, I only see the latest one. Why isn't it more like an RSS feed? Or maybe I should use an RSS feed for it?

  • Weight loss is still on track to reach my goal by Christmas. I'm such a dork I even wrote a program to calculate some stats, including what day my current trend will have me finishing at. 12/24/2008 so far.

  • One of the projects I'm not ready to post about yet involves some electronics running outside. I wasn't comfortable having it plugged in, so I went with a large, rechargeable battery. After getting everything working, I realized
    1. The motors weren't powerful enough
    2. but they were still drawing too much power to allow the battery to last very long
    3. and I bet the battery won't work well in the cold
    Sooo....yeah. Back to the drawing board for at least part of that.

Tuesday, September 16, 2008


  • I cracked 50 lb of weight loss today. I'm still on track (±ε) to reach my original goal by Christmas. It also happens to be, as of yesterday, 10 lbs in 100 days, or almost exactly 350 calories/day.
  • Pursuant to that, I have made a breakthrough in food reduction technology. One of my favorite meals is...undocumented on this site?! WHAT. Anyway, it involves guacamole. The problem I've had is that I need to make enough to use up an entire avocado, which now that my metamabolism needs fewer calories is a little too much. Avocado turns brown if you look at it funny, so I can't put the excess in the fridge. I also can't throw it away because of the starving children in Africa. However, it turns out to freeze just fine. So now I can make M/Nths of a recipe which not only vastly reduces the hit points but also means I only use M avocados every N days.
  • I'm trying to embed a microcontroller into a project that I'll describe more later. All I know is Arduino, so I'm going with that. (I guess I could just use the Atmega chip or however that works, but baby steps, people.) The basic Arduino is a little unwieldy for this, but last night I finished soldering and testing the Really Bare Bones Board. And besides being much smaller and breadboard-compatible, it's also much cheaper because it pushes some of the cost of the unit into a one-time-purchase cable.
  • Number One Son, age 9, is trollering me. He just found out about HTML and has made a couple of pages. (With random size changes and font colors, naturally.) He keeps calling the .html file a "program".

Wednesday, September 10, 2008

New Control Structure Considered Useful

We have a large data processing problem at work. Basically, we get thousands of items every day and have to figure out which ones go together. The only way to know if they go together is to try them. Some items may not go with anything, some may fit with a hundred or more other items. The one nice thing is that once we've found 3-5 items that go together, we can zip through all the other members of the group.

The problem is finding those 3-5 items. Choosing every possible combination of 5 would take too long. Choosing every combination of 3 is fast enough, but leaves a lot of extras. The simple solution is to first try all the combos of 3, then try all the combos of 4 on the remainder, then try all the combos of 5 on the remainder of that. The smaller and smaller pile makes the larger and larger choices feasible.

My boss, who is a competent practical programmer, suggests we have 3 procedures: One that does a 3 nested loop, one that does a 4, and one that does a 5. Like this (in Tcl):

set items {apple orange banana grape strawberry}
set count 5

for {set i 0} {$i < $count} {incr i} {
    for {set j [expr $i + 1]} {$j < $count} {incr j} {
       for {set k [expr $j + 1]} {$k < $count} {incr k} {
         set string [lindex $items $i]
         lappend string [lindex $items $j]
         lappend string [lindex $items $k]
         puts $string

That's just the 3 level loop because the other two look almost the same. The 4 and 5 level loops are identical except for having additional levels. As a programmer who values elegance over readability, the phrase "identical except for" is a red flag. Why have 3 separate procedures when all you are adjusting is a single parameter? What I need is a new control structure that is basically a for loop but lets me control how many nested fors there are.

Tcl makes it easy to create new control structures. Here's the control structure definition:

# Usage:
#  indexcount - how many items are being chosen
#  itemcount  - how many items are being chosen from
#  indexvar   - variable to hold current combination of indexes
#  body       - code to execute for each combination
proc chooseloop {indexcount itemcount indexvar body} {

    if {$indexcount > $itemcount} { 
      error "More indexes than items"

    if {$indexcount == 0} { return }

    set indexes {}
    for {set i 0} {$i < $indexcount} {incr i} {
       lappend indexes $i

    set maxindexval [expr $itemcount - 1]

    while {1} {
       # make new body that sets indexvar first
       set newbody "set $indexvar {$indexes}\n$body"

       # do this iteration
       uplevel 1 [list eval $newbody]

       # find incrementable index
       set found no
       for {set i 0} {$i < $indexcount} {incr i} {
          set index [lindex $indexes end-$i]
          set thismax [expr $maxindexval - $i]
          if {$index < $thismax} {
             set found yes

       if {!$found} { break }

       # increment this index and set all following ones
       set incrindex [expr ($indexcount - 1) - $i]
       set precedingval [lindex $indexes $incrindex]
       for {set j $incrindex} {$j < $indexcount} {incr j} {
          lset indexes $j [expr $precedingval + 1]
          set precedingval [lindex $indexes $j]

Now to get my 3 level loop, I can call like this:

chooseloop 3 5 indexes {
    set str ""
    foreach index $indexes {
       append str "[lindex $items $index] "
    puts $str

In order to do 3, then 4, then 5, I can call like this:

for {set i 3} {$i < 6} {incr i} {
    chooseloop $i 5 indexes {
       set str ""
       foreach index $indexes {
          append str "[lindex $items $index] "
       puts $str
    puts "--"

The output of that last one is:

apple orange banana 
apple orange grape 
apple orange strawberry 
apple banana grape 
apple banana strawberry 
apple grape strawberry 
orange banana grape 
orange banana strawberry 
orange grape strawberry 
banana grape strawberry 
apple orange banana grape 
apple orange banana strawberry 
apple orange grape strawberry 
apple banana grape strawberry 
orange banana grape strawberry 
apple orange banana grape strawberry 

Monday, August 18, 2008

Forming Acrylic Mirror

I think all this information exists in previous entries, but it's nice to have all my knowledge, however little that is, dumped into one spot.

Heat forming acrylic (aka plexiglass) is pretty simple. Just get the temperature up around 220°F and it's pliable. I put it into the kitchen oven. Don't rely on the oven temperature, though, use something with a probe to tell if you've got the real temp. For one thing, you can put the probe right down where the mirror is, not just floating around in the air inside the oven. Also, when I was researching this I found some warnings about fumes. I think that's only if you overheat because I never smelled or sensed anything. Maybe I've silently shortened my life by 20 years.

I tried a couple different methods of using a form. The first couple tries were "open-faced," meaning I laid the acrylic on top of something and counted on the weight of the material itself to cause it to sag into the form. It isn't really heavy enough for that, so I moved to a two-part form. It takes longer to heat that way because of the mass of the form itself. Another disadvantage of this method is that you have to be able to force the mirror into shape before you heat it, which means no 2D curves (like a bowl, if you see what I mean). Actually, you probably could do that by putting the acrylic sheet between the halves of the form and then weighing the top part down. Like the open-faced method, but with extra weight. Drill a hole in the form so the temp probe can sit right on the acrylic.

The above should give pretty nicely formed acrylic sheet even in complex shapes. Unfortunately it's totally unworkable for acrylic mirror. I'm not sure if it's the acrylic or the mirror backing, but the heat stresses the material such that you don't get a smooth reflection anymore. For a while I thought it was imperfections in the form, but various experiments ruled that out. (You can get bumps and ridges from a rough form, though, which can be eliminated by loosening the form a little or by lining the form with some kind of bumper material. I used a sliced up silicone baking sheet.)

Also: I never got far enough to have this problem, but eventually you'll run out of space in the oven. Multi-part forms? Some other heating method?

The curve I wanted wasn't 2D, so how about cold forming (aka "bending")? I have not yet determined the point at which the acrylic cracks or deforms. I haven't even determined if there's some point short of complete destruction where the mirror breaks down, a la the heat deformation. It seems to be pretty sturdy and stable, but then I'm not making tiny radius curves. If you imagine bending a yard stick, that's about what it seems like, or maybe a little stiffer. Put another way: I have a square of acrylic mirror that's 2'x2' bent into a curve about the same as the side of a 55 gallon drum and I haven't see any problems with it. (This is the 1/8" thick stuff. There's also a 1/4" thick stuff that I've never tried.)

The trick with cold forming is that you have to hold it in place somehow. Even drilling a hole through the acrylic will deform it, although only in the immediate area surrounding the hole. I started with a sandwich method--cutting two parts and then cramming the mirror between. That works, but you have to have some method of securing the bread of the sandwich that doesn't involve drilling through the mirror. Also, you cover up some portion of the mirror surface.

Of course, you can drill through the mirror, but in that case why even have the top piece of bread? That's what I switched to: Put the mirror on an open-faced form and drill a few well-placed holes to secure it down. Don't overtighten, because the force isn't distributed over a wide area like with the sandwich, so the local area can get quite deformed. Maybe a reason to have the top piece of bread after all. Or maybe just some rubber washers or silicone baking sheet for padding.

You can't get too fancy with this method, but for a single, relatively gentle curve it works great.

Wednesday, August 13, 2008

Massively Unparalyzed

  • I think I'm out of the summer diet doldrums. I suddenly realized that if I stayed focused, I could meet my original goal by Christmas. I have to lose 1 lb every 10 days, which seems pretty reasonable. That's just ~350 calories/day. This is the same rate my overall history has been up til now, so as long as I keep, or *cough* get back on, that average I should be good. (I say "original goal" because after I meet that goal I think I'm going to go an additional 10 lbs. But I'll have to see how things stand when I get there.)

  • I needed to sense sunlight vs shadow and I'd read somewhere you can do that using an LED somehow. I got that working but they aren't made for that and so it didn't meet even the low standards of this application. Some photoresistors, even at RadioShack's redonk prices, were only $3 and work so much better.

  • Also needed, or at least wanted to evaluate, pulleys. McMaster-Carr's site is so awesome, why can't my local hardware store (or even Lowe's) have a website like that? Or McMaster-Carr have an outlet near me.

    That said, my local hardware store fits an amazing depth and breadth of stuff into their store. I don't think there's been a single thing I couldn't find there that I was able to find at Lowe's, in the fields the LHS covers. (i.e. they don't sell appliances at all, so obviously they have a smaller selection of dishwashers.) And the reverse is not true--I've found things at the LHS that Lowe's didn't have. And they manage to fit all this stuff into an area that's probably literally no larger than the area devoted to just cash registers at Lowe's. Like, how is it possible that my LHS has a 9 ft2 caribiners + pulleys display right next to the pumps I need (though are still more than I want to pay)?

    Oh and the staff actually know where things are and how to use them, unlike at Lowe's.

    I guess what I'm saying is, local hardware store:Lowe's::small European country:US. It may be a little more expensive, but the service and selection are great.

  • How can I completely waterproof a wooden structure? How about sunproofing? Like, is it going to get baked and shrunken on one side? Probably somebody already knows all this stuff. No wonder people just build with metal. Oh wait, how about PVC? Does that degrade in the sun? Oh and it's hollow, so you can put wires in there....HMMMMM

  • I was going to have an entry in here talking about all the things I suddenly (as of this morning!) have to do, but I can't even spend time enumerating them!

Monday, August 4, 2008

Paralyzed by Obstacles (i.e. whining)

(throughout this entry substitute "can't find at a reasonable price" for "can't find" and "free or under $40" for "reasonable price")

The next stage in the parabolic solar collector thing is to have the fluid circulating. I want to have it run through the collector, then down a hose into a tub of water and then back. Measuring the heating rate of the water will give me a better value for the power.

For this, I clearly need a pump. And can I find a pump? Clearly not. For simplicity, I think I want one that has garden hose fittings on both ends. Sump pumps usually have that on one end, but the other end doesn't have any fitting at all. (Maybe I could disassemble one to find out, but I can't find any to do that with either.) I bought a drill pump for like $6 but it was too wimpy to be useful.

Not that it has to be that powerful. According to the back of my envelope, I only need about 60 gph in the worst case. Typical sump pump numbers are 10x that. I could probably do it myself by putting a squeezable diaphragm inline and stomping on it. What a lot of work, though.

But I have feelers out on craigslist and freecycle, so in the meantime how about something else? I know, I can try to make a much larger stirling. What'll I use for the piston? Oooh, brill idea: a cut off bike pump!

Take 2: And can I find a pump? Clearly not.

Maybe I'm just too cheap. Or maybe I haven't figured out the right workaround. Or maybe I'm asking for too much. All of these questions (plus a couple other things I'm stopped on but aren't worth describing) has my brain in vapor lock. I am unable to move on anything.

Saturday, July 19, 2008

Stirling Walking Beam

I made a Stirling engine before, but it wasn't "real" in the sense of "having traditional engine parts, like a flywheel and crankshaft". Also, it would be pretty difficult to scale that one up or extract power from it as is. So this is my first regular ENGINE engine. (This is called a "walking beam" engine--many other configurations are possible.)

One reason I built this one was to prove to myself that I really understood how they worked. For that reason, I designed this all myself. Not that there's SO MUCH there. Also, there are tons of videos on YouTube that are identical to mine.

It's be really awesome to scale this up. Like with an oil drum for the displacer cylinder. I'd start that right away, except not only do I not have an oil drum, I'd need access to machine tools to make the power cylinder.


  • With the power piston shaft and displacer piston shaft mounted on the same point, getting distances right is a little tricky. It's a big parallelogram this way. Make them separate next time. Maybe even on a rotating collar so the phase angle between can be modified.
  • If the shaft tiepoints have a lot of play in them, the engine works jerkily if at all (because all the motion is taken up in using the play).
  • I think I overdid it on the height and underdid it on the width. Could have used a little angle-reducing distance on the piston shaft. Alternatively, shorten the stroke.
  • The flywheel is a little heavy. The momentum should carry it through the compression stroke, it shouldn't have to be barely sucked in.

Tuesday, July 8, 2008

New Results

Latest solar trough configuration:

A few details:

  1. Those are just simple, band-sawn parabolic arches. The mirror is attached with velcro. Works awesome. Ly.
  2. I suspended the mirror from the pipe thinking that would keep the focal length constant while allowing simples changes of elevation. Why do I always go straight for the complicatedest solution in the universe?
And data from same:

The highest temp on there is almost 140°C. That's over 280°F. According to my rough calculations, the four steepest upward slopes indicate powers in the range of 20-25 watts. (Some of those dropouts are me messing around with the setup, some are cloud cover. Also, I later discovered that true solar south is like 15 or 20° east of where I've been pointing.)

Two big changes from the last run, other than the already-mentioned one of shortening the excess pipe.

  1. Painted the pipe flat black.
  2. Used a laser pointer to adjust the focus. I mounted a frosted glass square (I happen to have a bunch I bought for just such a use as this) at what I thought would be the focal length. Then I stood back and aimed the laser pointer in a roughly perpendicular way and looked where the point fell. This really needs a System to keep it perpendicular, but anyway I was able to determine that my focus was off by over an inch.
I'm thinking the Mark III will be the last iteration. Pointing in the right direction, and simplifying the pointing a little, may let me add another 10-20 degrees to the peak but that will be about as far as I can go with these simple materials and using an open-air design.

Friday, June 27, 2008

Belated Mirror Squeezer Results

I did one "live" run of data collection from the parabolic mirror squeezer, but after I did it I realized there was a major problem. The pipe was much longer than the mirror width, so it overhung. Too late, I realized that this meant there was unheated oil in there, making the temperature measurement invalid. And I don't even know what direction the error was worse in, since the overhang could also act as cooling fins. Anyway, here's the graph of the results:

It looks very similar to the original run in a hotbox:

One major difference: Check the x-axis. The parabola run is at least 4x steeper.

Anyway, if I get some sun this weekend I should be able to re-run with more accurate results.

Tuesday, June 17, 2008


  • The diet hit a plateau. I'm down by 43 lbs from when I started, but in the last 30 days it's only changed by .5 lb. Looking at the chart from a year ago, I think I see a pattern. It was going down very slowly in May/June 2007, too. Looks like maybe 3 lbs in 60 days.

    There's probably two things going on. First, every year I imagine early summer weight loss should be easy. "Winter hibernation pounds just melt away naturally!" Second, a lot of good, fresh food shows up at the store.

  • I used to listen to Pandora at work. The advertised feature, discovery and laser(ish) targetting of your tastes, worked great. The problem was that the selection wasn't so great. I was down to about 30 songs that they just endlessly looped for me. Then I switched to The targetting isn't very good, but the selection is pretty huge. Exhibit A probably says more about how out of the loop I am for just now finding this, but still: Pretty hilarious (Lyrics)

  • And speaking of nerds: Do you like math? Do you also like mechanical devices? Then you will probably love How Round Is Your Circle. It's filled with mechanical ways to make, or approximate, mathematical functions, such as for linkages. The main problem with the book is that it's too short. It should really be a set of volumes so he can better explain each item. (Video teasers).

  • I have dismantled and cannibalized the Squeezer for a much simpler version of a parabolic trough now in production. Stay tuned!

Friday, June 6, 2008

Speaking Of Things That Don't Work

My house is crammed with computers, but only two of them (mine and Mrs Username's) are connected to the internet. Which means the kids always want to use them to play games.

The basement is wired, so last night I finally got around to hooking one up. It's got some version of Windows on there and already has a network card, so it should be easy, right? Drivers?? I don't even know what the card is! Not to mention the fact that I'm not too comfortable putting a Windows machine on the internet.

Then I get a crazy idea: I'll make it dual boot Ubuntu1! Takes me 45 minutes to download the latest disc, i.e. less time than it would have to identify, locate, download and install a NIC driver. Completely easy to install: Other than the fact that I had to adjust a slider to say how much room to leave for the existing Windows partition, I didn't have to tell it anything at all. It even got on the internet all by itself to download updates.

The question is: Is making my kids dual boot into Linux to play games child abuse or child undangerment? Either way, it certainly builds character.

1Actually, Xubuntu, because this is an older machine. I considered Edubuntu, but I think I'll go with the small, fast one and then add kid-oriented packages.

Monday, June 2, 2008

Things That Don't Work vs Things That Do

I've never been completely happy with my temperature logger. It's a bit fragile in the sense that if anything at all goes wrong, and there's no way to tell that at the time, I lose the entire run. I lost a run Memorial Day weekend.

Instead of storing the measurements on the Arduino, I'd like to instantly beam them onto my computer far inside the safety of the house. That way I can track things realtime as well as be assured that I have them. Coincidentally, for my birthday, I got both another Arduino1 and Making Things Talk.

The book describes a great number of schemes to make microcontrollers talk to each other and to computers. You can use wireless networking, bluetooth, XBee, etc (I have only the vaguest notion what some of these are). Naturally the easiest protocols require the most expensive hardware. I only need one way, slow communication, so I got a simple RF module.


It works just like a serial port! Just connect the transmitter to the TX pin and the receiver to the RX pin! It Just Works(tm)!



Perhaps my unit was faulty. I found many tutorials and guides across the internets and while results varies, I can't ever really say it worked. I did see data appear for a short time, but mainly what I saw was noise. Or nothing at all, which is even less explicable.

Last night I had a brainwave. Or brainstorm. Something happened to my brain and it resulted in an idea. Why not use a wireless laptop as the go between? The kids have these OLPC dealies. The laptop has a USB port and does WiFi. I have a WiFi router (specifically purchased, used, to work with these laptops). About 30 minutes and 10 lines of Python later, I was reading values from /dev/ttyUSB0 and sending them out over a socket to my desktop to another 15 minutes and 20 lines of Python.

The guts of the entire scheme are already there. But with so much success so fast, I'd like to add features. For instance, instant graphing of values on both ends. A protocol so that the laptop knows if there's been an error and can tell me, out in the field. When I have more than one sensor, I'll need a way to indicate which sensor had what value. It'll be like a complete Science Sensing Station!

1If you are at all interested in robots, sensors, controlling stuff with computers, electronics or just plain messing around, I highly recommend the Arduino. That SparkFun item is all you need, assuming you have a USB port (and possibly a cable). may also need some external electronics, depending on what you want to do. LEDs, resistors, motors, etc.

Thursday, May 22, 2008


Once I abandoned the dead end of heat-formed acrylic, the ideas for cold-forming have been coming thick and fast. Here's the result of the squeezer configuration.

First, the squeezer itself:

Closeup of squeezing mechanism:


Closeup of accuracy:

Soo....yeah. That works. The squeezer is a bit overbuilt. I could go with 2x2s or even smaller next time. And one bolt every couple feet instead of every 6 inches. Other minor improvements. Those may never be made, though, since I had a real brainstorm on an extremely simple way to accomplish the same thing. More on that another time, though. I'm going to use this for my next experiment.

Thursday, May 8, 2008


Last you heard I'd come up with an incredibly complex system for getting a perfect parabolic wood form that still failed to make a good parabolic mirror. I actually tried tweaking a couple variables after that. The main thing I realized was that the mating surfaces of the form don't press perpendicularly, which means there's a shear force on the mirror between them. As a padding and semi-lubrication, I put in some strips of silicone baking sheet but to no avail.

So I decided to abandon the heat-forming idea altogether. At this point, even if it worked I'd still have major problems implementing anything at a larger scale. Instead, I'm going with a cold, mechanical system based on the working-extremely-well nail system.

The first stab at a mechanical forming system looked like this:

The idea is that you just wind on some wingnuts to raise the tension and adjust the shape. And that actually worked pretty well to get the shape, modulo this being a first stab prototype. But the focus wasn't all that much better.

Finally, one might even say AT LONG LAST, the light dawned. I turned the mirror around and actually looked at it, searching for the distortions. Huh, they are right around those big holes I drill...OMG. The plexiglass just can't take the stress of the drill! I'm distorting the area around the hole! The oven is probably distorting the whole schmiel! That's why the nail version works so well. I'm just bending, not drilling or melting. What I need is some way of shaping into a parabola as non-destructively as possible. (I realize how obvious this sounds, but I didn't hear any Internet Geniuses suggesting it to me at the time, so bite me.)

Kind of fiddling around with it, I found that I didn't really need to shape the main body, so to speak, of the curve. Just pressing on the ends gave me a pretty good parabola. So, Mechanical Parabolic Mirror System Mark II:

Now winding on the wingnuts transmits compression to make the shape you want. I'm pretty sure that doesn't make a perfect parabola (I think it's actually a cubic curve, based on my skimming of some beam bending equations) but it's pretty damn close. Maybe not so close at full size, we'll see. If it needs more adjustment at larger sizes, I can add some tension non-destructively.

And how does it work, doctor?

Friday, April 18, 2008

Syringe Stirling

I just realized I've never done a post on Stirling engines. How can that be?? Stirling engines are so, so awesome.

Stirlings are a member of the class called "hot air engines". As a group, hot air engines work by exploiting the expansion and compression of a gas when it is alternately heated and cooled. There's a good explanation/animation here.

(That particular engine is a "true" Stirling because of those green cross-hatches. That's a "regenerator" that vastly improves efficiency. However, most people call all generic hot air engines, regenerator or not, "Stirlings".)

Stirling engines are awesome for a lot of reasons, but one of the best reasons is that you can use any source of heat. This isn't an internal combustion engine that can use only one type of fuel that's later impossible to wean away from. This is an external combustion engine. You could use natural gas or wood or ethanol or solar energy or geothermal energy. In fact, some satellites/probes use Stirlings to convert nuclear energy to electricity. That's right, Stirling engines in spaaaaace.

Anyway, back to Earth and me. Because Stirlings are so simple and efficient, you can make even a really crappy one run fairly well. They are very common first projects in machine tool classes, for instance, whereas building an IC engine from scratch would be...challenging for a beginner. However, I'm not even at the level of machine tool student, so even that option isn't open to me.

Fortunately, lots of people have been coming up with plans for engines that don't require machining. A few years ago, I tried one that used water-based pistons but I couldn't get it to run. I really have no idea what the problem was, probably multiple things. More recently, I found some "plans" for a test tube Stirling. It took me a while to actually get it going, because it turns out that glass syringes are incredibly finely made and also very rare nowadays. I actually had to buy one on ebay as an antique!

I think the functioning is clear enough to explain itself. (Note: This is technically not a Stirling since I have no regenerator, although I could stuff a bit of steel wool in there to fix that.)

After viewing the video again, actually that might not be so clear. Here's what is happening:

  1. Candle heats air inside left end of test tube.
  2. Air expands, pushing "piston" up.
  3. Marbles roll to the left, displacing the air to the right.
  4. Air cools down, contracting.
  5. Pulling piston down and causing marbles to roll right.
  6. Air displaces leftward.
  7. GOTO 1

Saturday, April 12, 2008

The Etching Calculator [EDIT]

A lot of things, many of them new to me, went into this project. We have "regular" programming, "device" programming, a communication protocol, stepper motor control, motor mounting, power supply design and the mathematics of drawing an optimal line on a pixelated display. Some comments on each.


I originally thought this was going to be the hardest part. "The rest is just sitting at my computer desk and either typing or handling tiny pieces of electronics" was my opinion. In fact, I just cut a couple spacers and then improvised mounting plates from....I don't know what that stuff is. It's like countertop covering. In any case, this part took maybe 45 minutes. It helps that one vital component of the mount is masking tape.

Connecting the steppers to the knobs went through some iterations. The motors had gears on the ends, but of course the EAS isn't geared. I tried various ways of coupling one to the other, but wasn't satisfied. (This turned out to be a power supply problem, which I talk about below, but I didn't know that at the time.) In the end I managed to remove the gears--they are just press fit, so you can knock them off with a nailset and a hammer. The shafts of both motors and the EAS were almost all the same size, which in turn was just a tiny bit bigger than the internal diameter of some plastic tubing. I just cut a short length as a sleeve and voila.

Stepper Motor Control

Physical Computing was invaluable. In fact, reading about how to control a stepper was what gave me the original idea of controlling an EAS1. (The guts of that section are online.) I originally tried to do the entire thing with totally generic components, i.e. plain transistors, but I soon gave that up. I unbent enough to use 2 dual H-bridges. Still generic, but you can't get them at Radio Shack (but what CAN you get at Radio Shack?). This compacts the wiring and anyway the motors need more current than a regular transistor can switch.

If this were a real product, I would definitely build/buy a stepper control board. Finer control isn't an issue, but sweet mother of crap this thing is loud. I think a board can ramp the amperage up and down to give a smoother movement that won't shake the house down.

"Device" Programming

The Arduino libraries include an object-oriented Stepper control library, but it wasn't really suited to what I was doing. The most basic fact it cared about was the RPM. The most basic fact I cared about was how many steps to take. So I wrote my own SingleStepper library. That makes me sound alphanerdy, but seriously, it was just a matter of copying and tweaking the existing library.

Another reason for writing my own was that the Stepper lib left the current on even when the motor wasn't turning. That's great if you need the torque to stay on, but non-great if you have a limited budget of amperage. So my library also turns the power on only long enough to move the motor, then turns it back off.

Communication Protocol

The stock Arduino serial comm library only supports reading a byte at a time. WTF ARDUINO ? Naturally I need to send coordinates larger than 255. The solution is conceptually not too difficult: Send a two-byte int a byte at a time and reassemble on the other end. This actually took a couple days to implement, though, because Python (on the other end of the wire) isn't geared towards working with binary data and then there's the question of negative numbers, twos complement, endianness, etc.

Also, in the case where a lot of coordinates are being generated very quickly, the internal buffer can overflow and the EAS goes haywire. So each coordinate has to be ACKed by the controller before the next is sent.

Line Drawing

Here's another place where I didn't go 100% from my own bootstraps. I actually did start deriving this myself, but soon realized that there were going to be special cases and stuff and I wasn't interested in debugging those. Instead, I just adapted a classic algorithm. I didn't use any of the optimizations on that page, since they are more for a digital display than position control. I did make one optimization of my own, though, which was to not move each motor a single step at a time if I could take 5 steps with one and then 1 with the other.

Theoretically, one could turn both motors on at the same time but at different rates to draw diagonal lines. But even if I had the electric power to do that it's just too hard to attempt.

"Regular" Programming

This is so dead simple that it's really not that interesting, but just for completeness: Generate a series of coordinates (either by hand typing in your own or using some equation) and send them out the serial port.

Actually, I should explain that a bit. I chose to implement this as a display-like device. You give it a coordinate pair X,Y and it moves there. The Arduino handles everything after being handed the values. So for instance the sine wave is being calculated as a series of points in Python on my computer and then sent over to the microcontroller for plotting.

Power Supply

Of these all, the one that I figured out last was the power. The EAS isn't really made with computer control in mind. The controls are surprisingly sticky. At first I thought the coupling between motor and EAS was slipping, but I eventually eliminated that. The power supply I bought is rated up to 1.5A, but only puts out 5V, so the motors only drew about 700mA. Turns out that wasn't quite enough to consistently turn the knobs. By bypassing the power supply, I was able to feed 1A directly to each motor (one at a time) and that was enough.

It may still be a little short, though, because I still get the occasional glitch. But I don't have a wall wart that puts out more than an amp at more than 8V.


The steppers I got out of a broken inkjet printer. (I really lucked out on that, I later realized. Two other inkjets I disassembled had steppers but they were tiny.) I already had the mounting stuff and the Arduino, as well as wires, resistors, etc. I had to buy the H-bridges, the power supply, a heatsink and some power resistors. That probably adds up to $20 or $25. But I can and will reuse it all, especially the power supply, which was the most expensive single purchase.

Oh yeah, and I had to buy an EAS. But one of my design goals (as well as an instruction from my seven year old) was to not alter it beyond being used by humans afterwards. So I consider that a capital investment as well.

1Gave me the idea, but I wasn't actually spurred to do anything until I saw the EAS clock. The auto-erase functionality of the clock would be really nice to have, but I'd like to point out that the ability to draw curves is even nicer.

Per request, here's a closeup of a diagonal line. You can't see the "pixels".

That said, you actually can see the "pixels" in some curves. I think that's because of the (mathemetical) stepping involved in going from floating math to integer.

Tuesday, April 1, 2008

The Future Was In 1956

tps12 has been doing 3D photos recently and pointed me to a pretty simple tutorial.

Where the magic happens (spoilers ahead):

This looked really mind-blowing in Gimp, pretty great as a jpeg and not so awesome online. Good ol' lossy compression!

Tuesday, March 25, 2008

Boring Diet Update

I'll have something much more exciting in a few days, I think. Well, exciting to a NERD. It involves motors and integers and wires.

A month ago, I mentioned my upcoming dietversary. Today is the last day of Year One. My Official Tally of Weight Lost is 38 lbs. That's an average of 2/3-3/4 of a lb per week.

I was half-heartedly shooting for 40 during the last few weeks, knowing I wouldn't make it. But I came pretty close and in the final weeks I doubled my average rate. Also, the Official Tally is based on a moving average, so my last actual weigh-ins have been at or close to exactly 40 lbs. All in all, not at all disappointing.

My original goal was 60 lbs, with a caveat that I may want to go 10 beyond that when I get there (I'm not sure I believe the BMI chart). So I've still got 6 to 9 months ahead of me at this rate. Perhaps by Christmas? Then again, I'm actually chowing on Easter candy as I type this...

Friday, March 14, 2008

Parabola Update

I didn't realize until just now how much as happened since the last update.

The final picture in that post shows the problem. Imperfect focus. My theory was that the parallel parabola issue preventing full closing of the two halves of the form. When I tried it, the halves definitely did fit better, but the resulting mirror acted the same. The next possible culprit was Shaky Hands Syndrome. You can't freehand a perfect cut on a bandsaw, even following a line.

So I came up with an elaborate procedure that would let us use a router.

I'm not going to describe every little nuance of this thing, because seriously, it is much more complicated than it looks. I'm just going to point out the main idea.

If you recall, when I hold the mirror in place with nails it works great. So my theory was that constraining a springy object was making it closely approximate a parabola. So I took another springy object (the tan stick thing on top of the paper) and bent it to fit a parabola printed on paper. Then we used that as a guide for a router.

When I clamped the mirror into the form, it looked really good. There was not a single gap anywhere. But the result is indistinguishable from the freehand versions.

To my eye, the star pattern of the imperfect version looks like it is coming from short sections that aren't agreeing with each other. Like a faceted mirror. That would be easy to explain from a freehand form, but this latest version destroys that theory, at least as far as the form is concerned.

Yesterday I realized that uneven bending could be the result of uneven heating. Maybe some areas of the mirror aren't quite getting up to temperature. I was going to heat the entire thing up by another 10 degrees, but I accidentally broke the form. (Uh could also be shrinkage or other heat-deformation. I might be doomed.)

Also, I just realized that bending acrylic must be a technique used in industry (and art?). I should google around to see what I find. (I did that before I started, but more from the point of view of parabolas and less from the point of view of general acrylic forming.) (Update: Heh. Sounds like this guy had the exact same problem I'm having, 40 years ago. (picture caption, 2nd paragraph))

It's also possible I'm being a perfectionist. I'm going to have a 1/2" copper pipe running where the focus is. As long as all the energy hits the pipe, it isn't vital that it be pinpoint focus. Still, it's annoying that a thrown-together-in-5-minutes nail version performs so much better. It seems like I must be missing some really simple thing.

I actually do have an entirely different approach in the back of my mind. No oven needed at all...

Thursday, March 13, 2008

The Heated Mouse

Not only do I work in the basement of my building and not only are there lots of computers (and thus lots of AC) but one of the AC vents is right above my desk. Oh and of course I sit still all day. So I get cold hands. More specifically, I get a cold mouse hand.

The obvious1 solution to this problem is a heated mouse. Google can tell you this isn't a new idea but google can't tell you where to actually buy one. The only place that sold them is now dead and in any case seems to have been a scam. People didn't get their shipments or they did but the contents either failed to work as heaters or failed to work as mice.

But this can't be complicated. USB is a powered connection, meaning that a mouse can get power from the computer. If it can draw enough, it can run a tiny heater. As a matter of fact, the USB spec says that a device can draw up to 500mA at 5V, which is 2.5 watts. That's not a lot of heat, but if you were holding it literally in the palm of your hand I thought it might be enough to ward off pneumonia.

USB optical mouse and resistance wire from hair dryer.

Entire inside of optical mouse, USB cable unplugged from board. Red/black are power, don't mess with the other wires (data).

(I really should have photographed this entire build, but I was feeling my way through and didn't want to waste time with a bunch of dead ends.)

The first thing was to get a USB optical mouse. USB for the power, optical to have plenty of space inside. I had one lying around. Then I needed a way to turn electricity to heat. Resistance wire out of a trashed hair dryer turned out to be perfect. Around 3" of wire (coiled length), coated with liquid insulation, provides ~20 ohms of resistance. That draws about 250mA, providing around 125mW of heat. (I stayed well below the spec just in case, plus the mouse itself needs 100mA, according to the label.)

The rest was just a bunch of boring details. How to keep the heater wire inside the mouse. How to attach the power to the coil. How to get the mouse back together. Thinking about safety. Like, am I going to burn down the building? I don't think so...

Does it work? I've got it plugged in right now and it's working great. Works fine as a mouse (didn't even have to reboot, even though I switched from PS/2 to USB) and as a heater (I switched because my hand was cold and now I'm comfy).

I'd say the only problem is that the heat is applied more towards the palm when it needs to be more towards the fingers. It works as-is, but maybe I could uncoil the resistance wire and spread it out a little more around the inside of the mouse to hit all the areas.

1To a dork.

Thursday, February 28, 2008

Weight Loss Milestones: Past, Present and Future


My time-weighted, moving-average BMI dropped below 30 on the 7th. Also, I had to buy a couple new pairs of pants several months ago.


The new pants are starting to feel a little loose too. And just this morning, I put my belt down another notch. To the last notch. It's a little bit too tight this way, but up a notch is way too loose. "Pants feel a little tight" is a good way to keep from snacking at work.


Looking at my log, I see that it will be a year on March 26. I've dropped 33 lb in that time. Since I need a short-term goal to really get me moving, I thought maybe I'd try to reach 40 lb (2/3 of my original long term goal) by the 25th, but I don't think that's really feasible.

Up until now, I've been short an average of ~350 calories/day. To lose 7 lb in 30 days I'd have to short myself ~800 calories/day. That doesn't sound too healthy. So I don't know what short term goal I can set myself.

Wednesday, February 13, 2008


A few weeks ago I was really proud of myself for figuring out how to make a binary clock with multiplexed outputs to save pins. Now I learn about charlieplexing and I'm agog. Simply agog.

One project I've been kind of wanting to make is an LED cube. To illustrate just how awesome charlieplexing is, look at how many output pins you'd need to drive an LED cube of a given size compared to the simple multiplexing I "invented".

Edge Length# LEDsReq. Multiplexed OutputsReq. Charlieplexed Outputs

So on the Arduino, where I think I have 12 ports to work with, I could either do a 3x3x3 cube the old and busted way or do a 5x5x5 cube the new hotness way. (Or maybe I have 18-19 ports, in which case it's still 3x3x3 the old way but now 6x6x6 the new way.) But how can you possibly control that many LEDs with so few ports? Read the instructable!

Or read this simplified summary: Basically, you set things up so that every port can be either positive or negative. Then attach your LEDs so that every possible combination of ports lights one up. (Remember that LEDs are one-way valves, so port A being positive with B negative can light one LED while reversing polarity can light another one. Just remember not to cross the streams.) "Every possible combination" of N ports is N *(N - 1), so with, say, 9 ports you can control 9 * 8 = 72 LEDs.

5x5x5 isn't enough to be a 3D display, though. But a larger cube could be decomposed into smaller cubes each controlled by a separate microcontroller. 10x10x10 is probably large enough to show some cool animation, although coordinating 8 microcontrollers might be a pain. Not to mention wiring up 1000 LEDs.

Wednesday, January 23, 2008

The Parable of the Parallel Parabola

OK,, I wish I'd been detailing every little step so I wouldn't have to regurgitate it all up in a huge mass. I'll try to make this short.

First of all, I used my calculation to make a simple parabolic reflector. I just plotted it out on graph paper and then set a few nails as guides to hold the mirror in place. This actually worked really well. (Even more surprising in light of how poorly the (first!) oven-formed one came out. More about which below.)

The one on the right has a black dot where I pre-calculated the focus to be, the one on the left is just a different focal length.

Now then. Having a single strip mounted with nails isn't that useful to me, so I want to mass produce these. Can't use the nail thing as a form since it'll just bend unevenly. I spent quite a few days trying to figure out how to make a jig that would cut a perfect parabola, but it was too hard (I still have some ideas on that, though, but that's another 2 or 3 posts). (And before you tell me, I know all about the T-square and string method of drawing one.) I eventually decided to just freehand follow a line.

So I had my shop assistant cut a parabola for me and I sandwiched the mirror in there. (My shop assistant is my father-in-law down the street who actually owns a bandsaw.)

(Other item of note: I originally wanted to have the mirror soften and sink down into shape, but that creates alignment problems. Instead I clamped the bendy strip cold. But that means it's hard to tell when I've reached temperature. So I put a probe down into the coldest part of the thing. The tip of the temperature probe is resting right on the mirror, so when that gets up to ~210°F, I can stick a fork in it. This takes like 2 hours--wood is a really great insulator, unfortunately.)

(Oh also: You can't see it, but there's a little alignment peg sticking out of the convex part of the form. There's a corresponding hole in the concave part so it can stick through. There's also a hole in the middle of each mirror. If I put each mirror on the peg, then after I'm done with all of them, I can line them up perfectly. So clev.)

The result: Not so great.

How could that possibly be? How could a few nails hastily thrown together at a few points make a better parabola than a careful, full-contact form?

Then a phrase floated up out of the darkness1. The curve parallel to a parabola is not another parabola. Just think about that for a minute. If you have a parabola and you want to make a curve parallel to it, you can't just take the same parabola and shift it up. Nor can you use some other parabola. (Read the gories yourself, it's pretty cool. If you like that sort of thing.)

So if you cut a parabolic form and sandwich it around a mirror, FOR EXAMPLE, then you are probably going to get the wrong shape because the two halves want to be parallel (i.e. separated by the thickness of the mirror) but can't. Wellity wellity wellity.

I took the equations in that paper and made a little program2 that would generate an SVG file of the shapes I wanted. Now I can take those back to my shop assistant and have him cut it out again.

(Note to anyone who actually reads this far, runs the program, examines the output and starts wondering: The curves aren't really all that different. I think the issue isn't so much that the curve is wrong, but that the poor alignment doesn't provide even pressure across the entire mirror. So it ends up wibbly-wobbly rather than smooth. Then again, the freehand wood parabola isn't all that smooth either, so maybe THAT'S the source of the error. The nail method at least creates a smooth curve, even if it isn't mathematically perfect.)

1I think it came from Practical Conic Sections, a really rip-roaring tale that I've been reading to the kids at bedtime. But seriously, it's very clear and pretty practical.



# p1 and p2 are parallel to the parabola, i.e. a constant distance
# away *along the normal to the parabola*.

# For a curve C with generated by the function y = f(x), the parallel
# curve C' is given parametrically by:

#                 y'
# X = x - k -------------
#           sqrt(1+(y')^2)
#                 1
# Y = y + k -------------
#           sqrt(1+(y')^2)

# where k is the distance of the parallel from the curve.

# For derivation, see "The Curve Parallel to a Parabola is not a
# Parabola" by F. Max Stein.

import math

print '<?xml version="1.0" standalone="no"?>'
print '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"'
print '"">'
print '<svg xmlns=""'
print '    width="8.5in" height="14in">'

focallength = 2.5
a = 1/(4.0 * focallength)
mirrorwidth = .125

vertoffset = 7
horizoffset = 2
phorizoffset = 2
prevx = 0
prevy = 0
pprevx = 0
pprevy = 0
first = True
x = -5.5
while x <= 5.5:
    y = a*x*x
    px = x - (mirrorwidth * 2 * a * x)/(math.sqrt(1 + (2*a*x)**2))
    py = y + (mirrorwidth * 1)/(math.sqrt(1 + (2*a*x)**2))
    if not first:
        print '<line x1="%.2fin" y1="%.2fin" x2="%.2fin" y2="%.2fin" style="stroke:black;stroke-width:2"/>' \
              % (prevy+horizoffset, prevx+vertoffset, y+horizoffset,x+vertoffset)
        print '<line x1="%.2fin" y1="%.2fin" x2="%.2fin" y2="%.2fin" style="stroke:red;stroke-width:2"/>' \
              % (pprevy+phorizoffset, pprevx+vertoffset, py+phorizoffset,px+vertoffset)
    prevx = x
    prevy = y
    pprevx = px
    pprevy = py
    x += .125
    first = False

print '</svg>'

Friday, January 11, 2008

Parabolae Foci

I keep having to solve this problem. It's not hard, but to "save time" I usually google it and find too much information and not enough explanation. Then I end up solving it myself. And it's so easy that each time I figure it out I'm like "there's no need to write this down--it's obvious BY INSPECTION". And then I forget it. So here it is:

Where is the focus of a parabola? Alternatively, what formula should I use to create a parabola with a given focus?

Take the equation y = ax2. Obviously the focus will be on the y-axis, but how far up? We know all the incoming rays will meet there, so let's choose a convenient one. A great choice is a ray that is turned by 90°. That is, it comes in vertically, hits the parabola, and heads towards the focus horizontally.

Since the angle of incidence equals the angle of reflection, the slope of the parabola at the point the ray hits is going to be 45°. (I spent like 20 minutes using gnuplot and the gimp trying to illustrate this before giving up. Just visualize it.) Where on a parabola is the slope 45°? Slope is also rise/run, so the the slope in the y = mx + b sense is 1. Where is the slope 1?

The equation was y = ax2. The instantaneous slope is the derivative, y' = 2ax. We want that to be 1.

2ax = 1
x = 1/2a

Substitute in to find out where on the y-axis this is.

y = ax2
y = a(1/2a)2
y = 1/4a

Now let's say I want to make a parabola with a focus that is 6 inches from the bottom of the curve.

1/4a = 6 inches
a = 1/24 inches

Therefore my equation in inches should be: y = .0416x2. (I think. Contradicting my claim about how easy this is is the fact that I actually got this wrong on paper, TWICE, before posting this.)

Monday, January 7, 2008


A non-blurry, curved mirror.

In my last post, I hypothesized the problem might be too much time spent in the oven, causing some kind of degradation. That prompted epicanis to wonder if the acrylic was oxidizing. That in turn made me actually take a close look at the failed samples (why I didn't already do this is a mystery).

The acrylic is actually fine in those failures. It's the mirror backing that cheesed out on me. What is the backing made of? Who knows! What do I do about it? I dunno!

Then I was coincidentally reading a book about polymer clay and it had a tip for firing: Put it in at a sub-firing temperature to evenly heat the item, then turn it up to actually harden it. And I was all: whoa. I know that the softening point for acrylic is around 230°F, but I've had to turn the oven up to 250°F to get the samples to bend. I've been chalking it up to oven imprecision and chemical composition variation. But I think the real issue is that the core of the mirror doesn't get hot enough until the outside is too hot.

So this time I put the whole apparatus (which I should have taken a pic of, sorry) inside the oven at 200°F until a probe told me it was more or less up to temp. Then I just cranked it up to 215°F and voila, it worked.

Now I need to do a bunch of these at once (or one large sheet)...

Wednesday, January 2, 2008

Your Favorite Geek Desk Toy Sucks

I've seen these binary clocks around the office. They are fairly cool, but they fail to please in one important way: Each decimal digit is represented separately. 14 seconds is represented as a binary 1 and a binary 4, rather than a binary 14. Granted, reading 6 bits depicting 0-59 seconds is a little harder than the 4 bits required for 0-9. But is ease of use really the primary concern of a binary clock?

MISSION: Build this clock the right way. Namely, 6 bits for the seconds, 6 bits for the minutes and 5 bits for the hour (or maybe 4 bits for the hour with 1 bit for AM/PM). (Another idea would be a straight-up 17 bits for the 86400 seconds in a day, but seriously.)

Now then. I know there are clock chips out there. And it is probably possible to do this using hardware only, say with a 555. But I'm a dumb programmer, so everything looks like a Turing-complete problem to me. Plus I already have an Arduino. So that's the medium of choice. Using an Arduino, some LEDs and resistors and pure force of will, I'm going to make this work.

But there's a problem already. My design calls for 17 LEDs. The Arduino only has 14 output ports1, 2 of which I can't use because they are special. The solution to this problem is multiplexing. The basic idea is that you use X/Y coordinates to address each LED, Battleship-style. So for MxN LEDs, you only need M+N ports.

Let's say I want to light up the LED labeled 0,0. I need to apply positive voltage to A (the left column) and negative to 1 (the bottom row). B and C should be low while 1 and 2 should be high to "push the wrong way" against the remaining diodes.

But now there's another problem. Let's say I want to light up both 0,0 and 2,2. I apply positive to A and C and negative to 1 and 3...and I get all four corners lit up. Long story short, it is also necessary to employ a spot of subterfuge. If I want 0,0 and 2,2 lit up, I have to do them one at a time, but switch back and forth so fast nobody's the wiser.

And finally, there's the little matter of the clock function itself. There isn't an API call for that exactly, but the underlying chip supports interrupts. I basically just copyandpasted the timer code from elsewhere and then added a long comment explaining it to myself, probably incorrectly.

Grainy video (the ticking is an amazingly coincidental loud clock in the same room):

Somewhat less grainy still shot:

The code:

#include <avr/interrupt.h>
#include <avr/io.h>

#define NUMPOS 6
#define NUMNEG 3

int pos[NUMPOS] = {9,8,7,6,5,4};
int neg[NUMNEG] = {12,11,10};

int i = 0;
int j = 0;
int k = 0;
int lastpos = 0;
int lastneg = 0;

int isr_counter = 0;
int oldsecond = 0;
volatile int second = 0;
int seconds = 0;
int minutes = 31;
int hours = 13;

   Here's how I think this works.  The Atmega168 clock runs at 16MHz.  
   The "prescaler" divides that down.  In this case, it clicks at 2MHz.  
   Each time it clicks, it increments at 8 bit register by 1.  The register
   overflows after 256 clicks.  That overflow is the interrupt we receive.

   2000000 clicks/second divided by 256 clicks/overflow = 7812.5 overflows/second.
   So if I could count 7812.5 overflows, I know a second has elapsed.  I can't
   find .5 of an overflow, so I should really use the /4 prescaler.  But 
   a) that uses more power and b) I can't figure out what bits to set to do that.  

ISR(TIMER2_OVF_vect) {
  if (isr_counter > 7811) {
    isr_counter = 0;

void SetupTimer2(){
  //Timer2 Settings: Timer Prescaler /8, mode 0
  //Timer clock = 16MHz/8 = 2Mhz or 0.5us
  //The /8 prescale gives us a good range to work with
  //so we just hard code this for now.
  TCCR2A = 0;
  TCCR2B = 0<<CS22 | 1<<CS21 | 0<<CS20;

  //Timer2 Overflow Interrupt Enable
  TIMSK2 = 1<<TOIE2;

  //load the timer

void setup() {
  for(i = 0; i<NUMPOS; i++) {
    pinMode(pos[i], OUTPUT);
  for(i = 0; i<NUMNEG; i++) {
    pinMode(neg[i], OUTPUT);

  for(i = 0; i<NUMPOS; i++) {
  for(i = 0; i<NUMNEG; i++) {

void showXY(int col, int row) {

  lastpos = row;
  lastneg = col;

void loop() {
  // time changed, so readjust all the details
  if (oldsecond != second) {
    if (second > 59) {
      second = 0;
      if (minutes > 59) {
        minutes = 0;
        if (hours > 23) {
         hours = 0;
    seconds = second;
    oldsecond = second;

  // seconds is column 2 and has 6 bits
  k = 2;
  for(j=0; j<6; j++) {
    if (seconds >> j & 1) {

  // minutes is column 1 and has 6 bits
  k = 1;
  for(j=0; j<6; j++) {
    if (minutes >> j & 1) {

  // hours is column 0 and has 5 bits
  k = 0;
  for(j=0; j<5; j++) {
    if (hours >> j & 1) {

1Possibly not true. I found one post that said the 6 analog in ports could be used as digital out. But even if multiplexing isn't strictly necessary for this project, it would be for a larger one.