Patent Description:
In various fields of technology and industry, an accurate and fast measurement of the frequency of a signal is required. To name but a few, it is necessary for the control of equipment connected to a power grid operator, and also for the stability of the power grid itself as a whole. Generators and loads must adjust its consumption or generation pattern according to the value of the frequency or its derivative measured at its connection point. Likewise, the measurement of the frequency at various geographical locations provides the entity in charge of the control and regulation of the electricity grid with elements of judgement with which to make decisions. For example, to order the connection or disconnection of generation groups in real time, preventing the grid from becoming unstable or collapsing. Certain electrical protection relays depend on frequency measurements, as they are responsible for disconnecting circuits when the frequency exceeds certain limits.

Currently, accurate frequency measurement is usually done with very complex equipment and permanent GPS (Global Positioning System) synchronisation, which prevents its mass use in embedded equipment. These techniques do not provide sufficient immunity to signal disturbances (e.g. harmonics), nor to low-frequency modulations of the signal amplitude and phase. Moreover, the measurement of the frequency derivative of the grid, which is, in many applications, a key variable in providing stability to the power grid, is particularly poor. The frequency derivative is a reflection of the time lag between instantaneous power generation and demand. If a frequency measurement with low latency (defined as the time between the occurrence of a change in the network and the time it takes to identify it) is required, the accuracy is substantially reduced. If, on the other hand, a precise measurement is required, then filtering is introduced which results in a delay in the output of the equipment that is a source of instability in a control circuit.

Currently, there is no uniform approach to the frequency measurement method, and there is a significant gap between the measurement performed by protection relays, equipment specifically dedicated to frequency measurement (e.g. PMU -Phasor Measurement Unit-) and power quality equipment (Power Quality Meter).

Considering the limitations identified in the prior art, a process and a system for measuring the frequency of a waveform and/or its derivative corresponding to an input signal according to the independent claims is presented. Particularly advantageous embodiments are defined in the dependent claims.

Mathematically, if a signal is periodic, its frequency is constant (and its derivative null). In this paper, a less strict definition is used. Generally, a signal is said to be periodic because it repeats in cycles. The length of the cycles may vary, which means that the actual frequency value varies from its nominal value. The procedure and system is primarily applicable to input signals, both analogue and digital, which are cyclic, i.e., which are quasi-periodic in the mathematical sense.

Existing inventions that could be more closely related to the invention to be patented will be discussed below. For obvious reasons, technologies based on completely different mathematical concepts, such as synchrophasors or Clark or Park transforms, are not analysed.

In all the inventions reviewed, clocks with a fixed sampling frequency are used.

A number of patents focus on frequency measurement by measuring the time between two zero crossings of the signal and calculating its inverse value, in some cases applying filtering, interpolation or integration around the crossings to estimate the intersection more accurately (<CIT>, <CIT>, <CIT>, <CIT>, <CIT>, <CIT>, <CIT>, <CIT>, <CIT>); in these inventions the frequency is estimated by taking several network cycles and calculating their average period value.

Other patents improve the estimation by applying a typical hysteresis comparator instead of a zero-crossing comparator, usually with a pair of thresholds, one positive and one negative which is its opposite (<CIT>, <CIT>, <CIT>, <CIT>, <CIT>). By this change, instead of measuring the period of the periodic signal, the period of the output of the hysteresis comparator is measured, which is much more immune to noise (a particular case is patent <CIT>, which limits itself to creating the square hysteresis comparator signal, but without estimating the frequency). In addition, some of the patents analysed improve the measurement of the periods by applying filtering prior to the hysteresis comparator (<CIT>), or a more complex process of attenuation, rectification of the signal and setting a positive threshold around which the hysteresis levels are defined, also positive (<CIT>); however, these filters inevitably add phase shifts and therefore delays in the calculation of the frequency.

More elaborate methods are also employed, such as in <CIT>, where in four consecutive zero-crossings the input signal is adjusted to a hypothetical ideal signal whose frequency is defined as a function f(t) approximated by a Taylor series, and the frequency can be evaluated at any nearby instant t using precisely that function f(t). Or as in <CIT>, where the minimum of the convolution of the signal with itself is sought, in order to obtain the optimum value of the period and, therefore, of the frequency; furthermore, based on the stability of the calculated periods, it determines the quality of the measurement.

The main problem with most of the above inventions is that, in order to increase the number of period samples and gain accuracy, they must rely on a measurement interval of several or many cycles, so that if they do so they are not able to capture the dynamic frequency sense of the input signal, and if they do not they simply give a very poor measurement, with poor accuracy. Some of them attempt to correct for this by filtering and interpolating values, but the former inevitably adds delay, while the latter is very sensitive to noise and harmonics. In addition, the measurement of the frequency derivative is usually based on the approximation by the ratio of the increment and the time, thus using only one pair of values and the uncertainty of the resulting measurement can be very large; in this case the most direct possibility to increase the accuracy is to increase the denominator of the ratio, which adds delay, while still using only one pair of values for the calculation. Patent <CIT>, by obtaining a Taylor series of the frequency function f(t), is able to automatically evaluate its derivative algebraically, although the origin of the fit to that function still falls on a few points, so the accuracy is not expected to be good in real conditions either.

To measure the frequency of an input (analogue) signal, several steps are performed:.

The hysteresis condition is introduced to avoid bouncing, i.e. oscillations of the waveform around the level that serves to define the measurement function. A hysteresis condition defines two situations:.

That, from the first, higher level, it goes to a falling edge towards the second, lower level, when the waveform goes below the second selected level.

That, from the second level, it goes to rising edge towards the first level when the waveform rises above the selected level.

Well known and obvious methods based on the approximation of the derivative by its increments can be used to measure the derivative of the frequency (also named ROCOF or "Rate of Change of Frequency"). However, a much more accurate method is also proposed where the following steps are performed on an (analogue) input signal:.

To implement the operations of the method, the system includes an analogue-to-digital (A/D) converter, an anti-aliasing filter, a calculation unit with data processing capability (e.g., a computer, processor circuit, microcontroller, microprocessor, etc.) with associated memory to record the data. In cases where the input signal has a high voltage or current, a conditioner to work at levels of a few volts (V) or amperes (A). Further details and examples are given in the detailed description.

The anti-aliasing filter is used exclusively to avoid coupling the sampling frequency of the A/D converter with the high frequencies that the input signal may contain, which would cause the unrealistic effect of obtaining superimposed low frequencies in the digitised signal. It must be distinguished from other low-pass filters that are usually inserted in other frequency measurement systems, which are intended to filter lower frequencies than the anti-alising filter, as without them their calculation algorithms would not work properly.

An advantage of the technique proposed in the procedure and system is that it does not require sophisticated calculations, very high quality electronics or a very precise timing source. Thus, in certain embodiments, it can be implemented in embedded equipment or integrated circuits.

Another advantage of the proposed technique is that it is highly immune to superimposed disturbances on an input signal, so that, in most circumstances, it can avoid prior filtering to remove them. This results in a lower latency in obtaining the frequency measurement, since any filter adds an inertia between its output and input and therefore a delay in the observability of any variation, including its frequency.

The process and system can operate without external synchronisation and can use low-cost analogue-to-digital (A/D) converters.

The proposed technique can perform the calculations in a short time interval, with a minimum of one cycle of the input signal, which also means better behaviour in the event of amplitude and phase modulations of the signal. This is particularly positive for evaluating the frequency derivative, which is another important parameter for stability control in an equipment or system, and control systems can be implemented that use this variable and counteract an incipient loss of instability sufficiently in advance. Compared to other methods that are based on increasing the number of network cycles in order to obtain more samples and therefore a better estimation of the frequency, this one is based on increasing the number of samples without the need to increase the cycles, which results in better precision for the same calculation time.

In addition, it can optionally give the uncertainty of each measurement, both of the frequency and of its derivative, making it possible to know if each of the calculated values is of sufficient quality, a parameter that can be advantageous to discriminate the accuracy of the calculations with respect to the real physical phenomena. Other systems are unable to determine the uncertainty of each of the reported measurements, relying on laboratory certifications according to specific waveforms, which reduces the confidence in the measurements when there are strong disturbances in the network and it is necessary to operate with confidence and with precision.

