Arduino Based Optical Tachometer
Arduino Based Optical Tachometer
Living
Outside
Play
Technology
Workshop
Table of Contents
Arduino-Based Optical Tachometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step 4: Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
Image Notes
1. Beakman's Motor
2. IR LED
3. IR Detector (Phototransistor)
4. This part of the frame slides up and down to adjust the light beam gap
Image Notes
1. USB connection
2. Motor
3. Results
4. Arduino board and proto board.
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
Image Notes
1. Spinning coil
2. This does nothing
Image Notes
1. Connection to IR LED
2. Connection to phototransistor
3. Power and ground connectors
4. Status LED
5. to Arduino pin 2
6. to Arduino pin 12
7. to Arduino pin 13
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
Image Notes
1. Same diameter as coil
2. Straight line for aligning coil tails
Image Notes
1. Black electrical tape across middle of coil
Image Notes
1. Spinning coil
2. This does nothing
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
The Arduino Diecimila has a current limiting resistor on pin 13, so to reduce the parts count, I connected the IR LED to that pin. If you have an older Arduino board,
remember to connect an appropriate series resistor to the output pin. The connections for this were also done with a right-angled header on the breadboard and alligator
clip patch wires to the LED. Anode to digital pin 13, cathode (flat side) to ground.
Status LED
Since we're dealing with invisible IR light, interrupts, and serial communications for status, I wanted to see something that would tell me the circuit is working, so I
connected a RED status LED to digital pin 12 through a 220 Ohm series resistor.
Image Notes
1. View full size (through "i" link) if you can't read the writing.
Image Notes
1. Connection to IR LED
2. Connection to phototransistor
3. Power and ground connectors
4. Status LED
5. to Arduino pin 2
6. to Arduino pin 12
7. to Arduino pin 13
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
Image Notes
1. Completed circuit sitting on top of Arduino board
Step 4: Programming
The program for calculating the RPM of the motor is pretty simple. I adapted it from a Hall Effect motor speed calculator at the excellent Arduino Playground site.
You can download the "sketch" for the program below.
The rpm_fun function is the interrupt function that will be called whenever the data on pin 2 changes from HIGH to LOW (a FALLING pulse). It updates the global
rpmcount, then toggles the status LED.
void rpm_fun() {
//calculating RPM
//Update count
Setup initializes the variables, configures the serial parameters, sets the pin modes, and sets up the interrupt function.
void setup() {
Serial.begin(9600);
The loop function, as the name implies, is the main processing loop that "runs forever" while the board is powered up. The first statement delays for one second (1000
milliseconds), but note that the interrupt function will break in every time the value of pin 2 changes and run the rpm_fun function. After the 1 second delay, the interrupt is
temporarily disabled (this may not be necessary, but seems safer) then the RPM is calculated based on the number of interrupts and the elapsed time between now and
the last time the calculation occurred. The result is sent back to the computer over the serial port, then the interrupt is restored.
void loop() {
delay(1000);
detachInterrupt(0);
rpm = 30*1000/(millis() - t
Note that the way the motor and the IR detector is configured, each single turn of the coil will result in two transitions, so the calculation takes that into effect. The same
would occur for a two bladed fan or propeller. If only one light break per revolution occurred, such as a swinging arm, the calculation would be:
rpm = 60*1000/(millis() - timeold)*rpmcount;
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
File Downloads
OpticalTachometer.pde (1 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'OpticalTachometer.pde']
Image Notes
1. USB connection
2. Motor
3. Results
4. Arduino board and proto board.
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
Image Notes
1. Beakman's Motor
2. IR LED
3. IR Detector (Phototransistor)
4. This part of the frame slides up and down to adjust the light beam gap
Image Notes
1. Spinning coil
2. This does nothing
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
Related Instructables
Tachometer by
MauricioR
DIY Infrared
Proximity
Sensor (Arduino
Compatible) by
xBacon
Motor Control
With DIY
Tangible
Interfaces by
juanifico
Electronic
Music Box
Powered by
Arduino (sort
of) by h2osteam
Arduino on a
Breadboard
(Photos) by
ThatCaliforniaGuy
Advertisements
Comments
32 comments Add Comment
electro18 says:
Thanks for this great Instructable ! I've made an enhanced version of this tachometer.
http://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/
danielito.lajo says:
yaly says:
kkrumm says:
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
stringstretcher says:
ptorelli says:
Hi,
How did you validate that it is actually working properly? I found that if I spin it very slowly (<10 RPM), the interrupt is triggered like crazy, generating
hundreds of falling edges per second. I notice you have no debouncer for lower frequencies.
Thanks,
Peter
os_sanches says:
Hi, what your sugest to im use this sketch to measure rotations over 200.000rpm?
eddy40 says:
lalder says:
OMG is that the Forest Mimns Book in the back ground? I totally loved them, and learned a bunch from them!
craigbic says:
RANDOMFISHYFACE says:
for me when i down load the program it comes up as a tmp file so could you post it replying to this comment
Lenny24 says:
wii552 says:
zholy says:
I've tried that ... but it is too slow ... LDR + laser ... you could break the beam very fast, an Arduino would not noticed.
EvilSpeeder says:
What would the upper rpm limit of something like this be?
kikiclint says:
zq76 says:
CMPalmer says:
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
I estimate that speeds around 2500 RPM shouldn't be impossible. Of course this motor design is inefficient and doesn't provide much torque, so there is
no reason to super-optimize it except for fun.
Other things to remember are (a) use a fresh battery - the motor isn't too kind to them and (b) there is a bit of arcing at the contact points, so periodically
you need to wipe off the coil tails and the "brush" points as carbon can build up.
The paper clip arms need to be the same height as well (but they are easily - maybe too easily - adjusted).
I've also thought about gluing small craft beads on the coil tails to keep it from "walking" side to side - something else that will slow it down or stop it.
If you look at the Beakman's Motor page, there are some links to other designs of simple motors and you can find a ton of them via Google (there is a
cool brushless motor that uses a magnet reed switch where the motor shaft has permanent magnets attached and it rotates beside an electromagnetic
coil - I think I'm going to build one of those some day).
Another good Science Fair type project would be to compare the speed and efficiency of the different types of simple motors.
EvilSpeeder says:
I should have been more specific, I meant to ask about the tachometer. Thanks
CMPalmer says:
Cairie says:
kikiclint says:
DBeta says:
teddanbren says:
robotkid249 says:
You don't need a resistor to the led, arudino has them built in.
raykholo says:
sparkyhester says:
adrenalynn says:
sscanf says:
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/
DavidRobertson says:
Cool
os_sanches says:
CMPalmer says:
http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/