Sunday, December 17, 2006

Rotation Is Being Sensed

Developing a rotation sensor has had a kind of ironic reversal. I started off with a light sensor. When that didn't work because of the jitteriness of light sensors, I tried a touch sensor. Not fast enough, so I switched from NQC to BrickOS. After some fiddling around, I got the touch sensor to be pretty accurate, but even at 5:1 (let alone the 15:1 I think I'll actually be working at) there was too much friction. Obvious solution: Use a light sensor! So I'm back where I started, but now running BrickOS.

The light sensor is still pretty jittery, but with the increased speed of BrickOS (at least 10x, maybe more) I now have the time to sample the sensor over a longer period to average out the wiggles. Taking 3 samples over 3 ms made the above pictured 5:1 ratio come out dead-on accurate even after 6 fast cranks of the big handle ( == 30 revolutions of the wheel, which itself has 6 light/dark transitions for each revolution, for a final "pulse" count of 180).

BrickOS is pretty awesome, but the documentation is totally non-existent and development seems to have stopped. But it works find as-is the the code is right there to examine, so I'll stick with it. Next I have to do a little experimenting and calculation to determine how much of a tilt translates into how much rotation and how fast those both occur.

No comments: