Reading hz more accurately

RobinArvidsson 6 years ago in IQANdesign updated by Ulrik Zakariasson (Software development) 6 years ago 9

i am using a FIN to read an RPM sensor. The sensor has 30 pulses per revolution.

Today we are getting an even value (2-4-6-8 etc.) of off the sensor. in other words 1Hz is the lowest given pulsefrequenzy. ( 1 pulse per second = 2 rev per minute 1*60/30 )

i would like to be able to read half an rpm, or even 1 rpm steps would work ( 0,5Hz )..

is this possible?

i know i could average an Array, but i would assume the FIN could give me a more accurate read, with less delay?


Satisfaction mark by RobinArvidsson 6 years ago

Hello Robin,

I have been doing some experiments with this topic lately, here are some pointers:

- A moving average filter will do about the same as averaging an array (and with one channel)

- Our input was a sinewave in mV, so hooked it up to a VIN as well, counting flanks. If this is the case you might do something to get 1/2 hz. Keep in mind that we couldn't do high speed inputs because of cycle times.

Hey, thanks for the pointers. yes, i've used average filter as well, but could i use that into a PID channel? 

i was thinking that i would need a better value from the actual FIN channel to feed the PID with to be able to regulate this in the best way..

No, we can get from 0,5hz to 105hz (1 - 210 rpm), so the cycle time messes up any counting of pulses or flanks.. 

If you use FIN on an expansion module, e.g. XA2 or XC21, the expansion module CAN protocol limits the resolution to 1 Hz. Locally on the module the frequency is measured by counting flanks and it also applying a moving average filter, with a total time depth of 500 ms. 

To get a more application specific balance between accuracy and response time, you could experiment with applying your own moving average filter to a PCNT based frequency calculation. 

A limitation is the window size of the SFC channel moving average, but you could cascade multiple filters (which is essentially what happens when applying a moving average to e.g. an XA2 FIN) 

See IQANdesign 5 solution library for a template: 

Perfect, Thank you. I'll test the template. 

is there any specific reason i would need the reset pulses signal?

When would be ideal to reset the pulses?


The reason is that when you have accumulated a high number of pulses, you may bump into an issue with how accurately the PCNT channel can represent its scaled value. The PCNT channel has value type Real, which means it can accurately represent up to 7 significant digits. It is reset on startup (assuming you don't use store value), but if you risk exceeding this before restarting the system, you should add a function for resetting it.

i actually use the FIN on a MC43, if that makes any difference.

For PCNT, it does not make a difference. 

For FIN, I am surprised that you say you measured the values you did. FIN frequency measurement on the MC4x is based on counting the time between flanks instead of counting pulses. This method makes it more responsive than e.g. an XA2, but it has to come with a timeout, this is set at  200 ms , which is why the MC4x Appendix A information states 5 Hz as the lowest frequency when the pin is configured as FIN. 

Ok, then i'll need to use the PCNT channel, since i need less than 5Hz. unless the 200ms limit can be altered. 

Thanks for the response.