Computing the metrological power from three-phase sampled signals involves performing power calculations based on the voltage and current waveforms for each phase. Typically, instantaneous power is computed by multiplying the instantaneous voltage and current values, and active/reactive/apparent power calculations follow based on these computations and phase relations.
Below is a simplified C code example for calculating the active power of a three-phase system. This example assumes equally spaced samples of voltage and current over one or more full cycles of the waveform and no phase shift.
Before starting the computations, understand that:
V_phase_a, V_phase_b, and V_phase_c are arrays of voltage samples for each phase.
I_phase_a, I_phase_b, and I_phase_c are arrays of current samples for each phase.
sample_count is the number of samples for each phase over one cycle. The more samples per cycle, the more accurate the results will be, considering it represents the waveform more accurately.
n_cycles is the number of cycles over which the measurements are averaged. Averaging over multiple cycles can help minimize errors due to noise and waveform distortion.
- It's important that voltage and current samples are aligned, meaning they are sampled at the same time.
#include <stdio.h>
// Function to compute the average active power for a three-phase system
double compute_three_phase_power(double V_phase_a[], double I_phase_a[],
double V_phase_b[], double I_phase_b[],
double V_phase_c[], double I_phase_c[],
int sample_count, int n_cycles) {
double total_power = 0.0;
// Compute instantaneous power and sum them for each phase
for (int i = 0; i < sample_count * n_cycles; ++i) {
total_power += V_phase_a[i] * I_phase_a[i]; // Power for phase A
total_power += V_phase_b[i] * I_phase_b[i]; // Power for phase B
total_power += V_phase_c[i] * I_phase_c[i]; // Power for phase C
}
// Calculate the average power over all samples
double average_power = total_power / (sample_count * n_cycles);
return average_power;
}
int main() {
// Example usage:
// Sample count per cycle (make sure this matches your actual sample count per cycle)
const int sample_count = 100;
// Number of cycles to average
const int n_cycles = 10;
// Recorded voltage and current samples for each phase.
// These should be filled in with actual measurements.
double V_phase_a[sample_count * n_cycles]; // Fill with voltage samples for phase A
double I_phase_a[sample_count * n_cycles]; // Fill with current samples for phase A
double V_phase_b[sample_count * n_cycles]; // Fill with voltage samples for phase B
double I_phase_b[sample_count * n_cycles]; // Fill with current samples for phase B
double V_phase_c[sample_count * n_cycles]; // Fill with voltage samples for phase C
double I_phase_c[sample_count * n_cycles]; // Fill with current samples for phase C
// Fill your sample arrays with actual measured data
// ...
// Calculate three-phase power
double power = compute_three_phase_power(V_phase_a, I_phase_a,
V_phase_b, I_phase_b,
V_phase_c, I_phase_c,
sample_count, n_cycles);
// Print the result
printf("Average three-phase power: %lf Watts\n", power);
return 0;
}
Please note this example does not consider phase shift or power factor, which are required for complete power quality analysis. Depending on the type of load and power system characteristics, phases could be shifted, and you might need to apply the appropriate power factor correction to get accurate true power readings.
Moreover, if your system includes distortion or you need to compute reactive or apparent power, the calculations would be more complex and you would use methods like Fourier analysis or implement power factor correction techniques.
For a real-world application, you should also consider aspects like calibration, signal conditioning, ADC resolution, potential transients, and noise in the signals, which all affect the accuracy of your power measurements. Always consult the equipment's datasheet or engineering references for proper calculation methods according to the specifics of your hardware and application requirements.