Confirmation on Frequency Counter

Thread Starter

bobby19

Joined Jun 3, 2007
13
Hi - I've been out of the digital world for a while now and I just want to confirm my thoughts/understanding.

I want to measure the outlet frequency:
-I plan to use a transformer to first step down voltage and then recitify it to a square wave.

*Here is where I want to confirm my understanding*
An oscillator will essentially act as the reference clock
The rectified square wave will be compared to the oscillator
Every clock cycle, it will look for a rising edge
If a rising edge is detected, a counter will be incremented
When the preset sampling period is over, the number of rising edges (count) will be divided by the sampling period (seconds)
Reset counter and loop again

This is obviously high level, but am I right in my understanding of frequency count and oscillators?

Thanks!
 

beenthere

Joined Apr 20, 2004
15,819
You're close. The internal clock is usually a stable oscillator that is used to control the period that the external signal is gated in. If the period is 1 second, then the internal counter that is clocked with each external signal will read directly in Hz.

Your idea about a transformer is excellent - it's the only safe way to observe the line frequency. Use half wave rectification to preserve the original frequency and pass the sine wave across a pot for level control. Use a Schmitt trigger gate to convert the signal to a digital pulse train for the internal counter. The count is as good on rising as it is on falling edges.
 

Markd77

Joined Sep 7, 2009
2,806
If you need high accuracy then measuring the number of cycles in a second is not the best way to do it. That would give 2% accuracy. A better way is to time how long it takes for 50 cycles (for example). It should be easy enough to get better than 0.1% accuracy with this method and a crystal oscillator.
<ed> 2% figure is for mains at 50Hz </ed>
 

Wendy

Joined Mar 24, 2008
23,415
This would work for countries with 50Hz, not so well with 60Hz. Line frequency is a quick and dirty way for a time base, a 10 Mhz crystal is a better way. But like my signature says, good enough works.
 

SgtWookie

Joined Jul 17, 2007
22,230
In the US, there are actually small fluctuations/deviations in the 60Hz line frequency, so from second to second you may notice some difference. When deviations in frequency occur, the load on the power grid is rather high, so they try to keep the deviations as small as possible.

Over a longer period of time, say 24 hours, the net deviation will be extremely small.

An uncompensated crystal oscillator's frequency may vary fairly significantly depending upon temperature. If used as a time base for a clock, the errors will quickly accumulate, and at the end of a week you may find the errors accumulate to several minutes.

One way to stabilize a crystal oscillator is to keep it's temperature constant; an oven-controlled crystal oscillator (OCXO). This can actually be done quite simply and inexpensively. Roman Black has thoughtfully posted an inexpensive and effective means for creating a crystal oven on his website:

http://www.romanblack.com/xoven.htm

This will improve the stability of an xtal oscillator by several orders of magnitude.
 

Wendy

Joined Mar 24, 2008
23,415
Battery backup, same as in most digital clocks.

The diodes switch between the power supply with the most voltage. If AC goes down that leaves the battery.

When you get over 10 posts you will have the ability to delete posts. Handy for the accidental double post, which happens to us all.
 
Top