Tuesday, September 18, 2007

Christmas Present Idea

Long have I pined for a mechanical watch where you could actually see the gears and springs and whatnot flying around. I've seen things like this with the "Fossil" brand attached, but they are always less than what I really wanted. I tried googling for "mechanical watch with visible gears" but that wasn't too helpful.

Today I discovered the magic word: Skeleton. A "skeleton" watch is one where it is purposely made to be see-through. "Full skeleton" means that even things that you'd kind of like to have on a watch, like numbers and hands, are as tiny and hard to use as possible so you can see the full glory of the gears.

Feast your image display software on THIS:

I gather it is possible to spend up to and including ONE MILLION DOLLARS on a watch like this, but, I further gather, Chinese imports can be had for under $100. Even well under $100. For instance.

I wouldn't have many requirements on such a gift. It should be as visible as possible and be actually mechanical, no hidden battery doing the work.

Monday, September 17, 2007

A New Recipe for π

I've been working on a Difference Engine in Lego. A little derivative perhaps, but still a big challenge. For one thing, there's not that much construction detail at that site. For another, what little there is I'm ignoring. I want to try to solve this on my own.

I've made some progress, but my (borrowed) video camera is being cranky so I've been unable to record and post it. (Aside to person I borrowed it from: I'm just getting a black screen in record mode. Also a little red flashing light that I think is the button battery so I thought that was it. However recording suddenly started work despite that, but only for a few minutes. ???) Thus this post isn't about that.

When the Difference Engine actually is running, I thought it would be fun to have it calculate π. NO WAIT, LET ME FINISH!!! I know π is transcendental, meaning there is no polynomial for which π is the solution.

The point of the Difference Engine is that as you crank the handle, you calculate the value of the polynomial for higher and higher values of x. What I'd like is a polynomial such that for higher and higher x, the value is closer and closer to π.

So I just google for a polynomial that does that, right? I mean, there must be hundreds of them by now. No. There are none that I can find.

There are plenty of series approximations, however. For instance:

π = 1/1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 +....

And with some series...es, it's possible to come up with an expression that the series sums to up to any given point. For instance, the sum of the first n odd numbers:

1 + 3 + 5 + 7 + .... 2n-1 = n2

So maybe one of the series approximations of π can be manipulated into a polynomial. Then I can use the Lego Difference Engine on that polynomial and crank out 2 or 3 digits.

However, I'm having a great deal of trouble with this (not that that indicates anything other than the fact that I'm really not that great at math). For one thing, I've concentrated my efforts on the simple-to-remember 1/1 - 1/3 + 1/5 approach. But I just realized this morning that this series alternately overshoots and undershoots the target, meaning it has an infinite number of humps and valleys. A polynomial of degree n can have a maximum of n-1 humps and valleys, AFAIK, so that series is out.

If I'm going to start from a series, I need one that's always more or less than π and never the other. Or an entirely different idea. I can think of plenty of iterative methods, but that's basically just a series. I need a single step where the accuracy is chosen by the value of x I input. Since I haven't been able to find any reference to such a thing, I'm thinking it hasn't ever been done. Is that because it's impossible?

Tuesday, September 11, 2007

You Program My Back, I'll Program Yours

If you are a math/science/computer nerd and you have a child, you have undoubtedly wondered how you can teach your child programming. I googled for such a thing more than once and found the usual suspects: BASIC, LOGO, etc, etc. The free ones were all half-finished or too hard, the good ones were all expensive or geared towards classrooms.

I tried teaching Number One Son (8 years old) some pseudo-codey stuff to do simple math problems and learn about loops. He enjoyed that, but we didn't get very far and I always had to be the virtual machine to check if his program ran.

However, MIT has recently come up with something that absolutely rules--Scratch. And it's free!

Scratch is graphical. You drag the little components around to assemble a program. For instance, to make a loop, you drag your components into a loop widget, which wraps around it like a vice. If you want to construct a conditional, you get out the "if" widget and drag and drop logical/mathematical conditions in from the toolbox. Just fill in the blanks and go.

