3-phase PV router
Loading...
Searching...
No Matches
General Processing

Functions and routines that handle general system processing tasks. More...

Classes

class  EWMA_average< A >
 Implements an Exponentially Weighted Moving Average (EWMA). More...
 

Functions

void checkDiversionOnOff ()
 Checks and updates the diversion state based on the diversion pin.
 
bool forceFullPower ()
 Forces all loads to full power if the override pin is active.
 
void handlePerSecondTasks (bool &bOffPeak, int16_t &iTemperature_x100)
 Handles tasks that need to be executed every second.
 
void logLoadPriorities ()
 Prints the load priorities to the Serial output.
 
void loop ()
 Main processor loop.
 
bool proceedLoadPrioritiesAndOverriding (const int16_t &currentTemperature_x100)
 Handles load priorities and overriding logic.
 
bool proceedLoadPrioritiesAndOverridingDualTariff (const int16_t &currentTemperature_x100)
 Handles load priorities and overriding during dual tariff periods.
 
void proceedRotation ()
 Proceeds with load priority rotation.
 
void sendResults (bool bOffPeak)
 Prints or sends telemetry data logs based on the selected output format.
 
void updatePowerAndVoltageData ()
 Updates power and voltage data for all phases.
 

Detailed Description

Functions and routines that handle general system processing tasks.

This group includes functions that are not time-critical but are essential for the overall operation of the system. These tasks include monitoring system states, managing load priorities, and handling diversion logic.

Function Documentation

◆ checkDiversionOnOff()

void checkDiversionOnOff ( )

Checks and updates the diversion state based on the diversion pin.

This function monitors the state of the diversion pin and updates the global b_diversionOff flag accordingly. It also logs changes in the diversion state for debugging purposes if enabled.

  • If the diversion pin is LOW, the diversion is considered OFF.
  • If the diversion pin is HIGH, the diversion is considered ON.
  • Debug messages are printed when the diversion state changes (if debugging is enabled).

Definition at line 107 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ forceFullPower()

bool forceFullPower ( )

Forces all loads to full power if the override pin is active.

This function checks the state of the override pin and forces all loads to full power if the pin is active. It also logs changes in the override state for debugging purposes if enabled.

  • If the override pin is LOW, all loads are forced to full power.
  • If the override pin is HIGH, normal load behavior is restored.
  • Debug messages are printed when the override state changes (if debugging is enabled).
Returns
true if loads are forced to full power, false otherwise.

Definition at line 64 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handlePerSecondTasks()

void handlePerSecondTasks ( bool & bOffPeak,
int16_t & iTemperature_x100 )

Handles tasks that need to be executed every second.

This function performs various tasks that are triggered once per second, ensuring proper system operation and load management.

  • Increments the absence of diverted energy count if no energy is being diverted.
  • Toggles the watchdog pin if the feature is enabled.
  • Checks and updates the diversion state.
  • Manages load priorities and overriding based on the current temperature.
  • Updates relay durations and proceeds with relay state transitions if relay diversion is enabled.
Parameters
bOffPeakReference to the off-peak state flag.
iTemperature_x100Current temperature multiplied by 100 (default to 0 if temperature sensing is disabled).

Definition at line 408 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logLoadPriorities()

void logLoadPriorities ( )
inline

Prints the load priorities to the Serial output.

This function logs the current load priorities and states to the Serial output for debugging purposes. It provides a detailed view of the load configuration and their respective priorities.

  • Each load's priority and state are printed in a human-readable format.
  • This function is only active when debugging is enabled (ENABLE_DEBUG).

Definition at line 464 of file utils.h.

Here is the caller graph for this function:

◆ loop()

void loop ( )

Main processor loop.

This function handles non-time-critical tasks such as load management, telemetry updates, and temperature sensing. It processes ADC data through flags set by the ISR and ensures proper system operation.

  • Executes tasks triggered by the b_newMainsCycle flag, which is set after every pair of ADC conversions.
  • Handles per-second tasks such as load priority management and diversion state updates.
  • Processes data logging events and updates power, voltage, and temperature data.
  • Sends telemetry results and updates relay states if relay diversion is enabled.

Definition at line 449 of file main.cpp.

Here is the call graph for this function:

◆ proceedLoadPrioritiesAndOverriding()

bool proceedLoadPrioritiesAndOverriding ( const int16_t & currentTemperature_x100)

Handles load priorities and overriding logic.

This function manages load priorities and overriding behavior based on the system configuration. It supports dual tariff handling, priority rotation, and manual override functionality.

Parameters
currentTemperature_x100Current temperature multiplied by 100 (default to 0 if deactivated).
Returns
true if the system is in a high tariff (on-peak) period.
false if the system is in a low tariff (off-peak) period.
  • If dual tariff is enabled, it delegates to proceedLoadPrioritiesAndOverridingDualTariff.
  • If EmonESP control is enabled, it handles load rotation based on the rotation pin state.
  • If priority rotation is set to auto, it rotates priorities after a defined period of inactivity.
  • If the override pin is present, it forces all loads to full power when activated.

Definition at line 236 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proceedLoadPrioritiesAndOverridingDualTariff()

bool proceedLoadPrioritiesAndOverridingDualTariff ( const int16_t & currentTemperature_x100)

Handles load priorities and overriding during dual tariff periods.

This function manages load priorities and overriding logic based on the dual tariff state and the current temperature. It ensures proper load behavior during off-peak and on-peak periods.

Parameters
currentTemperature_x100Current temperature multiplied by 100 (default to 0 if deactivated).
Returns
true if the system is in a high tariff (on-peak) period.
false if the system is in a low tariff (off-peak) period.
  • Detects transitions between off-peak and on-peak periods using the dual tariff pin.
  • During off-peak periods, manages load priorities and overrides based on elapsed time and temperature.
  • Logs transitions between tariff periods for debugging purposes.

Definition at line 171 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proceedRotation()

void proceedRotation ( )

Proceeds with load priority rotation.

This function triggers the rotation of load priorities and waits until the rotation is completed. It ensures that the new load priorities are logged after the rotation.

  • Sets the b_reOrderLoads flag to initiate the rotation process.
  • Waits in a loop until the rotation is completed by the ISR.
  • Logs the updated load priorities after the rotation.

Definition at line 140 of file main.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendResults()

void sendResults ( bool bOffPeak)
inline

Prints or sends telemetry data logs based on the selected output format.

This function handles the transmission of telemetry data in various formats, such as human-readable text, IoT telemetry, or JSON format. It also ensures that the first incomplete datalogging event is skipped during startup.

Parameters
bOffPeakIndicates whether the system is in an off-peak tariff period.
  • If RF communication is enabled, it sends RF data.
  • Depending on the SERIAL_OUTPUT_TYPE, it prints data in text format, sends telemetry data, or outputs data in JSON format.
  • Skips the first datalogging event during startup to avoid incomplete data.

Definition at line 423 of file utils.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updatePowerAndVoltageData()

void updatePowerAndVoltageData ( )

Updates power and voltage data for all phases.

This function calculates the power and voltage for each phase based on the accumulated data during the datalogging period. It also updates the total power.

  • Computes the power for each phase using the accumulated power data and calibration factors.
  • Calculates the RMS voltage for each phase using the accumulated voltage squared data.
  • Updates the total power by summing the power of all phases.

Definition at line 334 of file main.cpp.

Here is the caller graph for this function: