Abstract:
A method of measuring frequency samples a waveform, calculates waveform voltages based on an initial time base and adjust the time base for a particular waveform to determine the actual frequency of the measured AC power. A microprocessor can be used to implement the method so a small quantity of electronic elements is required, and the manufacturing cost is low.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The present invention relates to a method of measuring frequency, and more particularly to a method of measuring frequency that is able to obtain a correct frequency reading from a distorted AC power source which includes noise, harmonics or abnormal utility waveforms. 
     Furthermore, a frequency detector that uses the method is able to use significantly fewer electronic components than are required in conventional frequency detectors. 
     2. Description of Related Art 
     In general, an AC power source outputs unstable power with unstable resistance of electronic equipment. Therefore, a switching power supply with angle detection and using a power source, such as utility power generator, etc., detects the frequency of the power that is usually necessary. 
     With reference to FIG. 5, a conventional first stage ( 50 ) of a switching power supply includes a differential circuit ( 51 ), an angle detection circuit ( 52 ) and a voltage detection circuit ( 53 ). Two input ports of the differential circuit ( 51 ) connect to the alternating current (AC) power source to compact the AC power. The output terminal of the differential circuit ( 51 ) connects to the input terminal of the angle detection circuit ( 52 ) to obtain a sample output voltage from the differential circuit ( 51 ). Then, the angle detection circuit ( 52 ) is able to calculate the frequency of the AC power by calculating the interval of two adjacent quadrilateral-wave falling/rising edges. 
     When the angle detection circuit ( 52 ) outputs continuous pulses, a microprocessor (not shown) determines the frequency of the AC power. However, the angle detection circuits ( 52 ) uses a comparator, and when high voltage with noise is input to the comparator, the comparator outputs a signal that includes an error pulse in the normal pulses. 
     Therefore, the angle detection circuit ( 52 ) is sensitive to the noise, harmonics and other abnormal utility waveforms, so that the comparator has no correction frequency detection capability. 
     With reference to FIG. 6, the difference between another conventional first stage ( 50   a ) of a switching power supply and the previously described conventional stable circuit is that the angle detection circuit ( 52   a ) consists of a transistor (Q) and resistors (R a , R b , R c ). The angle detection circuit is able to transform the output AC signal of the differential circuit ( 50 ) to continuous pulses. The angle detection circuit ( 52   a ) is able to perform a frequency measurement, but it also has problems such as high noise sensitivity. 
     To overcome the shortcomings, the present invention provides an improved method of measuring frequency to mitigate and obviate the aforementioned problems. 
     SUMMARY OF THE INVENTION 
     The objective of the present invention is to provide a method of measuring frequency, wherein the method is able to obtain highly accurate frequency measurement results without using an angle detection circuit. 
     A further objective of the present invention is to provide a method of measuring frequency that will be lower the manufacturing cost of the equipment. 
    
    
     Other objects, advantages, and novel features of the invention will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings. 
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a functional block diagram of a method for measuring frequency of AC power in accordance with the present invention; 
     FIG. 2 is a graph of time versus voltage of a method for frequency measuring of the AC power in accordance with the present invention; 
     FIG. 3 is a logic diagram of the method for measuring frequency of AC power in accordance with the present invention; 
     FIG. 4 is a circuit diagram of a method for measuring frequency of AC power in accordance with the present invention; 
     FIG. 5 is a circuit diagram of a conventional first stage of a switching power supply; and 
     FIG. 6 is a circuit diagram of another conventional first stage of a switching power supply. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT 
     With reference to FIG. 1, a method for measuring the frequency of AC power comprises the following steps: 
     setting an initial time base; 
     dividing a cycle of the AC power present into multiple parts; 
     calculating the voltage of each part of the cycle; and 
     determining the frequency of the local AC power. 
     In the setting an initial time base step, the normal cycle of the local alternating current (AC) power is used to set up a time base. 
     In the dividing a cycle of the local AC power step a sample cycle is extracted from the local AC power in accordance with the time base. Then the sample cycle is divided into multiple overlapping parts in accordance with a ratio. The overlapping parts have adjacent parts and isolated parts. The isolated parts overlap a portion of the adjacent parts. The cycle is composed of the adjacent parts. The ratio is a ratio of the isolated parts to the adjacent parts. Each part has a voltage. For example, where a cycle is divided into four segments and each part is two consecutive segments, the time of the isolated part equals the sum of half the time of the two adjacent parts. This can be further generalized by stating that the time of the isolated part overlapping two adjacent parts is equal to the sum of half the time of the adjacent parts. 
     In the calculating the voltage of each part step, the voltage of each part is calculated by integral calculus techniques. 
     In the determining the frequency of the local AC power step, a result is obtained by summing up the voltage of adjacent parts. Secondly, the result is checked to determine if it is close to zero. If the result is zero or nearly zero, the frequency measurement is equal to the reciprocal of the initial time base. If the result is not close to zero, the process is executed from the setting an initial time base step to the determining the frequency of the local AC power present step. 
     With reference to FIG. 2, a graph of time versus voltage of a normal AC power sample shows multiple parts in a sample waveform of the AC power. This graph is a particular embodiment of the method where the sample waveform is divided into four segments and three parts. Because the normal frequency of the local power supply is 50 Hz˜60 Hz, the time base is set to 20 ms in the setting an initial time base step. Before executing the next step, the sample cycle is divided into multiple overlapping parts. For example, the sample cycle is divided into three overlapping parts, wherein the time of the sample cycle equals the sum of the time of the second and third parts. 
     Because a normal sample cycle has a negative half cycle and a positive half cycle, the sum of the voltage of a whole sample cycle should be zero. In the calculating the voltage of each part step, three voltages are calculated respectively using numeric integral calculus techniques. If the each of the two adjacent parts of the three parts is equal to half of the sample cycle, and the present sample cycle is normal, a sum of the two parts is zero. On the other hand, if the sum is not equal to or close to zero, the frequency of the local AC power is not normal. 
     When the sample cycle waveform includes harmonics or noise, the harmonics or noise is canceled in the sum of the voltage during the calculating the voltage step, because an area of noise is small with respect to the entire waveform and the part. Therefore, the method of detecting and calculating the frequency is able to eliminate the noise influence. 
     With reference to FIG. 2, the cycle waveform above with natural functions is divided into the following areas: 
     SA 1  is the area of the voltage (V (t) ) in the part Ac between 90° and 270° of T base , that is, the sum of the voltage between T base /4 and 3*T base /4; 
     SB 1  is the area of the voltage (V (t) ) in the part B 1  between 0° and 180° of T base , that is, the sum of the voltage between 0° and T base /2; and 
     SB 2  is the area of the voltage (V (t) ) in the part B 2  between 180° and 360° of T base , that is, the sum of the voltage between T base /2 and T base .              SA1   =         ∫     Tbase   4         3   ×   Tbase     4              v        (   t   )       ×                   t         =       ∫     Tbase   4       3   ×   Tbase              2        v                 sin                   (         t   -   x     T     ×   2      π     )             t                       =           2     ×   V   ×   T       2      π            {       -     cos              [     π   ×     (         3   2        Y     -     2      θ       )       ]       +     [       π   ×     Y   2       -     2      θ       ]       }                   SB1   =         ∫   0     Tbase   2              v        (   t   )       ×                   t         =       ∫   0     Tbase   2              2        v                 sin                   (         t   -   x     T     ×   2      π     )             t                       =           2     ×   V   ×   T       2      π            {       -     cos              [     π   ×     (     Y   -     2      θ       )       ]       +     cos              [     π   ×   2      θ     ]       }                   SB2   =         ∫     Tbase   2     Tbase            v        (   t   )       ×                   t         =       ∫     Tbase   2     Tbase            2        V                 sin                   (         t   -   x     T     ×   2      π     )             t                       =           2     ×   V   ×   T       2      π            {       -     cos              [     π   ×     (       2      Y     -   θ     )       ]       +     cos              [     π   ×     (     Y   -     2      θ       )       ]       }                                    
     Because the sample cycle waveform is divided into three parts A 1 , B 1 , and B 2 , three natural functions are used to respectively describe the three parts of the sample cycle waveform. Observing the above equations, a rule is defined:          SA1   ×   cos                   (       π   2     ×   Y     )       =       SB1   +   SB2     2                            
     and then the above equation is completed by introducing the following equation: 
     
       
         cos α×cos β=[cos (α+β)+ cos (α−β)]/2 
       
     
     Thus a relationship between time base T base  and an inverter frequency of the AC power T is obtained. 
     
       
           T   base   /T=f/f   base =2/π cos −1 [( SB   1   +SB   2 )/2 SA   1 ] 
       
     
     With reference to FIG. 3, to begin with, an initial T base  in accordance with the normal cycle of the local AC power is set, and a sample T A/D  to divide an entire sample cycle is set into multiple parts. Then, the three voltages of each part SA 1 , SB 1 , and SB 2  are calculated. 
     Per the foregoing functions, a constant k equals (SB 1 +SB 2 )/( 2 *SA 1 ). If the sample cycle is normal, k=0 is obtained because of SB 1 =−SB 2 . Then, due to the ratio Y=T/T base =1, the frequency of the local AC power is normal. 
     Ifk≠0, T and the T base  ratio Y are obtained, therefore, a new time base is able to be reset in accordance with the ratio Y. Then the setting an initial time base step of the method is executed until the ratio Y equals 1. 
     With reference to FIG. 4, the previously described process is implemented in an electronic element, such as a microprocessor ( 11 ), a signal chip, etc., with appropriate programs. Whereby, the microprocessor ( 11 ) replaces the conventional angle detection circuit to reduce the manufacturing cost. 
     Although the present invention has been explained in relation to its preferred embodiment, it is to be understood that many other possible modifications and variations can be made without departing from the spirit and scope of the invention as hereinafter claimed.