|
3-phase PV router
|
Implements the processing engine. More...
#include <Arduino.h>#include "config_derived.h"#include "dualtariff.h"#include "processing.h"#include "utils_pins.h"#include "shared_var.h"#include "mult_asm.h"#include "ct_filter.h"#include "energy_bucket.h"#include "load_priorities.h"#include "adc_chain.h"#include "datalog_math.h"
Go to the source code of this file.
Classes | |
| struct | adc_ctx_t |
| Interrupt Service Routine - Interrupt-Driven Analog Conversion. More... | |
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 | getLoadPins () |
| The pins the loads drive: the local TRIACs, plus the status LED of each remote load. | |
| constexpr uint16_t | getOutputPins () |
| Retrieves the output pins configuration. | |
| template<typename T, size_t N> | |
| constexpr void | initializeArray (T(&array)[N], 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 int32_t | initThreshold (const bool lower) |
| set default threshold at compile time so the variable can be read-only | |
| ISR (ADC_vect) | |
| void | printParamsForSelectedOutputMode () |
| Print the settings used for the selected output mode. | |
| void | processCurrentRawSample (const uint8_t phase, const uint16_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 uint16_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 uint16_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 72 of file processing.cpp.
| ISR | ( | ADC_vect | ) |
|
static |
Definition at line 1135 of file processing.cpp.
Definition at line 1144 of file processing.cpp.
| uint32_t absenceOfDivertedEnergyCountInMC { 0 } |
number of main cycles without diverted energy
Definition at line 112 of file processing.cpp.
| bool b_diversionStarted { false } |
Tracks whether diversion has started
Definition at line 64 of file processing.cpp.
| bool beyondStartUpPeriod { false } |
start-up delay, allows things to settle
Definition at line 116 of file processing.cpp.
|
constexpr |
the fixed levels of the main energy bucket
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 110 of file processing.cpp.
|
constexpr |
Definition at line 43 of file processing.cpp.
|
constexpr |
Definition at line 47 of file processing.cpp.
| uint16_t i_DCoffset_V[NO_OF_PHASES] {} |
<— for LPF main energy bucket for 3-phase use, with units of Joules * SUPPLY_FREQUENCY * 2^Energy::FRACTION_BITS
Definition at line 36 of file processing.cpp.
|
constexpr |
nominal mid-point value of ADC @ x64 scale
Definition at line 35 of file processing.cpp.
| uint16_t i_sampleSetsDuringThisDatalogPeriod { 0 } |
number of sample sets during each datalogging period
Definition at line 98 of file processing.cpp.
| int16_t i_sampleVminusDC[NO_OF_PHASES] {} |
current raw voltage sample filtered (left-aligned ADC)
Definition at line 91 of file processing.cpp.
|
constexpr |
for resetting flexible thresholds
Definition at line 39 of file processing.cpp.
| int32_t l_energyInBucket_main { 0 } |
main energy bucket (over all phases)
Definition at line 82 of file processing.cpp.
| uint32_t l_filterDC_V[NO_OF_PHASES] {} |
for the LPF which determines DC offset (voltage)
Definition at line 92 of file processing.cpp.
|
constexpr |
lower default threshold set accordingly to the output mode
Definition at line 79 of file processing.cpp.
|
constexpr |
threshold in anti-flicker mode - must not exceed 0.4
Definition at line 41 of file processing.cpp.
| uint32_t l_sum_Vsquared[NO_OF_PHASES] {} |
for summation of V^2 values during datalog period
Definition at line 95 of file processing.cpp.
| int32_t l_sumP[NO_OF_PHASES] {} |
cumulative power per phase
Definition at line 90 of file processing.cpp.
| int32_t l_sumP_atSupplyPoint[NO_OF_PHASES] {} |
for summation of 'real power' values during datalog period
Definition at line 94 of file processing.cpp.
|
constexpr |
upper default threshold set accordingly to the output mode
Definition at line 80 of file processing.cpp.
| LoadPriorities::Switching< NO_OF_DUMPLOADS > loadSwitching |
for improved control of multiple loads
Definition at line 88 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 100 of file processing.cpp.
| uint8_t n_lowestNoOfSampleSetsPerMainsCycle { 0 } |
For a mechanism to check the integrity of this code structure
Definition at line 102 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 97 of file processing.cpp.
|
constexpr |
Output mode to be used
Definition at line 62 of file processing.cpp.
| uint8_t perSecondCounter { 0 } |
for counting every second inside the ISR
Definition at line 114 of file processing.cpp.
| LoadStates physicalLoadState[NO_OF_DUMPLOADS] {} |
Physical state of the loads
Definition at line 109 of file processing.cpp.
| Polarities polarityConfirmed[NO_OF_PHASES] {} |
for zero-crossing detection
Definition at line 106 of file processing.cpp.
| Polarities polarityConfirmedOfLastSampleV[NO_OF_PHASES] {} |
for zero-crossing detection
Definition at line 107 of file processing.cpp.
| Polarities polarityOfMostRecentSampleV[NO_OF_PHASES] {} |
for zero-crossing detection
Definition at line 105 of file processing.cpp.
|
constexpr |
Definition at line 57 of file processing.cpp.
| const Load::OverrideMasks< NO_OF_DUMPLOADS > overrideMasks PROGMEM { Energy::toFixedPerSample< N_MIN, N_MAX >(f_powerCal) } |
power calibration over n, in fixed point, for every expected n: no division in the ISR
override bit of each load: the ISR tests a mask instead of shifting by the pin
Definition at line 56 of file processing.cpp.