RPM Counting Continuous


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2007
    Location
    Harvest, Alabama
    Posts
    10

    Default RPM Counting Continuous

    It is fairly simple to produce a disk which provides a pulse which is say 5 degrees wide of a rotation. This pulse can be measured relative to the width of the pulse in time. The resulting time will tell by calculation the RPM of the disk. I am wanting to do such a thing and wondered if anyone out there knew the best way to measure this pulse width. The RPM may vary greatly and as such the time probably needs to be a 14 or 16 bit time value. I have an PIC18F4620 chip I am working on.

    Ideas Please!

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by CluckShot View Post
    It is fairly simple to produce a disk which provides a pulse which is say 5 degrees wide of a rotation. This pulse can be measured relative to the width of the pulse in time. The resulting time will tell by calculation the RPM of the disk. I am wanting to do such a thing and wondered if anyone out there knew the best way to measure this pulse width. The RPM may vary greatly and as such the time probably needs to be a 14 or 16 bit time value. I have an PIC18F4620 chip I am working on.

    Ideas Please!
    So, what's your hardware actually going to look like? How are you wanting to drive the pulse input from the wheel? IR? Beam-breaker? Hall effect?

    When you can get a good pulse coming from the disk, you can time the difference between the pulses, 1st pulse starts the timer, 2nd pulse stops the timer, saves the value, code resets the timer/counter and awaits the 3rd (actually back to the 1st) pulse.
    Use any 16 bit timer with a pre- and/or post -scaler.
    Just as an example here...if the rpm gets too great, the pulses get too close together, less than 256 counts, you could turn down the prescaler (down to a point anyways) to make the timer 'more accurate' for those speeds.
    If the rpm falls off, and you get close to maxing out the timer/counter, say above 50,000, and you could turn up the prescaler to make the timer 'less accurate'. The accuracy won't be changing, but the method in which you calculate the rpm will.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi,

    << The RPM may vary greatly >> ... ha,ha ...

    YES, but from how much to how much ??? and what is the precision looked for ???

    The simplest way would be to use a 16 Bits timer/counter ... you have 3 aboard.
    could feed another 16 bits soft counter ... if really needed.

    as our INTERNATIONALs Mel & Darrel showed us how to deal with 31 bits numbers, DIV32 could be used to recover some "easy to use" 16 bits results.

    Then Just read result when needed ...

    Alain

    Other simple solutions using a soft-switchable pre-divider ...

    43 to 32000 rpm with a simple 16C84 ( PbP programmed ! ) ...i.e. with .1% precision.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile how about

    Hi Paul,

    Is there a reason to use 5% and measure pulse width?
    Could you just count the revolutions, for a time period and multiply to get revolutions per minute?

    Search the forum for: rpm*

    http://www.picbasic.co.uk/forum/showthread.php?t=2811

    http://www.picbasic.co.uk/forum/showthread.php?t=1150

    http://www.picbasic.co.uk/forum/showthread.php?t=366

    Skimask, the adjustable prescaler idea is a really good idea.

    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    Skimask, the adjustable prescaler idea is a really good idea.
    -Adam-
    I thought it was kinda slick. Came in handy for a low end freq counter from awhile back, worked from near 0 to something like 50khz with oscillator precision, (+/- 1 count of course). Same principle on the rpm thing.

  6. #6
    Join Date
    May 2007
    Location
    Harvest, Alabama
    Posts
    10


    Did you find this post helpful? Yes | No

    Default RPM Issue

    I have first to thank everyone for responding quickly.
    The problem with my RPM calculation is that it needs to be fairly precise and in fairly close to real time. The preferred device I have to count is an optical counter which will have a wheel and blank spaces so I have the option of counting either the length of the width of the blank space or of the null from the disk. High or low pulse counting option is what I am looking at. I really need to count the specific one pulse width issue and maybe keep a sum of these like 5 in a stack because this is fairly "now" use data.

    The next thing I need to do is execute a pulse to do my control function that varies in length with RPM. (Function of degrees of turn of the device and latency of the control circuit) This I expect will be on a lookup or a formula depending on the math I can do. This pulse will be executed a period of time delay after the timing (RPM count) pulse comes in and will execute a turn off of the pulse after a short period of time based on the RPM.

    I am needing help figuring out the way to count the pulse so that the counter does not affect timer accuracy and responds with about 1/10,000 sec accuracy.

    The RPM will be slow relative to some of the response posts. It will be 0-1,800 RPM. At this time it is more likely to stay below 600 RPM. The device will have extreme torques on it allowing a substantial variance of the RPM in time so I need to respond in real time. It may seem that the speed of response is not critical but the device is definitely needing this accuracy. 1/1,000 it too inaccurate. Honestly I would like to push it closer to 1/100,000 sec.

    If somebody thinks Hall Effect is better for this I can use it. The latency is the issue. The sensor latency needs to be low. I am looking at 1/1000 to 5/1000 delay in the sensor as is. Circuit delays are real issues in this device. If somebody knows a sensor with wheel package already done up I am all ears.

    So I have 2 issues. Pulse width measuring or RPM counting by other means and timer interrupt On and timer interrupt off counting without the first timer failing the operations of the second timer.

    This could be 3 timers operating, I expect that. (1) to keep up with RPM. (2) To time the initiation pulse ON condition. (3) To time the initiation of Pulse Off condition.
    Better Ideas are always welcome.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by CluckShot View Post
    Better Ideas are always welcome.
    The method I mentioned above will give you an almost instantaneous rpm reading, so long as you can figure out how to keep good track of time (that's up to you, I'll help you along, others here will help you along, somebody here might spell it out for you and even write the whole program, but I, for one, am not going to write the complete code for you).
    You read one pulse, save the time that pulse happened (read one of the timers), you read the next pulse, save the time the 2nd pulse happened, and subtract the 1st pulse from it. Read the 3rd pulse, subtract the 2nd pulse from it, etc.etc.
    After reading a pulse, do the math on it, reciprical functions (i.e. 1 pulse per second = 1 rpm, 2 pulses per second = 2 rpm, etc., less time per pulse = more rpm).
    Assuming you use PBP math functions to do the multiplication/division on it, you could easily get a solution within 1/1000 of a second. Use a few look-up tables and a fast PIC, and that number could go down into the microseconds.
    As far as controlling whatever you are controlling, you're looking at using a PID control loop to keep the rpm constant under varying loads. It's the same principle with microprocessor controlled voltage regulators, only an electrical load vs. a mechanical load.

    And give a hard thought about what you really NEED vs. what YOU want . I can't think of very many things that need instantaneous correction within one us...and I can think of fewer things that can possibly respond inside of a handful of microseconds, much less 10 us.

  8. #8
    Join Date
    May 2007
    Location
    Harvest, Alabama
    Posts
    10


    Did you find this post helpful? Yes | No

    Default I guess I was explaining

    I have really only wanted a basic description of the process solution. I am not asking for code so much as use timerO to count ... and timer1 to count. This is sort of a process thing rather than expecting detailed answers. I did ask and get a detail question on pull-up resistors because I simply didn't know the answer for sure. Thanks all

Similar Threads

  1. Interrupt RPM and Taylors Elapsed time on 18F4620
    By Tobias in forum mel PIC BASIC Pro
    Replies: 70
    Last Post: - 3rd February 2010, 16:12
  2. Slow code needs a tune up
    By Tobias in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th January 2010, 15:05
  3. Pulsin vs. Interrupt RPM measurement
    By Tobias in forum General
    Replies: 1
    Last Post: - 31st December 2009, 01:29
  4. 16f877A and tmr1 external crystal question
    By comwarrior in forum General
    Replies: 3
    Last Post: - 13th July 2009, 00:40
  5. RPM - DIV32 Problem
    By davewanna in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th April 2008, 04:33

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts