After the background has collected sufficient data, the flag PHASE_STATUS_NEW_LOG is set by the background. The user main loop checks the status of this flag and calls the foreground process calculate_phase_readings () to perform the rest of the computation to deliver the measurement readings. The foreground process includes:
- Power processing: Calculate the active power, reactive power, fundamental active power, fundamental reactive power by scaling with number of samples and power scaling factor.
- Voltage processing: Calculate the RMS voltage, fundamental RMS voltage by scaling with number of samples, perform square root and multiply with the voltage scaling factor.
- Current processing:
- Calculate the RMS current by scaling with number of samples, perform square root and multiply with the current scaling factor
- Calculate fundamental RMS current from power and voltage
- Calculate the apparent power by multiplying the root mean square voltage and root means square current
- Other processing:
- Calculate the power factor
- Calculate the frequency of the AC line