Re: Measuring motor RPM with micro.



seegoon99@xxxxxxxxx wrote:

Hi all.
I am trying to measure the RPM of a motor and have a few questions.
The motor is turning slowly(about 132RPM after gearing). There is an
"optical encoder"
on the shaft that gives me 8 pulses / rev.This gives me a pulse every
56ms or so.
How can I calculate the RPM of the motor WITHOUT using floating point
routines and in
a fairly fast time.
I could wait 1 second , count the number of pulses / 8 * 60 to get RPM
, but this takes far to long(1s) :0( I can measure fewer pulses , but
the time is still to long.
I could measure the period of 1 pulse , invert / 8 * 60 to give RPM.
This is much quicker , but involves floating point routines. I can gate
a timer in the micro with the pulses from the encoder to give me a
count in the micro , but this will also involve floating point routines
to get back to rpm.
Is there a simple solution to this problem(probably) and I've missed
the boat completely or am I stuck with the options I have described:0(
Cheers
Rob

Oi. Kids these days.

You need revolution/minute, and you have clock ticks/revolution, right?

So do the math:

revolution/minute = (clock ticks/minute)/(clock ticks/revolution)

Let's say that you have 1us clock ticks. That means you have

(60000000 clock tick/minute)/(clock ticks/rev)

That'll fit into 32 bit integers, no problem.

Want RPM in tenths? Use

(clock ticks/(minute/10))/(clock ticks/revolution)

That'll _still_ fit in 32 bit integers.

Granted, going higher will require some fancy footwork, but you should see where I'm going.

Dig through the archives of the Embedded Systems Programming magazine -- the have had more than one on doing this kind of stuff with integer math. http://www.embedded.com.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Posting from Google? See http://cfaj.freeshell.org/google/

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
.



Relevant Pages

  • Re: Why do electric powered automobiles need to be so complicated?
    ... 10,000 RPM). ... Torque conversion of one sort or another is a must. ... very fast - whatever the standard 3-phase 60 Hz induction motor runs at). ... pole, 8 pole, and 12 pole motors, which run correspondingly slower but with ...
    (sci.electronics.design)
  • Re: Measuring motor RPM with micro.
    ... I am trying to measure the RPM of a motor and have a few questions. ... but involves floating point routines. ...
    (sci.electronics.design)
  • Re: Engine sounds like marbels and diesels after stopping
    ... >>> tight sounding motor it sounds like it's full of marbles. ... Andvancing the timing to create more ... You don't do this by advancing the ... >> Odds are, if they changed the compression, they also changed the max RPM. ...
    (rec.outdoors.rv-travel)
  • Re: pic micro programming
    ... revolution of the motor shaft. ... Any idea what the pulses you get, ... think over the basic idea of rpm and ways to measure it. ... Set up the counter to count external pulses and the timer for the time you ...
    (sci.electronics.repair)
  • Re: pic micro programming
    ... I as using a sensor which gives me 4 puls per ... revolution of the motor shaft. ... think over the basic idea of rpm and ways to measure it. ... Set up the counter to count external pulses and the timer for the time you ...
    (sci.electronics.repair)