Simple Sensors To Calculate RPM

Ever wonder how to calculate revolutions per minute using a microcontroller? This project shows you how by purposing an IR emitter and detector and a computer fan. As the fan blades spin they disrupt the beam of infrared light between the emitter and the receiver. This results in a waveform on the receiver’s circuit which can be easily used to trigger interrupts in any microcontroller. In this case a PIC 18F452 monitors the detector’s signals for a rising edge. By measuring time data between interrupts the period can be established and RPM calculated. You can see a video of the test rig after the break.

So what can you use this for? It’s the method that most spinning POV displays use to stabilize the display. You won’t be limited to an IR sensor, but can use a hall effect sensor in the same basic fashion.

[youtube=http://www.youtube.com/watch?v=MKEG8qzZYN4&w=470]

[via Hacked Gadgets]

18 thoughts on “Simple Sensors To Calculate RPM

  1. Cool idea, but wouldn’t it get too fast for the controller to pick up at some point? Especially if you’re trying to control a different process.

    I only really program PLCs, so a high speed counter would work there, but not sure how it works in the microcontroller world.

    It’s amazing how much is spent on sensors etc in industry. They hold up very very well and that’s what you pay for (and the customization), but many are pretty simple at their core.

  2. I am a UC Berkeley mechanical engineering student. We have a senior class on measurement and data distributions in which we have a final project that is exactly this. When I saw this post, I thought it might be from one of my classmates, but alas, it’s not.

  3. @Colecago – Hey now, don’t be dissing on PLCs :).

    BTW, last time I worked with an IR emitter, I found I could see it with a webcam – apparently it picks up just a little more than visible light.

  4. @JC — Yeah, there would be some aliasing at some point in time, depending upon how fast the CPU is being clocked and the code running upon it. However, if it was necessary, it would be possible to detect the aliasing and adjust the output as necessary, although it won’t really be acurate (I mean, it’s aliasing…). A second sensor at a different rate might help in that scenario as well.

  5. @JC

    If the motor was turning too fast for the processor to monitor on the fly, I would simply attach a pin change interrupt to the IR sensor and just have a counter being incremented every time an edge is detected.

    I would then have a timer generating an interrupt every few hundred milli seconds (or whatever) and in that interrupt calculate how many edges have occurred during that time period.

    This would definitely be the way forward if you are multitasking as it uses minimal CPU time during the interrupt service routine.

  6. Yes, Aaron. An IR emitter is perfectly seen by an IR sensor at night. Even beter than in the day because daylihgt contains a lot IR “noise”. You could mount the snsor and emitter next to each other and attach a small piece of white paper to the wheel. Tha way you won’t have a wave-form, but clear peaks in the signal.

  7. @ smoker_dave: That method is very nice, but might be less precise because only whole edges can be passed. Calculating the RPM every time the interrupt occurs would be more accurate, but somewhat time-comsuming. The way I would choose would be to calculate the microseconds between every edge. That way you can know a more exact speed. Maybe something in between the methods would be the best for all.

  8. @JC-
    No, not dissing. PLC’s are wonderful as they are industrial machines that basically have their own operating system to run customized code. Its basically an industrial arduino that runs ladder logic instead of code. No biggy, I’ve worked on PLC’s, I’ve worked on micros. Each have their own purpose

  9. @Aaron I would check first if IR light doesn’t bother the hamster, perhaps check with a TV remote and see how does it behave. Most rodents have night vision, so I don’t know if having an IR sensor pointing at them may disrupt their habits.

  10. Would it be hard to output the RPM in the form of resistance or voltage?

    I suppose it would be a little harder to calibrate but I was thinking it might be nice to have it so we can set our multimeter to resistance then have it output the data to a multimeter

  11. @aw it is pretty simple to use a frequency to voltage converter (I’ve used the 2907) to convert the square wave from the sensor into an analog voltage over whatever range you design.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.