I built a tachometer for the milling machine, as a step in giving the cnc controller full spindle control (auto-change with tool change, and sense when it’s stalling.) The first version uses an arduino and this code: http://arduino.cc/playground/Learning/Tachometer
The sensor is a mouse encoder wheel LED/phototransistor pair, with a turned aluminum disc that has a hole drilled in it, as the encoder itself.
(You may ask why I’m not using an AS5040. That’s the wrong tool for the job, since it senses position rather than just rotation, and the encoder wheel I just cut fits right on the hollow mill spindle, which provides no easy place to put a magnet.)
Anyway. The arduino code works fine. The schematic, however, has a problem: if you wire it up just as this says, the phototransistor output is always at about Vcc: the analog input to the arduino measures between 1017 and 1023 no matter how carefully you block the phototransistor.
But the moment you go to measure the voltage coming off the phototransistor with respect to ground, it works perfectly: any bit of anything blocks the lightbeam and the output goes to a fraction of a volt.
The meter’s input impedance drags down the output and makes it work. It’s hard to troubleshoot something that works when you’re measuring it, and only doesn’t work when you’re not measuring it.
A 1 megohm resistor between the output and ground makes it work great.
Tomorrow I’ll add an LCD rather than having to keep a laptop in there to see the RPM, and a bit later I’ll turn the whole thing into a standalone board on the back of the LCD, but for the moment this will do.
A while back Kirk gave me a webcam that has pan and tilt control. It works well under Windows. But I’m a masochist — and I already have a weather station + insolation + multiple temperature measurement setup for an old linux laptop, and I thought it’d be nice to add a pan&tilt webcam to the mix.
The webcam is a Creative Live! Motion cam. It uses a standard ccd for which drivers are included in the mainline kernel so camorama et al can get video from it natively. But that doesn’t handle motion.
Soooo I fired up wireshark, preparing to copy these guys:
who reverse-engineered the screendump program for an oscilloscope (and found that the scope actually dumps a nice full-color high-resolution screencap that the stock software degrades to a small monochrome picture.)
So I installed XP in virtualbox, installed the cam drivers in XP, and fired up the camera.
Problem 1: no USB. I solved this by running virtualbox as root.
Problem 2: XP crashed the moment I tried to do anything with the camera. I solved this by starting virtualbox as root, and doing the whole XP install from that — just copying over a VM made as a user didn’t do it.
At this point the camera is stable in XP.
Problem 3: wireshark crashed the camera connection. As soon as wireshark came up, the USB stream got broken.
My friend Brian pointed out that other people have had problems with old versions of libpcap, upon which wireshark relies. Turns out even recent versions of Ubuntu and Mint have wireshark packages from 2007.
Independent repositories to the rescue: ppa:jelmer/daily will provide you with (as of right now) wireshark 1.4.2 rather than the stock 0.9 and that has a libpcap that works beautifully.
So now I can drive the video camera around, taking pictures, and logging usb commands. I can look through the packets — ignoring the 64kbyte ones, that are just chatter between the computer and the camera and analyzing the packets that are larger than that — and start figuring out how I can copy them.
That’s as far as I’ve gotten so far, because now I’m learning how to use wireshark’s filters so I can have it show only the differences between sequential packets.