# What's the fastest way to get the phase angle and amplitude of a COSINUS 50hz signal?

I'm not a DSP specialist.I'm working in transmission and distribution. I need to retrieve the amplitude and phase angle of a discrete 50Hz COSINUS signal as fast as possible. Right now I'm using a Sliding DFT an I can manage to get this information in 10ms (half period) but I would like to know if it's possible to have it faster. I can adjust the sample time up to 1micro second.

I need to have this information (amplitude and phase angle) as fast as possible because it will determine the time constant of my corrector.

• One pointer: Liangliang Li, Wei Xia, Dongyuan Shi, Jianzhuang Li, "Frequency Estimation on Power System Using Recursive-Least-Squares Approach", Proceedings of the 2012 International Conference on Information Technology and Software Engineering Lecture Notes in Electrical Engineering Volume 211, 2013, pp 11-18 Jun 2 '15 at 8:04

Depending on how the signal will look like you can get away with only two or three samples:

$$y(t) = A + B \cos(\omega t + \theta)$$

If you know what the main value, $A_0$, would be, then only two samples would be required. Namely the cosine, shifted by a phase angle $\theta$, can be rewritten as a linear combination of a unshifted sine and cosine:

$$y(t) = A_0 + A_1 \cos(\omega t) + B_1 \cos(\omega t) = A_0 + \sqrt{A_1^2 + B_1^2} \cos\left(\omega t - \tan^{-1}{\frac{A_1}{B_1}}\right)$$

The gains can be solved for by solving the following linear system of equations:

$$\begin{bmatrix} 1 & \sin \theta_0 & \cos \theta_0 \\ 1 & \sin \theta_1 & \cos \theta_1 \\ 1 & \sin \theta_2 & \cos \theta_2 \end{bmatrix} \begin{bmatrix} A_0 \\ A_1 \\ B_1 \end{bmatrix} = \begin{bmatrix} y_0 \\ y_1 \\ y_2 \end{bmatrix}$$

where $\theta_i=2\pi f(t_0+i\Delta t)$, with $f=50\ Hz$ and the $t_0+i\Delta t$ are the consecutive moments in time used for for the three measurements and $y_i$ is the measured signal at those moments in time. The values found for $A_0$, $A_1$ and $B_1$ can then be used to find the constants of the initial equation, namely:

$$A = A_0$$

$$B = \sqrt{A_1^2 + B_1^2}$$

$$\theta = -\tan^{-1}{\frac{A_1}{B_1}}$$

This should work for any different points in time, which are not a multiple of the period of the signal spaced apart, however this does assume that there is no noise present in the signal. If there is noise then you might want to consider using more points and performing a least squares method. Also a shorter sample time/higher sample rate would make these calculations more sensitive to the noise, but you will be able to take more samples in the same amount of time.