Shop OBEX P1 Docs P2 Docs Learn Events
how to get rpm using freqin — Parallax Forums

how to get rpm using freqin

Have been using count on 37 & 20 tooth sprockets. But not getting the resolution needed because of the multiplication when reading 3 shafts for 500 ms .
Can't really find any examples of calibrating odd sprockets for true rpm

Comments

  • If your sensor can see the transitions, you might use PULSIN and calculate from there.
  • Lol.. more specifically I need to turn the pulses from a 37 tooth sprocket going approx 650 rpm into a serial lcd for display.
    I used count for 500ms then *2 for full second count..... then tried *162 then / 100 to correct for 37 teeth instead of 60.... that locked up the register going over 65,000 count..
    so then tried /100 & *162 and that wouldn't read..... so I'm wanting to try freq in but don't know how to correct it...
  • Trying to get my mind wrapped around this. Is the COUNT function counting the sprocket teeth going past a sensor? In other words, one revolution would yield a count of 37?
    If that is the case a 37 tooth sprocket turning at 650 RPM would yield a count of just over 200 in 0.5 seconds, or 400 per second.
    Divide 400 by 37 and we get 10 in integer only math. (Actually 10.81). Multiply 10 rev/second by 60 and you will have 600 RPM. Error caused by integer math.
    If we scale up the 400 by 10 to 4000, divide by 37 and then multiply by 6 the answer becomes 648, much closer to 650.

    I admit I'm not sure what the *162 /100 is supposed to do.
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2015-11-06 07:19
    rpm 
     = (count per 1/2 second) * 2 * 60 / 37
     = (count per second)  * 1.62162
    
    for Stampese using */ operator:
    rpm = countsec */ 415
    
    (figure 415/256=1.621)
    
  • Thank you, Tracy, for letting me see what should have been so obvious.
  • Not obvious but in the numbers game! Actually, */416 probably works a little better than */415. That is to compensate for the fact that both the counting and the */ operation tend to underestimate.
    400 */ 415 comes out at 648, but 400 */ 416 comes out at 650.
  • So would my original way of taking count for 500ms *162/100 not be a reliable way to calculate rpm?
    And also I was actually wanting tips on how to calibrate using Freqin where you only measure the time of one pulse. ...low to high to calculate rpm. ...
  • If you want to measure just one pulse, you probably want PULSIN and not FREQIN.
  • OK . Then how do you calibrate PULSIN on a 37 tooth sprocket for rpm
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2015-11-17 22:06
    So would my original way of taking count for 500ms *162/100 not be a reliable way to calculate rpm?
    And also I was actually wanting tips on how to calibrate using Freqin where you only measure the time of one pulse. ...low to high to calculate rpm. ...

    500 * 162 = 81000, which is a larger number than the stamp can handle. Believe me, the method using the fractional multiply operator */ will simplify the Stamp workload.

    About pulsin, the faster the rpm, the shorter the pulse. You can measure the many pulses and average them to take out some of the variation from one tooth to the next. The math is basically a constant divided by the pulse width. The constant you probably calibrate empirically, because it will depend on the shape of the tooth and the diameter out to the sensor.
  • Determine the width of the sprocket in degrees. Observe that there are 360 degrees in one revolution. Measure the time it takes the sprocket to pass a given point. Do the arithmetic.

    It may be possible to measure the period *between* sprockets which would likely give you more resolution (since the sprockets are further apart than their width).
  • Use the pulses from the sprocket e.g. with Hall sensor, or a magnet+reed switch, to charge/discharge a capacitor in an RC network, then the voltage over the capacitor will be proportional to the RPM. Measure the voltage with an ADC and you have a word number for the RPM. Calibrate it with another RPM meter to get a scale factor.
Sign In or Register to comment.