The system and method described has multiple applications. For example, it can be applied in medical devices where heart rate monitoring is required. It is also particularly advantageous in power supply systems. In situations where the balance between power generation and power consumption is disturbed and when synchronous generators are used. They rotate at a nearly constant angular velocity resulting in a nearly constant mains frequency (e.g., <NUM> or <NUM> Hertz), if the power consumption increases, the synchronous generators slow down slightly, transforming some of their kinetic energy into electrical energy needed by the loads. This results in a reduction in frequency. The opposite also applies, so that if there is excess production, the generators speed up and the frequency of the grid increases, albeit slightly. If there are generation sets based on renewable sources, in most cases, there is no or very little inertia and there is no damping of power fluctuations. Therefore, the balance between generation and consumption has to be balanced by the system operator, ordering the connection or disconnection of generating sets on the fly. This is a time-consuming operation. If an imbalance occurs abruptly, e.g. after a sudden disturbance, it can lead to a collapse of the entire power system or parts of it. During the time of this process, the frequency can vary quite rapidly. Being able to quickly measure the frequency of the electrical signal and its derivative makes it possible to anticipate and implement measures that are not currently available.

In order to support the description herein and to help a better understanding of the features of the invention, a set of drawings is attached hereto as an integral part of the description, in which the following is shown for illustrative and non-limiting purposes:.

<FIG> shows an embodiment of the system <NUM> wherein the method for measuring the frequency and derivative of an alternating voltage or current input signal <NUM> is carried out. The input signal <NUM> is connected to terminals A and B of a conditioning circuit <NUM>, which is responsible for reducing the voltage or current levels of the input signal to voltage levels manageable by the subsequent electronic circuits of the system <NUM>. This conditioning circuit <NUM> is connected via two wires to an anti-aliasing filter <NUM> and this is connected via two wires to an A/D converter <NUM>. The conditioned signal <NUM> is filtered to avoid any aliasing phenomena. The filtered signal <NUM> is fed to the A/D converter <NUM> which samples the filtered signal <NUM> at a constant sampling rate fs obtaining a waveform 4a. For example, the A/D converter <NUM> provides an integer value for each sample. In this way, a waveform 4a corresponding to the input signal <NUM> is obtained which a computing unit <NUM> operates on to obtain an estimate of the frequency of the input signal <NUM> and, optionally, the derivative of the frequency of the input signal <NUM> and/or the uncertainty associated with the resulting estimation.

<FIG> shows the schematic gain response of a low-pass anti-aliasing filter <NUM> and its relationship to the sampling frequency fs to be used in the present system. The anti-aliasing filter <NUM> prevents high frequency signals from being wrongly detected by the A/D converter <NUM> as very low frequency signals.

Coming back to <FIG>, in one embodiment the output of the A/D converter <NUM> is related to the original input signal <NUM> by a linear function with an offset and a gain, which however need not be known according to the present proposal. The A/D converter <NUM> may provide a synchronous stream of signed or unsigned integer data to the computing unit <NUM>. In the case of unsigned integer data, it is necessary to know the integer value representing the zero value of the original signal by subtracting it from each of the measurements of the synchronous data stream. A set of output data <NUM> relating to the measured frequency, and optionally, the uncertainty and the measured frequency derivative, with a certain number of decimal places, is obtained at the output of the computing unit <NUM>. The system <NUM> is fed by a power supply <NUM>. Optionally, the system may be provided with an external clock <NUM> which provides timestamps of the output data stream <NUM> and also allows counteracting the systematic error of the sampling frequency of the A/D converter <NUM>. With this timestamp, simultaneous measurements can be compared at different sites at the same time.

