Problem/question about frequency period counter
turbosupra
Posts: 1,088
Hi,
I am using the jm_freqin object, specifically the period method that counts cycles between a pin seeing a high and the next time it sees another high. My problem is that I need to sample faster than the method return value is being updated, so I get duplicate values. My dilemma is that the value update rate changes independently and randomly as far as the propeller is concerned, so a fixed sampling rate will not work and sometimes the previous and current values being identical are valid method return values as well.
I can't come up with a way to code around this so that I know I'm reading an updated value, and not a duplicate because of the sampling rate. Does anyone have any ideas?
Thanks for reading.
I am using the jm_freqin object, specifically the period method that counts cycles between a pin seeing a high and the next time it sees another high. My problem is that I need to sample faster than the method return value is being updated, so I get duplicate values. My dilemma is that the value update rate changes independently and randomly as far as the propeller is concerned, so a fixed sampling rate will not work and sometimes the previous and current values being identical are valid method return values as well.
I can't come up with a way to code around this so that I know I'm reading an updated value, and not a duplicate because of the sampling rate. Does anyone have any ideas?
Thanks for reading.
Comments
If, when you call it, it returns zero, you will know that it hasn't updated since the previous call.
-Phil
Thank you so much Phil, a simple solution that works great.