Signal Processing
Base Concept
Calculation & data processing done below order,
-
Remove the DC offset in all signal.
-
RMS Amplitude of voltage, current signal.
-
Calculate RMS Voltage, Current
-
With modulation method, calculate the phase
-
Now derive the complex impedance value
Reference from TI TIDA-060029
Amplitude & Phase calculation
RMS value - Voltage & Current
RMS(Root Mean Square) is the square root of the mean square of a set of numbers or a continuous function $$ x_\text{RMS} = \sqrt{ \frac{1}{n} \left( {x_1}^2 + {x_2}^2 + \cdots + {x_n}^2 \right) }. $$
Phase calculate option 1 - Goertzel algorithm
The Goertzel algorithm provides an efficient method for computing a single DFT (Discrete Fourier Transform) term at a specific frequency. This implementation is particularly useful for embedded systems and microcontrollers where computational resources are limited.
The implementation follows these steps:
-
Calculates the angular frequency (omega) and coefficient
-
Processes all samples using a second-order filter
-
Computes the magnitude of the real and imaginary components
Computational Efficiency
- Time Complexity: O(N)
- More efficient than FFT for single frequency analysis
- Requires minimal memory overhead
Usage Example
The Goertzel algorithm efficiently computes a single DFT term for a specific target frequency. Here's the implementation:
float goertzel(float* data, int N, float target_freq, float sampling_freq) {
float omega = (2.0 * M_PI * target_freq) / sampling_freq;
float coeff = 2.0 * cos(omega);
float q0 = 0;
float q1 = 0;
float q2 = 0;
// Process all samples
for (int i = 0; i < N; i++) {
q0 = coeff * q1 - q2 + data[i];
q2 = q1;
q1 = q0;
}
// Calculate magnitude
float real = (q1 - q2 * cos(omega));
float imag = (q2 * sin(omega));
float magnitude = sqrt(real*real + imag*imag);
return magnitude;
}
The algorithm uses less computational resources than FFT when analyzing a single frequency component.
Phase calculate option 2 - Synchronous Demodulation
The voltages are acquired using a two channel differential ADC and processed in the following form. Followed below steps
-
Modulation of the signal by multiplying the signal with a unity magnitude square wave of 0 degree phase and taking the average of the resulting signal (\(V_1\)).
-
Modulation of the signal by multiplying the signal with a unity magnitude square wave of 90 degree phase and taking the average of the resulting signal (\(V_2\)).
$$ \alpha = \tan^{-1} (\frac{V_2}{V_1}) $$ phase ‘\(\alpha\)’ of any signal is estimated with respect to the reference signal.