Over ten years ago, I put up a web page with detailed instructions on building a simple electric motor based on one from the Beakman's World TV show. I called it the "Beakman's Electric Motor" page and over the years it has had hundreds of thousands, if not millions, of hits. Realizing that just building a motor, no matter how cool, wasn't a good science fair project, I added suggestions for using the motor as a science fair project, such as experimenting with different magnets, batteries, and coil constructions and seeing how they affect performance. In order to do this, the speed of the motor should be measured, but I left that as an open-ended question.

I've had dozens of e-mails over the years asking how to measure the speed and I've always suggested using a broken light beam and a counter, but I've never built one myself. I even suggested to one person that they use a slot-car lap counter since I'd seen on one sale at Toys 'R Us for 99 cents and she said that it worked perfectly, but not everyone can find a good deal like that.

It just so happened that I got one of these "how do I measure the motor speed?" e-mails on the same day my new Arduino Diecimila microcontroller board arrived from the Make Store, so I thought that would make a great weekend project.

Here is the result, an optical tachometer for Beakman's Electric Motor using an IR emitter/detector pair and a Arduino board. With a few modifications to the programming, you can use this tachometer for measuring other things such as fan or propeller speed. Notes are included on what to change for different applications.

How to have fun with Arduino is a good source of basics on how to setup and use the Arduino board.

Step 1: Materials Needed

Arduino Diecimila Board
Available from the Make Store or from several other online resources. Note however that the techniques of this Instructable could be adapted for other microcontrollers and circuits.

Computer with Arduino software and USB cable

IR LED and IR phototransistor
I used a Radio Shack #276-142, but that may be an old part number. Parts selection on this probably isn't too critical.

Visible light LED
I used a high-brightness red one that I had around. Actual selection not too critical.

10K Ohm resistor

220 Ohm resistor

Breadboard (semi-optional), hookup wires, clips

Opaque tape, such as black electrical tape

Framework for holding LED and detector
Use your imagination, I used KNex pieces to build a frame.

Beakman's Electric Motor (or something else to measure)
Original instructions for building the motor are here: Beakman's Motor
Similar plans are available from other places, such as this Instructable:
Simple Electric Motor
<p>hi all ,</p><p>how im going to read 0 input as a rpm ?</p><p>my coding </p><p>//these define the pin connections</p><p>const int ledPin=13; //the code will flash the LED connected to digital pin 13</p><p>const int sensorPin= 0; //Sensor pin connects to analog pin A0</p><p>int level; //the variable that will hold the light level reading</p><p>const int threshold=150; //this represents the threshold voltage. If voltage is below 800, this triggers the LED to turn on</p><p>void setup() {</p><p>pinMode (ledPin, OUTPUT); //sets digital pin 13 as output</p><p>pinMode (sensorPin, INPUT); //sets the digital pin 0 as input</p><p>Serial.begin(9600); //sets the baud rate at 9600 so we can check the values the sensor is obtaining on the Serial Monitor</p><p>}</p><p>void loop(){</p><p>level= analogRead(sensorPin); //the sensor takes readings from analog pin A0</p><p>if (level &gt; threshold){</p><p>digitalWrite(ledPin, HIGH); //if the light level is below the threshold level, the LED turns on</p><p>}</p><p>else{ </p><p>digitalWrite(ledPin, LOW); //otherwise, if the light level is above the threshold level, the LED is off</p><p>}</p><p>Serial.print(&quot;DATA,TIME,&quot;);</p><p>Serial.println(level);</p><p>}</p>
<p>Here's an optical tachometer using an optical proximity sensor, tested to over 50,000RPM. We are using a Schmitt Trigger to make it work. </p><p>https://docs.google.com/document/d/1cU-Q1YAXNuakYPTdYbrLNRDndf-OAxwED3ou3WXyczE/edit#</p>
<p>Hi all, </p><p>Thanks CMPalmer for this Indestructible. I found it after I plaid with a simpler idea, using the <em>analogread </em>Arduino function at high acquisition rate to follow the analog signal from a QRD 1114 IR proximity sensor, and a simple code to find a transition event (the signal going from low to high for example). Every time the program finds such transition I timestamp and make the difference between two such events, which gives me the period of rotation. For some reason I get some fluctuations in the RPM reading. Here's the design and prototyping document. </p><p><a href="https://docs.google.com/document/d/1cU-Q1YAXNuakYPTdYbrLNRDndf-OAxwED3ou3WXyczE/edit#" rel="nofollow">https://docs.google.com/document/d/1cU-Q1YAXNuakYP...</a></p>
<p>That's great! I love that one-DIY project leads to another DIY project.</p>
<p>Thanks for this great Instructable ! I've made an enhanced version of this tachometer. </p><p>https://www.instructables.com/id/Measure-RPM-DIY-Portable-Digital-Tachometer/</p>
Hi, I wonder if I can use it in a diesel engine, I mean with all the noise and vibration over there... I want to visualize in a LCD display... thank you... great work
can I use a magnet and a reed switch for example on a bike?
Hello, <br>I have uploaded the code to my arduino and it works great, up to about 7500RPM then it starts sending random numbers and the occasional 0. <br>Have I run into a timing limit or what? I really need to read up to about 20,000RPM . I am using a signal generator sending a square wave to the board on the bench and the output goes wierd with a 250hz square wave inout from the sig gen. At 250hz the RPM indicates 7500rpm on the nose. Thanks for your assistance. Great program!!
If you read the fine print on the picture of Mims notebook, he says to use a large value resistor for higher sensitivity, and a smaller value for faster speeds. Maybe this helps?
Hi,<br><br>How did you validate that it is actually working properly? I found that if I spin it very slowly (&lt;10 RPM), the interrupt is triggered like crazy, generating hundreds of falling edges per second. I notice you have no debouncer for lower frequencies. <br><br>Thanks,<br>Peter<br>
Hi, what your sugest to i&acute;m use this sketch to measure rotations over 200.000rpm?<br>
please upload a proper program file.
OMG is that the Forest Mimns Book in the back ground? I totally loved them, and learned a bunch from them!
yes it is! I still have all of his &quot;Engineer's Notebook&quot; series he did for Radio Shack (back when they actually sold cool stuff for electronics hackers). The schematic and explanation of Phototransistors, as I recall (I'll have to dust off my collection) was from his fantastic reference book, Getting Started in Electronics which was also sold through Radio Shack. It's still available and I highly recommend it as well as any of his other electronics reference books to anyone interested in electronics at any skill level. They are terrific references and easy to follow.
&nbsp;for me when i down load the program it comes up as a tmp file so could you post it replying to this comment<br /> <br />
Hello. Great Instrucrable; I need the kind of Script for an RC-Car Engine-RPM-Meter (OMG, Creepy Word ;))<br /> And i Found out, That you can also Use a Reed Sensor for Measuring. Or an Hall-Sensor. I Tried out Both and&nbsp; the Hall sensor worked best for me.<br />
could this be done with a cds cell/photocell/LDR/photoresistor(all the same thing)<br />
I've tried that ... but it is too slow ... LDR + laser ... you could break the beam very fast, an Arduino would not noticed.<br />
What would the upper rpm limit of something like this be?
That would depend on how fast the arduino can run through its loop of code.&nbsp; It also might depend on how fast the sensor can detect a change of light.
Besides the point, but another way to measure the rotor speed is to hook the two paper clips up to an oscilloscope and count the voltage spikes over a period of time.
According to <a rel="nofollow" href="http://hibp.ecse.rpi.edu/~connor/motor_comments.html">this source</a>, the fastest coils have a relatively small diameter with many turns of small gauge wire. My coil in the drawings above had 7 or 8 turns wound around a pill bottle and maxed out at 1200 RPM, but usually ran steadily at around 700-800 RPM. At high speeds, imbalances are magnified and the coil would jump around on the paper clip &quot;brushes&quot; and slow down. Using thinner wire would mean that the coil couldn't the rigid shape of the tails.<br/><br/>One alternative is to allow the coil to sit inside a loop of wire (like the design that uses a large safety pin instead of bent paperclips). This wouldn't ensure proper contact all the time, but would minimize jumping.<br/><br/>What I'm thinking of doing is using two straight, rigid pieces of large, bare copper wire or metal tubing with a non-conductive joint in the middle, then winding a coil with a large number of turns out of very thin magnet wire, then inserting the rod through the width of the coil and soldering the bared ends to the tails. Then use paint on one side of one tail to mimic the half-sanded insulation on the magnet wire. This coil should be heavy, very stable, and have a high electromagnetic density. When I get a chance to build it, I will add it to the Instructable in case these instructions aren't too clear.<br/><br/>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.<br/><br/>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 &quot;brush&quot; points as carbon can build up.<br/><br/>The paper clip arms need to be the same height as well (but they are easily - maybe too easily - adjusted).<br/><br/>I've also thought about gluing small craft beads on the coil tails to keep it from &quot;walking&quot; side to side - something else that will slow it down or stop it.<br/><br/>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).<br/><br/>Another good Science Fair type project would be to compare the speed and efficiency of the different types of simple motors.<br/>
I should have been more specific, I meant to ask about the tachometer. Thanks
To quote Emily Litella, "Never mind" :-) Someone with a little more knowledge of the ATmega chip in the Arduino would have to answer that - it would all depend on how fast the interrupts can be processed. Taking out the status LED toggle would probably be a good idea for high speed devices. You could also use an offset "flag" on the coil to only break the light beam once per revolution (and use tighter optics or maybe a laser for the emitter/detector). If someone can figure out the maximum measurable speed with this setup, I would like to know as well.
i added a Serial.println and the serial data is in very strange characters. ascii maybe?&nbsp;anyway, it's not in number form. do you have any suggestions on how to make it voltage change in integers? i want to bring it over to Pd and create some sounds. <br /> thank you!<br />
You could use an op-amp as a comparator, so that the output would only be on, or off.&nbsp; It is really simple.&nbsp; By changing the voltage at the non inverting input voltage, you can change the sensitivity as well.&nbsp; <a href="http://web.telia.com/~u85920178/begin/opamp00.htm" rel="nofollow">http://web.telia.com/~u85920178/begin/opamp00.htm</a>&nbsp;gives an example of how to do this.&nbsp; You might be able to leave off the negative voltage and have it still work.
Thanks for this. I know this is an old guide, but I just got an arduino and your code example worked perfectly for tapping into the digital tach output on an S2000(A Honda sports car built for racing). I actually didn't have to change it at all! The output of the car worked exactly like the photocell you used. I tested it up to 4,000 RPM, but no higher(just didn't test higher, not sure the limit). I'm working on attempting to get that info cleanly into the computer to be processed by python or the like, but that is just a mater of time.
I need to be able to calculate angular acceleration (which will vary) for calculations after the is there a way to store each RPM reading into either a spreadsheet or .txt file so it can be analyzed in a graphing program?
You don't need a resistor to the led, arudino has them built in.
its only for one pin (like pin 13) and only on some models other pins need a resistor so that if something shorts out in the circuit, some of the output voltage will still be burned off and the board wont fry, then again, each component has a different voltage rating, so resistors might be necesary
Great instructable. I tried this with a small 'flag' on the shaft of a motor that ran through the slot of an opto-transistor. The motor was running at about 1200RPM I think but the figures being produced by the arduino were in the region of 30000 to 50000. Any ideas why?
I concur with sscanf: This won't work as detailed in your "pretty picture" - you need to go back to your hand-drawn schematic on graph paper. As detailed in the first picture the transistor will never see the voltage it needs...
I just used this howto as a reference for a similar application using the same IR components and Arduino Diecimila. Everything worked great but note that there is an important difference between the circuit diagrams on this page for connecting the phototransistor. I found that the hand drawn connection shown on the graph paper worked but the other does not. Your mileage may vary.
Hi! Can I use this tach to see another rpm measures? the aplication run under windows xp? can you send me this aplication? tks
Yes, you can use it for measuring different kinds of rotational motion. See the later steps. The Arduino application runs under Windows XP, but is compiled to object code for the Arduino. All of the source code and links to the application are included in the Instructable.

About This Instructable




More by CMPalmer:Arduino-Based Optical Tachometer Free Wire Twisting Jig Clip-On Metal Framed Reading Glasses 
Add instructable to: