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.

[via Hacked Gadgets]

Comments

  1. Travis says:

    wouldn’t the tachometer pin on the fan be a usable as a source for pulses that could trigger the interrupts in the PIC 18F452? (e.g. for this fan), instead of the IR beam splitting ?

  2. Erik Johnson says:

    @Travis I think the fan was just used for demo purposes only, the application is wider than that.

  3. JC says:

    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.

  4. Colecago says:

    PLC’s contain microcontrollers, so anything a PLC can do, a Micro can do, and most likely better and faster.

  5. Branno says:

    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.

  6. JC says:

    @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.

  7. ReKlipz says:

    @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.

  8. Aaron says:

    Does it work by night without light? I want to “monitor” the hamster wheel and calculate the distance he runs every night.

  9. smoker_dave says:

    @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.

  10. arjan says:

    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.

  11. arjan says:

    @ 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.

  12. Colecago says:

    @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

  13. Ivan says:

    @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.

  14. aw says:

    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

  15. sreeraj says:
  16. Mccoywm says:

    @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.

  17. addidis says:

    nice post this will be useful.

  18. qlwlp says:

    @smoker_dave

    timer input capture perfect for RPM measurement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 92,260 other followers