Foreground processing operates at a lower
frequency within the main application loop. The foreground tasks are triggered once the
background process has accumulated a complete block of data. This layer handles the more
computationally intensive calculations, including:
- Retrieving Accumulated Data:
Safely reading the consistent set of dot products and other relevant data logged by the
background task.
- Applying Calibration: Correcting
the raw accumulated values using predetermined calibration coefficients to compensate for
sensor inaccuracies and analog front-end variations.
- Calculating Final Parameters:
Computing the full suite of metrology parameters, such as RMS voltage and current, active,
reactive, and apparent power, power factor, frequency, THD, and sag and swell events,
using the calibrated data.
- Energy Accumulation: Integrating
power values over time to calculate energy consumption.
- Updating results: Making the final, calibrated measurements available to the
application for display, logging, or communication.