This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Frequency Meter

Hi,
I want to develop a frequency meter with a resolution of .01 Hz. I am using 89c51 and a 12Mhz clocker. Kindly let me know how to do it. Thanks

Parents
  • Hi Drew,
    Thanks for your response. I am looking at monitoring the line frequency, i.e. around 50 to 100 cycles. I want a resolution of .01 Hz. I used the counter method, where i count for a specified period of time and divide the counter value by the time. The max. resolution i can get is 1 Hz. I can get an resolution of .01 Hz, but i have to set the timer to 100 secs, which is too large. I have to monitor the frequency every 2 or 3 secs. Hope i have made myself clear. Thanks

Reply
  • Hi Drew,
    Thanks for your response. I am looking at monitoring the line frequency, i.e. around 50 to 100 cycles. I want a resolution of .01 Hz. I used the counter method, where i count for a specified period of time and divide the counter value by the time. The max. resolution i can get is 1 Hz. I can get an resolution of .01 Hz, but i have to set the timer to 100 secs, which is too large. I have to monitor the frequency every 2 or 3 secs. Hope i have made myself clear. Thanks

Children
  • 0.01 Hz is a period of 10ms which is a long time to a microcontroller. A simple solution might be to have an interrupt running periodically with a period of (say) 1ms and use a bit of software to increment a 32-bit counter.

    For continuous sampling, you will need to at least double-buffer the results. When the count is complete, you could trigger another interrupt internally or set a flag that will be checked on a round-robin basis.

    This will consume significant processor resources, but if you are careful this should not be a problem. The main advantage of this approach is its simplicity. You might also want to take the opportunity to do some filtering such as removing glitches - much easier this way.

    A 10ms interrupt period could still reliably give you the required resolution if you add some simple digital filtering such as taking the mean of 10 consecutive samples.

  • Trying to do this with a microcontroller may already be the wrong approach. Analog tools may well be cheaper --- I suspect some power plants out there still use mechanical tuning forks for this.

    That said, if you really want to do it using a micro, counting alone won't do it. You have to measure the duration of a certain number of cycles and do a division, instead. E.g. generate a zero-crossing signal, wire that to an interrupt input, and count for, say, 50 cycles. Have a second counter running free at a fixed frequency (CPU clock divided by something suitable, or an external reference oscillator). Start it on the first of those 50 cycles, and stop it after the last. Read it out, and you have the time taken for 50 cycles. Should be 1 second. The difference is your measurement.