|
Mar
9
Written by:
Gary Holbrook
3/9/2008 5:43 PM
My nephew recently made an inquiry as to the possibility of creating a low cost non contact digital tachometer. With my typical over-optimism, I nearly shrieked "No problem! Piece of Cake!". This didn't turn out to be entirely true, but the demonstration project I put together was pretty straight forward.
The first thing I needed was an optical sensor. Obviously ambient light can be a problem, so I wanted something tuned to infrared. As fortune would have it, someone had the brilliant idea of putting an infrared emitter (LED) and a detector (a phototransistor) in the same case! The sensor I ended up using is an Omron EE-SF5.
For my development platform, I used the aforementioned (in a previous po st) AVR Dragon\Dragon Rider combination with an LCD and an Atmega168 chip. For this project I opted to use the internal 8Mhz RC oscillator instead of a crystal. Obviously it would be a good idea to use a crystal for the final circuit. The final product could be put together for about $20, including the LCD or less if the LCD could somehow be omitted.
The first order of business was to get a reading from the sensor. That turned out to be a headache. A big one. The sensor expects right about 1.4V for input, so I ran to the basement and collected a 2.7K resistor and a 1K resistor and built a voltage divider. That didn't work. After much investigation, it turned out that my voltage divider wasn't permitting enough current through. After building a more appropriate divider, the emitter and sensor started working. In this photo, the emitter is on the bottom and the phototransistor is on the top. Notice the resistor to ground. This provides a path to ground, however since electricity is as lazy as the rest of us...it prefers the easy route. The easy route is out the wire and to the circuit board. On the voltage side, the wire goes to +5V.
Next, I needed a test platform. What else could I possibly use, except my super-manly erector set? In this bottom view photo, you can see that I fixed a wheel onto a frame. There is a small piece of aluminum foil on the wheel which triggers the sensor. The next picture shows the assembly with a motor, on top of the sensor. The optimal range for the sensor is only 5mm!
The final phase of the project was to write the AVR code. There are a couple of gotchas here. For starters, even though I tried to trigger an interrupt only on the rising edge of the signal, the interrupt occurred twice.
Another strange thing happened if I tried accessing the LCD without disabling interrupts. I'm not sure what that was all about. Anyway, ever second a timer updates the LCD. The LCD shows the number of times the sensor has been triggered, the current RPMS, and the number of seconds the program has been executing. If you would like to take a look at the code, be for-warned that it's really ugly! Still, you can get it here.
The demo video is on YouTube, sorry for the poor quality.
Tags:
|
| |