The GUI isn't just for show, either. You don't feel like you are using the mouse to write a program, you feel like you are literally assembling a physical object. And it eliminates syntax errors, which is a major deal in the under-13 crowd. Furthermore, the graphical programming language ties right in to the very graphics-oriented programs Scratch is targeted towards and children love. Creating and animating sprites takes just a few clicks. Object collision is just a matter of checking if two colors are touching. And this is all clearly presented enough that an 8 year old can (and has) figured most of it out himself.

I think he learned more about programming in 2 days with Scratch than he did in all the previous years of my bumbling explanations. He goes off and works on a program for a while and then will come to me with a question about how to do something. And they are pretty sophisticated problems (considering his age), such as how to cycle through sprite costumes and wraparound at the end or how to keep various sprites in sync. With the concrete example of his non-working program providing the motivation, the explanations of modular arithmetic or semaphores stick much better.

So far he's created programs that simulate a robot in a maze, animate a rocket flying to the moon, teach the alphabet to his two-year-old sibling and even one generic drawing program with adjustable pen size and color. All 100% on his own.

Windows and Mac only, but:

  1. They claim they'll have a Linux version out "before the end of 2007".
  2. The usefulness, fun and polish of Scratch is more than worth setting up an old PC with Windows.
It's possible to upload your program to share with other kids, but we haven't tried that yet. Videos of Scratch in action..

Tuesday, September 4, 2007

Lego Marble Pump II: Handcranked Bugaloo

The basic idea behind the Lego marble pump is working. I cobbled it together well enough to demonstrate My Vision, but many kinks remain to be worked out. For instance, the little levers need to be worked automatically. But I'm not going to do that, I'm just going to post the video of it hobbling along.

In case that isn't clear:

  1. Marble goes in ramp at left
  2. Cam on central carriage hits lever to open gate, allowing marble into carriage (part of cam played by my finger)
  3. Central carriage lifts, eventually dumping marble into next higher ramp (another "cam" lifts lever there to make sure gate is closed)
  4. Central carriage lowers, goto 2

Monday, August 27, 2007

Difference Engineering

I've known about Babbage's Difference and Analytical Engines for a long time, but never known much about how they work. Finally I actually read a little information on the first one (in the context of Legos) and it's pretty interesting from both a mathematical and mechanical point of view. Based on the information on that page, I worked out a tiny additional step of my own (though surely Babbage himself already knew this).

First of all, the basic idea: The purpose of the Difference Engine was to pre-calculate tables of polynomials for books in the days before portable calculators. So you'd want to known 3x3 + 14x2 + 5 for all values of x from 1 to, say, 1000. As it happens, there's a clever little shortcut such that if you have a few values you can calculate the next one very simply using only addition from the previous answer (thus "Difference Engine").

So let's say f(x) = x2 + 3x.


x   f(x)   diff1  diff2 
1     4      -      -   
2    10      6      -   
3    18      8      2
4    28     10      2
5    40     12      2
See that second difference column is a constant. If we'd picked a polynomial of the 3rd degree, we'd have to work this out to the 3rd column. Fourth degree, 4th column, etc.

So to build a machine, all you need to do is set the value for x = 1 and set the Nth difference in the last column. It automatically adds that difference to the previous difference, which is cascaded upwards until f(x + 1) is arrived at. Then you go around again. All that is required is simple addition.

What isn't explained on that page (that I saw) was how to know ahead of time what that last difference is going to be. Sure, you can work out N rows to get that Nth column, but it would be nice if you could set the inputs from direct inspection of the polynomial. As a matter of fact, this is easy.

Say f(x) = ax2 + bx + c. Then the difference between two successive answers (i.e. the value in the first difference column) is going to be:

a(x+1)2 + b(x+1) + c - ax2 - bx - c
= ax2 + 2ax + a + bx + b + c - ax2 - bx - c
= 2ax + a + b

The difference between successive entries in THAT column are going to be:

2a(x+1) + a + b - 2ax - a - b
= 2ax + 2a + a + b - 2ax - a - b
= 2a

And if we look at our example, we did indeed get 2 * 1 as the constant in the last column.

Working this out for a 3rd degree polynomial gives 6a (where a is the coefficient of x3). Based on these two examples and looking at Pascal's Triangle, I predicted the value for a 4th degree would be 20. But it was actually 24.

In fact, if you work it out it should be clear that the constant difference will be a * n!, where a is the coefficient of the highest power of x and n is that power. It should be simple to prove this using induction, since all other terms always drop out and you muliply the coefficient by the power at each step on the way down.

So if I wanted to know what the constant difference was in the 5th column of differences for the polynomial 8x5 - 3x3 + 117, I just multiple 8 times 5! and get 960. I cram that, plus the initial value for x = 1 onto the machine and get cranking.

Friday, August 24, 2007

Lego Marble Pump

This is a pretty neat machine. The core of the pump mechanism is pretty genius and I built one myself based on that graphic. The problem is that the tower can only be as high as the number of marbles you have and the number of marbles your motor can lift.

The most common way of lifting balls in a contraption is with a kind of one-way elevator. But I've already built one of those. This guy has an interesting idea. It's a little hard to see in the video, but he's got the marble going both ways through the pistons. It lifts one "story" going from left to right, then another story from right to left.

That gave me an idea. First of all, why not any number of stories? And second of all, why three pistons? Probably the answer to both is: maximum height for the amount of Lego he had.

I'm thinking you could put just one piston between two towers and with a certain amount of mechanical futzing pump the marbles up to any height.

*pause for 24 hours of trying to get some kind of Lego CAD software working on any computer in my house or office to illustrate this and failing miserably*

OK, here's the basic idea: The piston in the middle has ramps inside. The marble starts off at the bottom of one of the side towers. It rolls into the piston down one of the ramps and it stopped against the wall of the other tower. The piston moves up and there's a little nook in the other tower that the marble falls into. The piston lowers. Now there's another internal ramp, this time pointed the other direction, aligned with the nook, so the marble re-enters the piston and is stopped against the wall of the first tower. Repeat.

It's a little tricky, though. The nook is the problem. The marble needs to roll out of a ramp into the nook but then roll out of the nook into a ramp. The three piston video solved this by having good timing and long ramps. I don't have long ramps or the patience to get the timing right. What I'm trying right now is a kind of teeter-totter arrangement in the nook that tips up to receive the marble and then tips down to release it.

Oh cripes. I just re-read this entry and even I was too bored by the last two paragraphs to pay attention to them. I'll just have to make it work and post a video. Or somehow get LDraw working.

Wednesday, August 15, 2007

The Temperature of What?

So I had all these posts about temperature logging and one post with the actual logged temperatures...but the temperature of what?

A solar hot box!

You probably already know what this is, but just in case you don't: It's basically a tiny greenhouse. Or like a car left in the sun at noon in August. Only it's even hotter, since it is insulated, painted black and pointed right at the sun.

Inside the box I put a jar with 250 ml of cooking oil and poked a hole in the lid for a temperature probe. That's what these temps are.

Why did I choose cooking oil? Because I didn't want evaporation to be a problem. For one thing, it would fog up the inside of the glass. For another, it would cap my max temperature at 100°C (not that that turned out to be a problem in this case). And lastly, it would change the amount of water in the bottle and I needed that to be a constant because I did some calculations with it.

Knowing the amount of oil and the temperature change (plus looking up the specific heat of vegetable oil), I can calculate the rate at which energy is entering the oil. For the above graph, I got 2.5 watts for the steepest part of the curve. However, I see that the site I just linked to has the specific heat of veg oil as 1.67 kJ/kg K and I was using 2.5. So maybe the power is really more like 3.7 watts.

Knowing the area of the collector I can also calculate the amount of power falling into the box. That's about 75 watts. So the end-to-end efficiency was only about 3-5%. Not that great.

Imagine if you put a cup of water on the table and then turn the furnace thermostat up to 90°. How much energy are you going to waste before the water gets hot? This illustrates the 3 main problems:

  1. Air passively surrounding a container of liquid isn't going to heat it very fast.
  2. There's a lot of volume of air being heated uselessly.
  3. During all this time, heat is escaping the cracks, windows, chimney, etc. In the case of the hot box, the glass front gets very hot and is radiating a lot of the energy right back out.
If a hot box is like an oven, the next version will be like a microwave. Don't heat up the air, just beam energy right into the substance.

Wednesday, August 1, 2007

Locomotive Lego Linkage

It seems like I keep having to reinvent this linkage. The basic idea is that I want to turn a crank (i.e. rotary motion) which makes something move back and forth (i.e. linear motion). You see this exact same linkage on classic train wheels, though in that case the linear motion is the primary mover and it is turning into rotary motion to move the train.

In fact, almost all piston engines do this same thing. What I keep not realizing is that you need to hold the straight part straight or it doesn't work. Not "it doesn't go straight" but not work at all.

Let me show you what I mean

I think the reason I keep forgetting this is that the movement looks so smooth. It doesn't seem like there could be that much friction there, but there must be. The piston is rubbing against the sides. Not (just) because of a tight fit, but out of sheer necessity to make the piston run straight.

There are linkages that have been invented that can convert rotary motion to linear without all the side friction. For instance, here. A 3D version of that linkage is in the Boston Museum of Science. Another picture of Peaucellier is here and the page also calls my "locomotive linkage" a "sewing machine".

Peaucellier isn't very practical because it requires so many parts, which take up space and can fail. Or can it be made simply? Can another practical, mathematically accurate, low-friction linkage be built? In Lego?

Tuesday, July 24, 2007

Ambient Orb aka Rainbow Ball

For some reason this "ambient orb" Arduino project blew me away. The basic setup is very easy: red, green and blue LEDs mixed in different amounts. (Putting them inside a diffusing cover helps the mixing.) There are only two catches:
  1. LEDs aren't dimmable the way incandescents are, so how do you control mix?
  2. Finding LEDs of all three colors in the same output is nearly impossible.
The solution to the first catch is Pulse Width Modulation. Basically, you send tiny bursts of current so it flickers on and off faster than you can see it. The more time it spends on (the "duty cycle") the brighter it seems. Doing this from the Arduino is simply a matter of adjusting a number to say what you want the duty cycle to be in the range 0-255.

For the second catch, I pored over catalogs and websites trying to find matching LEDs. I did find them more than once, but it was always coming out too expensive. I mean, I was blown away by the idea, but not to the tune of $10! (Maybe I should have called this blog "The Cheap Bastard".)

I actually do already have all three colors, but the single blue LED I have is a trillion times brighter than any of the others. Really, it's blinding. I could have just bought a new blue to match the low-level reds and greens I have, but what power are they? Is there any way to figure that out, maybe from power consumption?

Finally I realized I could just use a bunch of reds and greens and also cut the blue's power in half (i.e. never get the PWM duty cycle above 50%) and it comes out all right. Mostly. The blue is still too powerful and swamps the blue-green transition.

Why is the green almost invisible in the video? Is the CCD in the camera less sensitive to green? Is the green really a lot less powerful and my eyes just adjust to it?

Light and Fluffy as a Kitten: For Real Now

That's because I gave up and washed my hair.

It was definitely true that my hair was less oily than I expected. There were many days when each hair stood alone, unclumped from the others, and I thought I was near to fluffy kittenhood. But then the next day I'd forget to rinse it or something and I'd be a greasemop.

Also, and this may have been psychosomatic, I felt like the greasiness was starting to migrate down my head. Like maybe the hair was leaving oily trails on my forehead, on the tops of my ears, etc.

Experiment terminated after two weeks.