<FIG> shows another simplified embodiment of the system <NUM> in which the signal conditioner, anti-aliasing filter and analogue-to-digital converter are not needed because it works directly in digital format. There is a remote data source <NUM>, which connects to the computing unit <NUM>, and provides a sequence or stream of data representing the waveform 4a corresponding to an analogue signal <NUM> of which the frequency is to be calculated. In this example, the remote data source <NUM> directly provides the waveform 4a with which the computing unit <NUM> operates as input to the system <NUM>. It is equivalent to the example of <FIG>, detaching the set of components consisting of the anti-aliasing filter, the A/D converter and the conditioning circuit, and considering that the computing unit is connected to a remote data source which already delivers the waveform as input. The output of system <NUM> can be fed to a monitoring device <NUM> to assess whether there is an excessive deviation from the safety ranges associated with the frequency and derivative. In the event of such a deviation, system <NUM> can generate warnings and alarms so that the monitoring equipment <NUM> can establish control measures to remedy or mitigate the problem depending on the degree of deviation. Control countermeasures may include selective disconnection of certain loads within an electricity network (load shedding).

<FIG> shows another embodiment of the system <NUM> similar to <FIG>, where the output of the computing unit <NUM> is connected to supply data to a first D/A converter <NUM>. The D/A converter <NUM> delivers a first electrical signal <NUM> for the frequency at its terminals C and D, and a second electrical signal <NUM> for the frequency derivative at its terminals E and F, by means of a second D/A converter <NUM>. These analogue signals <NUM>, <NUM> are of DC type, in voltage or current, representing a linear relationship with gain and offset, although any type of non-linear function can be implemented, and can be used to control analogue equipment operating with a different relationship to frequency.

<FIG> shows another embodiment of the system <NUM> in which the signal conditioner, anti-aliasing filter and A/D converter are replaced by a remote data source <NUM> to which the computing unit <NUM> is connected to receive the waveform 4a. A first D/A converter <NUM> and a second D/A converter <NUM> are connected to the output of the computing unit <NUM> providing, respectively, analogue DC signals <NUM>, <NUM>, in voltage or current, which preferably have a linear dependence with a gain and an offset, although it is possible to implement any type of non-linear function as indicated above.

Having described several embodiments of the system <NUM> where it is possible to implement the procedure for frequency measurement, this latter is explained in more detail.

<FIG> depicts in a schematic way the sequence of the main steps of the frequency measurement procedure.

A step for digitisation <NUM> of the input signal and obtaining a waveform 4a for digital processing. If the digital information is available, this step may be omitted.

An optional step of normalizing <NUM> the waveform 4a and obtaining a normalised waveform 4b.

A comparison step <NUM> of waveform 4a, or optionally standard 4b, with several pairs of crossover levels determining a hysteresis condition (user selectable or preset for convenience in a simplified mode of operation). The crossover levels must be within the full scale of waveform 4a or optionally of its normalised 4b, so that they intersect with it (may be, for example, ±<NUM>, ±<NUM>, ±<NUM>, +<NUM>/+<NUM> as illustrated in <FIG> or any other).

A generation step <NUM> of several measurement functions <NUM>, each one associated with a pair of crossover levels, C. Measurement function <NUM> is chosen to have a rising edge at a first level and a falling edge at a second level, which change when the waveform coincides with the crossover level and a hysteresis condition is met to avoid bounces. Therefore, the measurement function <NUM> is repeated according to time intervals which are called periods (mathematically they would be quasi-periods or pseudo-periods) and which may be slightly different from each other. Two consecutive rising or falling edges can be used to establish a period of the measurement function <NUM>.

If only the frequency of the signal, not its derivative, is to be estimated, a recording step <NUM> of a set of such periods is performed for each measurement function <NUM>. Subsequently a statistical calculation step <NUM> is performed to extract data <NUM> and obtain estimates of the waveform frequency 4a and measurement uncertainty, mainly using all periods of all measurement functions generated between two instants.

If it is required to estimate the derivative of the frequency of the signal, a recording step <NUM> of pairs of values associated with such periods is performed, the first element of each pair being the average time stamp of the period and the second being its difference (i.e., its duration). Step <NUM> would be identical to step <NUM> taking into account only the second element of each pair. Subsequently a statistical calculation step <NUM> to extract data <NUM> and obtain estimates of the frequency derivative of the waveform 4a and the measurement uncertainty, mainly using all pairs of values of all measurement functions generated between two instants.

