Reading frequency at very low pulse rate
I am really stumped!· This is my third shot on this forum to try to solve a problem I am working on. I am working on a rate meter that requires the stamp to read pulses and calculate a rate for me.· I will be using a gear tooth sensor that on a shaft that will turn as slowly as·2 rpm. The sprocket will have 10 teeth on it so the incomming rate of pulses will be 20 pulses/minute or .333/sec.· using pulsin I overflow the counter at this rate. the lowest I can get with pulsin is around 8 pulses/ second.· I would like to update the frequency reading at least every 3 seconds. Can anyone please give me some ideas on how to get a resonable frequency reading at these low pulse rates?· I've been working on this for quite a while now and am ready to give up.· Is there a way to keep a running average of the pulses comming in and compare them to a clock of some sort? please be specific, I have found that answers on this forum, as well meaning as people are, can tend to be rather vague.· thank you
Comments
A silvered panel on side of each tooth and a v beamed optical senser migh be the answer.
Magnetics at slow speed may be the problem in your case.
73
spence
k4kep
agentile·
·
To calculate the rate, you need to specify, what stamp you use, because the speed of the stamp will define the max pulse width.
Few suggestions:
1 count the leading and falling edge of the sensors == you get 40 pulses instead of 20 ; still to much; 1.5 second length to count.
2 Use two (word) variable. The first one will count the pulsin . ·Monitor this variable, and when the count > 50000 ( easy to manipulate) reset the pulsin variable to zero and increment the second variable by one
With a Bs2PE at 40 pulses / minute, you will get approximately 15 counts on second variable, and 47872 counts on pulsin variable. Total pulses counted = (15 X 50000) + 47872 =·797872.·· 797872·X 1.88usec =·1.4999936 sec. From there is just plain math.
I suggest to use greater then 50000 when you rollover, as I am not sure if you can catch the equal 50000 moment. However, in your case, few + or- counts will not make a big difference.
Good luck
Ion ·
owlogic.com/BS2speed.htm#longpulse
To measure the period with the Stamp without an external chip, the PBASIC program waits for the input to change state, then counts tight loops until the input changes to that state again, one whole period. The count will not be exactly in milliseconds, but a simple conversion factor can make it so. Or, for your purpose, you may need to do a division to convert period to frequency. Something like this:
On a BS2, the above loops will accumulate about 1200 ticks per second. So at 0.333 second, it would be about 400 ticks, corresponding to 2.0 rpm. So myconstant=8000. But each stamp will require a calibration step to determine the appropriate value for "myconstant".
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com