Hi,
Not really but it depends on the resolution you need. If the gate time is one second and the input frequency is 2Hz then the prescaler will count to 2 during each gate period - therefor you'll get a result of 2Hz. But if the frequency is 2.5Hz then the displayed result will "flicker" between 2 and 3 Hz. If the gate time is increased to 10 seconds the prescaler will accumulate 25 counts which, when divided by 10 is 2.5.But it would mean then, that the smallest frequency, which I could measure in one second is 256 Hz.
For lower frequencies i would have to increase sampling time.
[quote]Lets say, it is very rare, that one needs to measure frequency below 20 Hz in normal application.
That would mean, that in 1 second sampling time there will be 20 counts in prescaler, which in turn means we would have to provide 256-20=236 counts more to overflow it.[quote]
That's correct!
No, not at all.So, 236 remaining counts divided by 20 gives us 11.8 seconds! We will need to increase sampling time to 11.8 seconds, in order to measure 20 Hz frequency, or ?!
After the one second gate time the prescaler will hold 20 (which is the correct input frequency since the gate time was 1 second). By counting the number of additional pulses it takes for the prescaler to overflow you know what value was in the prescaler. It'll require 236 pulses which when negated is 20.
Yes, the "gate time" needs to be exactly 1 second but the total time for the measurment, the "prescaler value extraction", calculation and display will of course be a bit more than the gate time alone.Or "manual counting" in your example is the part of the code, which fills out the precaler by toggling PSCLKOUT for 3uS instead of using actual measured frequency to increase the count? Than it schould be significantly faster, than 11.8 seconds. In fact, it should be just very sligtly over 1 second for 20 Hz, or?
/Henrik.
Bookmarks