These estimates are used, for example, to assess frequency deviations of an input signal from a nominal or expected value. As a result, it is possible to implement actions to correct such deviations and/or to adapt the operation of equipment to the estimated frequency.

<FIG> show graphically various signals with which the calculation unit <NUM> works.

<FIG> shows an example of a sine waveform 4a which when divided by its amplitude A=<NUM> (constant) becomes a normalised signal 4b. It is important to normalise waveform 4a so that amplitude variations are not carried over to the frequency estimation.

If deviations from a nominal amplitude value occur, as in the case of the voltage signal in an electrical distribution network, if not normalised, fluctuations in the real amplitude of the input signal are interpreted as frequency drifts with respect to the nominal frequency by applying the proposed measurement procedure. Normalising resolves this circumstance effectively, although it may increase the uncertainty of the measurement, so it is added as an option and it will be necessary to determine what is to be prioritised in each case.

<FIG> shows a normalised sine waveform 4b, where the normalised amplitude is <NUM>, and its rectified version 4c. According to a first option the rectified mean value 5a (see formula [<NUM>] below, the rectified mean value corresponds to α=<NUM>) and according to a second option the rms value 5b (the rms value corresponds to α=<NUM> in formula [<NUM>]).

In general, the input signal can be normalised according to various techniques. Each of the xk samples of the input signal is divided by a value representing the amplitude A, yielding an equivalent normalised sample signal yk whose amplitude will range from approximately -<NUM> to +<NUM>, although in fact it may not reach or exceed these values at some point.

Other examples are to use as amplitude value A the maximum value, or a percentile of the absolute values of the input signal in a calculation interval (typically the <NUM>% or <NUM>% percentile), both of which are easy to implement in an algorithm and are also applicable to signals where there is no nominal or reference frequency (e.g. electrocardiograms).

Equation [<NUM>] can be used to generically calculate an amplitude value to normalise the input signal to:
<MAT>.

Being xk is each of the N samples of the input signal in the calculation window, a value is calculated for its normalisation amplitude, which we will call A, so that the normalised samples on which the algorithm will be applied will be xk/A.

The value of α can be chosen from any positive value greater than zero, where fs represents the sampling frequency of the analogue-to-digital converter and fn the nominal frequency of the signal, e.g. <NUM> or <NUM> in public power systems. The most common value for α will be precisely <NUM>, where A represents the ratio of the mean value of the absolute values of the signal to the mean value of the absolute value of a sinusoidal signal of amplitude one at the nominal frequency. A suitable value for α can also be <NUM>, where A represents the ratio of the rms value of the signal to the rms value of a sine wave of amplitude one at the nominal frequency (see <FIG>). If the maximum level or a percentile of the amplitude is taken, the original samples xk are taken, sorted by absolute value and the corresponding maximum or percentile value is taken, this being the A value.

<FIG> show examples of three measurement functions applied simultaneously on the same normalised waveform 4b during a measurement interval that includes slightly more than one cycle. The measurement functions are square functions <NUM> that change from high to low depending on the crossover with the normalised waveform 4b. The crossover levels can be chosen according to different criteria. For simplicity, in this example, the maximum amplitude of the normalised waveform 4b is divided into four equal segments according to three pais of crossover levels. <FIG> illustrates the crossover levels: C=±<NUM>, <FIG> illustrates the crossover levels: C=±<NUM>, <FIG> illustrates the crossover levels: C=±<NUM>. In other embodiments, it may be desirable to distribute the crossover levels in a non-linear fashion and to concentrate them closer to the x-axis, near zero.

The measurement functions <NUM> set lines at the positive and negative crossover level (C: ±<NUM>, ±<NUM> and ±<NUM>); the initial level is taken as +<NUM> or -<NUM> indistinctly (actually, the value of the level of the square function is irrelevant in the calculations, it could be ±<NUM>, ±<NUM>, ±<NUM>,. ); when the normalised waveform 4b exceeds the positive threshold and previously the square function has the value -<NUM>, then it acquires the value +<NUM>. ); when the normalised waveform 4b exceeds the positive threshold and the square function previously has the value -<NUM>, then it takes the value +<NUM>; when the waveform 4b goes below the negative crossing level, -C, and the square function previously has the value +<NUM>, then the square function takes the value -<NUM>; this process is repeated throughout the calculation interval and for each of the thresholds, thus obtaining the <NUM> square functions <NUM>.

The next operation is to calculate periods for these square <NUM> signals, from the time elapsed between two rising edges or two falling edges.

The following operation is a statistical analysis. Once various periods have been obtained for the square functions <NUM>, in the calculation interval, e.g. to facilitate further operations, their inverse values are calculated and used to generate a data vector F.

In a particular case, for the statistical analysis, in order to discard outliers, mean µ and standard deviation σ of the data vector F (of length n) are calculated and those values outside the interval [µ - η ·σ, µ+η ·σ] are discarded, η being a constant value to be chosen between <NUM> and <NUM>. Thus, a reduced data vector F̂ (of length n̂) is obtained, on which its mean µ̂ and standard deviation σ̂ are recalculated. The calculated frequency value is precisely µ̂ and the measurement uncertainty corresponds to the standard deviation of the mean, <MAT>, which are returned by the calculation unit.

If the number of samples is not large enough or if a faster calculation is desired, µ can simply be returned as the calculated value of the waveform frequency and <MAT> of its uncertainty. This statistical method is outlined in section <NUM> of reference NPL <NUM>, as well as in reference NPL <NUM>.

To increase the number of values, each square function is started alternately, once with the value +<NUM> and the next time with the value -<NUM>. In general, a level m shall be defined which will result in thresholds at the levels ±<NUM>/m, ±<NUM>/m,. , ± (m-<NUM>)/m. The value of m shall be chosen between a minimum value of <NUM> and a maximum value equal to half the full scale of the analogue-to-digital converter. Depending on the application, this m value may typically be a few tens, or even several hundreds or thousands for applications with very high accuracy and speed requirements.

<FIG> shows an example of a measurement function with crossover levels with non-symmetrical hysteresis with respect to the x-axis, namely +<NUM> and +<NUM>, applied on the original signal 4a without normalisation. As can be seen, the measurement function <NUM> continues to be generated and its period, understood as the distance between two rising or falling edges, continues to match that of the signal to be measured 4a. However, the time at high level is no longer the same as that at low level, hence the importance of measuring the distance between two rising or falling edges and not the half-period.

