Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: FreqCount Resolution change

  1. #1
    Junior Member
    Join Date
    Jul 2021
    Posts
    2

    FreqCount Resolution change

    Hi all,

    I'm trying to read frequency from a 10 MHz crystal using OpenQCM's Arduino and shield, and their default .ino uses the FreqCount library with a 100 ms interval.
    Problem is, that library measures the frequency during 1000 ms, but I want to measure every 100 ms. You can shorten the measurement interval, but this lowers the resolution too. It will now count for 100 ms and count the amount of upwards slopes as the frequency, but in reality it is 1/10th of the frequency since you measured 1/10th of the time. You have to multiply by 10 to get to Hz again, but then you're basically rounding to the nearest 10 Hz since the output variable "count" is an uint32_t. Is there a way to get the unrounded number?
    Has anyone tried to make it a float or is there another way to decrease the measurement time without losing resolution?

    I hope anyone has a solution... I'd really want a finer resolution in my data.

    Thanks,
    Joost

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,345
    You simply record 10 values per second, being the counts at 0.0s, 0.1s, 0.2s etc, and when a new value comes in take
    the difference from the one 1.0s ago. Display can update every 0.1s, the counts are for a whole second so have 1Hz resolution.
    Or just use a running average using floating point, and a time constant of around 1s.

  3. #3
    Junior Member
    Join Date
    Jul 2021
    Posts
    2
    That is a clever solution, thanks!
    I'll try it now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •