Some relay protection and automation functions require information about the frequency of the observed voltage or current. We will consider the option of calculating the frequency of the electric signal from the transition through zero.

Consider a sinusoidal signal, for example, the mains voltage (Fig. 1). The figure shows the signal period *T*. The frequency *f* is the reciprocal of the period, i.e. *f* = 1 / *T*.

Fig. 1. Example of a sinusoidal signal

Thus, in order to determine the frequency of the signal, it is necessary to calculate its period. In the ideal case, for this it is enough to determine neighboring times in which the observed signal passes a zero value in the same direction (for example, from the region of negative values to the region of positive values of the signal). However, in digital relay protection, the observed signals are discretized (i.e., the values of the observed signal are fixed at certain discrete time instants with a certain sampling frequency *f _{d }*at equal time intervals τ, called the sampling interval), which raises the problem of determining the moment of transition through zero.

As a possible solution to this problem, linear interpolation of the observed signal at those times at which the signal under study is not recorded is used. In fig. 2 illustrates this approach.

Fig. 2. Linear interpolation of the sampled signal

We compose an algorithm for determining the estimated time of the transition through the signal zero (according to Fig. 2):

- We determine the discrete time moment
*k*_{2 }when the observed signal passes from the region of negative values to the region of positive values (or vice versa). - We fix the signal values
*A*_{1}and*A*_{2}at discrete time instants k1 and*k*_{2}, respectively. - We calculate the value of
*m*based on the equation of a line passing through 2 points.

Given that (*k*_{2} – *k*_{1}) = 1, the value of *m* is determined by the following expression:

$$ m = \frac{|A_1|}{|A_1| + A_2} $$

After determining the neighboring time points of the transition through zero, the signal period is calculated. Consider the signal in Fig. 3.

Fig. 3. The input signal

For a given signal with accepted designations, the signal period will be determined by the following expression

$$ T = (k_j + m_2 – k_i – m_1) \cdot \tau, $$

where τ is sampling interval of signal.

After the appearance of the next transition through, the frequency is recalculated in accordance with the above algorithm. The algorithm for calculating the frequency for crossing over zero given in the article is given in the attached program file in the Matlab environment: freq_calc.m.

In fig. Figure 4 shows the result of calculating the frequency of a model signal containing a transient process.

Fig. 4. The input signal and the results of calculating the frequency of this signal

From the results it is clear that the calculation of the frequency for the transition through zero has a large error in the transition mode. To reduce this error, averaging over several periods is used.