<FIG> shows an example of a normalised waveform 4b with <NUM> hysteresis levels symmetrical about the x-axis and evenly spaced on the y-axis (±<NUM>, ±<NUM>, ±<NUM>,. In this case, <NUM> square measurement functions <NUM> would be generated, which are not depicted in <FIG> because their superposition would be unintelligible. The statistical calculations would be applied on the set of measurement functions <NUM> simultaneously, so that the greater the number of overlapping functions <NUM>, the greater the number of samples and, therefore, the better the measurement of the frequency and/or its derivative.

<FIG> illustrate two methods for calculating the frequency derivative separately (<FIG><FIG>and together (<FIG>).

A first simplified method, as exemplified in <FIG>, where the frequency measurement does not require additional calculation, by taking the estimated frequencies during two evaluation intervals (Tr), calculating the difference (Δf = |f<NUM> - f<NUM>|) between the estimated frequency obtained in each evaluation interval (f<NUM>; f<NUM>) and dividing by that evaluation interval:
<MAT>.

The measure of derivative of the frequency would correspond to the average slope of the frequency, between the two instants in which two frequency measurements are generated. This derivative measure would therefore have a natural delay given by Tr, since it would be necessary to have two consecutive frequency measurements.

A second, faster technique is shown in <FIG>, where the frequency is calculated in two contiguous windows defined by a calculation interval of width Tc, the derivative is calculated as the ratio of the frequency increment (δf) to the window width Tc:
<MAT>.

It is possible to determine the rate at which a frequency measurement is to be generated by setting an evaluation interval Tr. A time window of width Tc is taken just before each time instant where this frequency calculation is to be output.

With respect to the technique in <FIG>, this measurement of the derivative would have no delay Tr, since it would not be necessary to have two frequency measurements separated by this interval.

<FIG> shows an example of the difference between the two methods for measuring the derivative of frequency. It shows a comparatively better fit to the slope of the derivative curve obtained with the second method. In some embodiments it may be appropriate to implement either the first or the second, or even a combination of both.

<FIG> graphically shows the method of obtaining the cloud of points for a level with symmetrical hysteresis with respect to the x-axis (<NUM> signal and <NUM>/s derivative). Four cycles of the normalised waveform 4b and a pair of symmetrical levels of crossover C=±<NUM> have been plotted. Having obtained the measurement function <NUM>, every two consecutive rising or falling edges, a series of points P1, P2, up to P<NUM> are calculated, where each of them has as its first element the average value of the time stamp of the edges and its second element is the difference. The origin of times is arbitrary, being taken as zero precisely at the beginning of the graph for clarity. Each of these points is marked on the graph by a vertical dotted line, with their specific values expressed in milliseconds appearing in the legend. In fact, these vertical lines are virtually indistinguishable from the rising and falling edges of the measurement function <NUM>, although they would only coincide exactly for symmetrical hysteresis levels and constant frequency waveforms.

<FIG> graphically shows the method of obtaining the cloud of points for a level with a non-symmetrical hysteresis with respect to the x-axis (<NUM> signal and <NUM>/s derivative). The case is similar to the previous one and the subsequent statistical calculation is exactly the same, although now it can be seen how the vertical dotted lines corresponding to points P1, P2, up to P<NUM> are perfectly distinguishable from the rising and falling edges of the measurement function <NUM>.

<FIG> shows graphically the method for calculating the derivative of the frequency of a sine signal of amplitude <NUM> starting at <NUM> and whose derivative is <NUM>/s. In this case the signal is sampled at <NUM> (which would correspond to <NUM> points per cycle at <NUM>), with a <NUM>-bit A/D converter and <NUM> evenly spaced symmetrical crossover levels (levels ±<NUM>/<NUM>, ±<NUM>/<NUM>, ±<NUM>/<NUM>,. , ±<NUM>/<NUM>, ±<NUM>/<NUM> and ±<NUM>/<NUM>) are taken. For each of the points P001, P002, P003,. , P597, P598 and P599, the second of their elements is inverted to represent a frequency and not a period, and they are represented by crosses on a graph whose abscissa axis corresponds to the time and the ordinate axis to the frequency. Adjusting this cloud of points by a least squares line, a function f(t) is obtained whose algebraic expression is <NUM>+4t, indicating that its constant value is <NUM> and its slope <NUM>/s, which corresponds exactly to the frequency derivative of the original signal, demonstrating the reliability and accuracy of the procedure. The mean value of the frequency in the calculation window turns out to be <NUM> and the uncertainty of only <NUM>. Regarding the derivative, its mean value in the calculation window is the slope of the straight line, <NUM>/s, and its uncertainty is only <NUM>/s. These values are those that would be generated by the calculation unit <NUM>.

The variance in the estimation of the slope of the regression line is given by the sum of the squares of the residuals of the cloud of points with respect to the regression line (named SSE), divided by n-<NUM>, where n is the number of samples in the cloud of points (see non-patent literature NPL <NUM> page <NUM>). Calculating its square root gives its standard deviation, which corresponds to the uncertainty of the derivative of the frequency:
<MAT>.

A graph illustrating the relationship between uncertainty and number of pairs o symmetrical hysteresis values is shown in <FIG>. It can be observed how the uncertainty in the measured frequency (using the arithmetic mean) decreases with the number of samples. This is a real case on a waveform corresponding to a <NUM> public mains voltage signal, for measurement calculation intervals of <NUM> (continuous curve) and <NUM> (dashed curve) and varying the number of pairs of crossover levels between <NUM> and <NUM>. Theoretically, either the frequency calculation interval or the number of crossover levels can be increased to reduce the uncertainty. In the case where the frequency varies more rapidly, increasing the calculation period would not capture its dynamic character, so for input signals subject to rapid frequency variations it is preferable to increase the number of crossover levels. It is envisaged that in certain implementations it may be user selectable or, in unattended mode, programmed to increase the number automatically, e.g. if the accuracy of the measurement obtained is lower than a set threshold (for quality, regulatory requirement, etc.).

<FIG> show two waveforms normalised to <NUM>, sinusoidal and both with a very large harmonic component, and crossover levels C=±<NUM>. It can be seen how the square measurement function is virtually immune to the disturbances present in the waveform. <FIG> shows a sine wave with a third harmonic whose amplitude is <NUM>% of the fundamental frequency, while <FIG> shows a sine wave with a harmonic of order <NUM> and whose amplitude is <NUM>% of the amplitude of the fundamental frequency. Due to the statistical character of the frequency measurement with multiple C-levels, the lack of precision in the crossovers with the different positive and negative levels, inherent in the superposition of the higher frequency components (e.g. harmonics), is naturally balanced by obtaining a value representative of all statistical samples.

It is also worth mentioning that, since periods, not half-periods, are measured, the amplitude of the positive half-cycles need not be equal to that of the negative ones, something that is particularly visible when the signal has even harmonics. An example of this is shown in <FIG>, where it can be seen how for a particular case with C=±<NUM>. <NUM> and a second harmonic of <NUM>% amplitude with respect to the fundamental frequency (first harmonic), the squared signal has a substantially larger positive part than the negative part.

<FIG> shows a normalised, nominal <NUM> sine waveform, modulated in amplitude, frequency and phase, with crossover values C=±<NUM> and a corresponding square measurement function. Since there is modulation, the maximum amplitude of the waveform varies with time, even though it is normalised.

<FIG> shows the dynamic calculation of the frequency of the waveform in <FIG> above, with a calculation interval of <NUM> and <NUM> pairs of crossover values, C, showing how the calculated frequency matches the frequency of the original signal almost perfectly, although the latter varies along with the amplitude and phase.

Finally, if an external clock <NUM> is available that is more accurate than the A/D converter's own clock, the systematic error of the latter can be corrected. Indeed, by taking at regular time intervals ΔTi the number of samples ni of the A/D converter <NUM>, the random variable ri, corresponding to the effective sampling frequency of the A/D converter <NUM>, can be defined as:
<MAT>.

By taking a sufficient number of measurement intervals N the mean µ and standard deviation σ of this random variable can be obtained. The frequency and derivative measurements must then be calculated by taking this mean µ as the effective value of the A/D converter <NUM> sampling frequency. The standard deviation of the mean, <MAT>, gives a measure of the uncertainty of the sampling frequency and should be included in the rest of the uncertainty measurements, either of the frequency or of its derivative, as appropriate.

Alternatively, the external clock <NUM> may also be used to enhance the values of the rising and falling edge timestamps of the measurement functions <NUM> by incorporating these enhanced values in the calculation of the frequency and/or its derivative. In this case it would not be necessary to include the uncertainty of the sampling frequency of the A/D converter <NUM>.

Claim 1:
A method for measuring the frequency of a waveform (4a) comprising the steps of:
- setting a plurality of pairs of crossover levels (C);
- comparing (<NUM>) the waveform (<NUM>) with each of the pairs of crossover levels (C) and generating (<NUM>) measurement functions (<NUM>), wherein each measurement function (<NUM>) has a rising edge at a first level and a falling edge at a second level that change according to the coincidence of the waveform (4a) with its pair of crossover levels (C) and a hysteresis condition;
- recording (<NUM>), for each measurement function (<NUM>), a plurality of values,
where each one is defined as the absolute value of the difference of timestamps between two consecutive rising edges or two consecutive falling edges; and
- performing a statistical calculation (<NUM>) on the set of pluralities of values recorded between two given instants of the entire plurality of pairs of crossover levels (C), in order to estimate the frequency of the waveform (4a) between those instants.