3-phase PV router
|
Implements the processing engine. More...
#include <Arduino.h>
#include "calibration.h"
#include "dualtariff.h"
#include "processing.h"
#include "utils_pins.h"
Go to the source code of this file.
Functions | |
void | confirmPolarity (const uint8_t phase) |
Confirms the polarity of the current voltage sample for a specific phase. | |
constexpr uint16_t | getInputPins () |
Retrieves the input pins configuration. | |
constexpr uint16_t | getOutputPins () |
Retrieves the output pins configuration. | |
template<size_t N> | |
constexpr void | initializeArray (int32_t(&array)[N], int32_t value) |
Initializes all elements of a given array to a specified value. | |
void | initializeProcessing () |
Initializes the processing engine, including ports, load states, and ADC setup. | |
constexpr auto | initThreshold (const bool lower) |
set default threshold at compile time so the variable can be read-only | |
ISR (ADC_vect) | |
Interrupt Service Routine - Interrupt-Driven Analog Conversion. | |
uint8_t | nextLogicalLoadToBeAdded () |
Retrieve the next logical load that could be added. | |
uint8_t | nextLogicalLoadToBeRemoved () |
Retrieve the next logical load that could be removed (in reverse order). | |
void | printParamsForSelectedOutputMode () |
Print the settings used for the selected output mode. | |
void | proceedHighEnergyLevel () |
Handles the case when the energy level is high, potentially adding a load. | |
void | proceedLowEnergyLevel () |
Handles the case when the energy level is low, potentially removing a load. | |
void | processCurrentRawSample (const uint8_t phase, const int16_t rawSample) |
Processes the current raw sample for the specified phase. | |
void | processDataLogging () |
Process data logging at the end of each logging period. | |
void | processLatestContribution (const uint8_t phase) |
Process the latest contribution after each phase-specific new cycle. | |
void | processMinusHalfCycle (const uint8_t phase) |
Processes the start of a new negative half cycle for the specified phase. | |
void | processPlusHalfCycle (const uint8_t phase) |
Process the start of a new positive half cycle for the specified phase. | |
void | processPolarity (const uint8_t phase, const int16_t rawSample) |
Processes the polarity of the current voltage sample for a specific phase. | |
void | processRawSamples (const uint8_t phase) |
Processes raw voltage and current samples for the specified phase. | |
void | processStartNewCycle () |
Processes the start of a new mains cycle on phase 0. | |
void | processStartUp (const uint8_t phase) |
Processes the startup period for the router. | |
void | processVoltage (const uint8_t phase) |
Processes the current voltage sample for the specified phase. | |
void | processVoltageRawSample (const uint8_t phase, const int16_t rawSample) |
Processes the current voltage raw sample for the specified phase. | |
void | updatePhysicalLoadStates () |
Updates the physical load states based on logical load priorities and states. | |
void | updatePortsStates () |
Updates the control ports for each of the physical loads. | |
Implements the processing engine.
Definition in file processing.cpp.
|
constexpr |
set default threshold at compile time so the variable can be read-only
lower | True to set the lower threshold, false for higher |
Definition at line 43 of file processing.cpp.
void printParamsForSelectedOutputMode | ( | ) |
Print the settings used for the selected output mode.
This function displays the relevant configuration parameters for the currently selected output mode. It provides details about the energy bucket capacity, thresholds, and mode-specific settings.
Definition at line 1027 of file processing.cpp.
uint8_t activeLoad { NO_OF_DUMPLOADS } |
current active load
Definition at line 62 of file processing.cpp.
bool b_recentTransition { false } |
a load state has been recently toggled
Definition at line 58 of file processing.cpp.
bool beyondStartUpPeriod { false } |
start-up delay, allows things to settle
Definition at line 85 of file processing.cpp.
uint16_t countLoadON[NO_OF_DUMPLOADS] {} |
Number of cycle the load was ON (over 1 datalog period)
Definition at line 83 of file processing.cpp.
|
constexpr |
for resetting flexible thresholds
Definition at line 29 of file processing.cpp.
float f_energyInBucket_main { 0.0F } |
main energy bucket (over all phases)
Definition at line 53 of file processing.cpp.
float f_lowerEnergyThreshold { 0.0F } |
dynamic lower threshold
Definition at line 54 of file processing.cpp.
|
constexpr |
lower default threshold set accordingly to the output mode
Definition at line 50 of file processing.cpp.
|
constexpr |
threshold in anti-flicker mode - must not exceed 0.4
Definition at line 31 of file processing.cpp.
|
constexpr |
Definition at line 33 of file processing.cpp.
float f_upperEnergyThreshold { 0.0F } |
dynamic upper threshold
Definition at line 55 of file processing.cpp.
|
constexpr |
upper default threshold set accordingly to the output mode
Definition at line 51 of file processing.cpp.
|
constexpr |
nominal mid-point value of ADC @ x1 scale
Definition at line 24 of file processing.cpp.
uint16_t i_sampleSetsDuringThisDatalogPeriod { 0 } |
number of sample sets during each datalogging period
Definition at line 71 of file processing.cpp.
int32_t l_cumVdeltasThisCycle[NO_OF_PHASES] {} |
for the LPF which determines DC offset (voltage)
Definition at line 66 of file processing.cpp.
int32_t l_DCoffset_V[NO_OF_PHASES] {} |
<— for LPF main energy bucket for 3-phase use, with units of Joules * SUPPLY_FREQUENCY
Definition at line 26 of file processing.cpp.
|
constexpr |
mid-point of ADC plus a working margin
Definition at line 23 of file processing.cpp.
|
constexpr |
mid-point of ADC minus a working margin
Definition at line 22 of file processing.cpp.
int32_t l_sampleVminusDC[NO_OF_PHASES] {} |
current raw voltage sample filtered
Definition at line 65 of file processing.cpp.
int32_t l_sum_Vsquared[NO_OF_PHASES] {} |
for summation of V^2 values during datalog period
Definition at line 68 of file processing.cpp.
int32_t l_sumP[NO_OF_PHASES] {} |
cumulative power per phase
Definition at line 64 of file processing.cpp.
int32_t l_sumP_atSupplyPoint[NO_OF_PHASES] {} |
for summation of 'real power' values during datalog period
Definition at line 67 of file processing.cpp.
remove_cv<remove_reference<decltype(DATALOG_PERIOD_IN_MAINS_CYCLES)>::type>::type n_cycleCountForDatalogging { 0 } |
for counting how often datalog is updated
Definition at line 73 of file processing.cpp.
uint8_t n_lowestNoOfSampleSetsPerMainsCycle { 0 } |
For a mechanism to check the integrity of this code structure
Definition at line 75 of file processing.cpp.
uint8_t n_samplesDuringThisMainsCycle[NO_OF_PHASES] {} |
number of sample sets for each phase during each mains cycle
Definition at line 70 of file processing.cpp.
|
constexpr |
Output mode to be used
Definition at line 35 of file processing.cpp.
LoadStates physicalLoadState[NO_OF_DUMPLOADS] {} |
Physical state of the loads
Definition at line 82 of file processing.cpp.
Polarities polarityConfirmed[NO_OF_PHASES] {} |
for zero-crossing detection
Definition at line 79 of file processing.cpp.
Polarities polarityConfirmedOfLastSampleV[NO_OF_PHASES] {} |
for zero-crossing detection
Definition at line 80 of file processing.cpp.
Polarities polarityOfMostRecentSampleV[NO_OF_PHASES] {} |
for zero-crossing detection
Definition at line 78 of file processing.cpp.
|
constexpr |
allows each transition to take effect
Definition at line 60 of file processing.cpp.
uint8_t postTransitionCount { 0 } |
counts the number of cycle since last transition
Definition at line 59 of file processing.cpp.