3-phase PV router
Loading...
Searching...
No Matches
processing.h
Go to the documentation of this file.
1
12#ifndef _PROCESSING_H
13#define _PROCESSING_H
14
15#include "config.h"
16
17// analogue input pins
18inline constexpr uint8_t sensorV[NO_OF_PHASES]{ 0, 2, 4 };
19inline constexpr uint8_t sensorI[NO_OF_PHASES]{ 1, 3, 5 };
20// ------------------------------------------
21
24inline constexpr uint8_t PERSISTENCE_FOR_POLARITY_CHANGE{ 2 };
26inline constexpr uint16_t initialDelay{ 3000 };
27inline constexpr uint16_t startUpPeriod{ 3000 };
29// for interaction between the main processor and the ISR
30inline volatile uint32_t absenceOfDivertedEnergyCount{ 0 };
31inline volatile bool b_datalogEventPending{ false };
32inline volatile bool b_newMainsCycle{ false };
33inline volatile bool b_overrideLoadOn[NO_OF_DUMPLOADS];
34inline volatile bool b_reOrderLoads{ false };
35inline volatile bool b_diversionOff{ false };
37// since there's no real locking feature for shared variables, a couple of data
38// generated from inside the ISR are copied from time to time to be passed to the
39// main processor. When the data are available, the ISR signals it to the main processor.
40inline volatile int32_t copyOf_sumP_atSupplyPoint[NO_OF_PHASES];
41inline volatile int32_t copyOf_sum_Vsquared[NO_OF_PHASES];
42inline volatile float copyOf_energyInBucket_main;
47#ifdef TEMP_ENABLED
49#else
51#endif
52
58
59void processCurrentRawSample(uint8_t phase, int16_t rawSample);
60void processVoltageRawSample(uint8_t phase, int16_t rawSample);
61void processRawSamples(uint8_t phase);
62
63void processVoltage(uint8_t phase);
64
65#if defined(__DOXYGEN__)
66inline void processStartUp(uint8_t phase);
67inline void processStartNewCycle();
68inline void processPlusHalfCycle(uint8_t phase);
69inline void processMinusHalfCycle(uint8_t phase);
70inline void processVoltage(uint8_t phase);
71inline void processPolarity(uint8_t phase, int16_t rawSample);
72inline void confirmPolarity(uint8_t phase);
73inline void proceedLowEnergyLevel();
74inline void proceedHighEnergyLevel();
75inline uint8_t nextLogicalLoadToBeAdded();
76inline uint8_t nextLogicalLoadToBeRemoved();
77inline void processLatestContribution(uint8_t phase);
78#else
79inline void processStartUp(uint8_t phase) __attribute__((always_inline));
80inline void processStartNewCycle() __attribute__((always_inline));
81inline void processPlusHalfCycle(uint8_t phase) __attribute__((always_inline));
82inline void processMinusHalfCycle(uint8_t phase) __attribute__((always_inline));
83inline void processVoltage(uint8_t phase) __attribute__((always_inline));
84inline void processPolarity(uint8_t phase, int16_t rawSample) __attribute__((always_inline));
85inline void confirmPolarity(uint8_t phase) __attribute__((always_inline));
86inline void proceedLowEnergyLevel() __attribute__((always_inline));
87inline void proceedHighEnergyLevel() __attribute__((always_inline));
88inline uint8_t nextLogicalLoadToBeAdded() __attribute__((always_inline));
89inline uint8_t nextLogicalLoadToBeRemoved() __attribute__((always_inline));
90inline void processLatestContribution(uint8_t phase) __attribute__((always_inline));
91#endif
92
94
95#endif // _PROCESSING_H
container for datalogging
Definition: types.h:64
constexpr auto get_size() const
Get the number of sensors.
Definition: utils_temp.h:94
Configuration values to be set by the end-user.
constexpr TemperatureSensing temperatureSensing
Definition: config.h:91
constexpr uint8_t NO_OF_DUMPLOADS
Definition: config.h:38
constexpr uint16_t
Definition: config_system.h:32
constexpr uint8_t NO_OF_PHASES
Definition: config_system.h:19
void updatePhysicalLoadStates()
This function provides the link between the logical and physical loads.
Definition: processing.cpp:234
void processLatestContribution(uint8_t phase)
Process the latest contribution after each phase specific new cycle additional processing is performe...
Definition: processing.cpp:629
void processStartUp(uint8_t phase)
Process the startup period for the router.
Definition: processing.cpp:384
void processStartNewCycle()
This code is executed once per 20mS, shortly after the start of each new mains cycle on phase 0.
Definition: processing.cpp:495
void processMinusHalfCycle(uint8_t phase)
Process the start of a new -ve half cycle, for this phase, just after the zero-crossing point.
Definition: processing.cpp:550
void processVoltageRawSample(uint8_t phase, int16_t rawSample)
Process the current voltage raw sample for the specific phase.
Definition: processing.cpp:780
void proceedLowEnergyLevel()
Process the case of low energy level, some action may be required.
Definition: processing.cpp:449
void processPolarity(uint8_t phase, int16_t rawSample)
Process with the polarity for the actual voltage sample for the specific phase.
Definition: processing.cpp:283
void processRawSamples(uint8_t phase)
This routine is called by the ISR when a pair of V & I sample becomes available.
Definition: processing.cpp:732
uint8_t nextLogicalLoadToBeAdded()
Retrieve the next load that could be added (be aware of the order)
Definition: processing.cpp:584
void processPlusHalfCycle(uint8_t phase)
Process the start of a new +ve half cycle, for this phase, just after the zero-crossing point.
Definition: processing.cpp:704
void processDataLogging()
Process with data logging.
Definition: processing.cpp:657
uint8_t nextLogicalLoadToBeRemoved()
Retrieve the next load that could be removed (be aware of the reverse-order)
Definition: processing.cpp:607
void confirmPolarity(uint8_t phase)
This routine prevents a zero-crossing point from being declared until a certain number of consecutive...
Definition: processing.cpp:330
void processVoltage(uint8_t phase)
Process the calculation for the current voltage sample for the specific phase.
Definition: processing.cpp:354
void proceedHighEnergyLevel()
Process the case of high energy level, some action may be required.
Definition: processing.cpp:408
void processCurrentRawSample(uint8_t phase, int16_t rawSample)
Process the calculation for the actual current raw sample for the specific phase.
Definition: processing.cpp:299
volatile uint8_t copyOf_lowestNoOfSampleSetsPerMainsCycle
Definition: processing.h:43
constexpr uint16_t startUpPeriod
Definition: processing.h:27
constexpr uint8_t PERSISTENCE_FOR_POLARITY_CHANGE
Definition: processing.h:24
void updatePortsStates()
update the control ports for each of the physical loads
Definition: processing.cpp:190
uint8_t loadPrioritiesAndState[NO_OF_DUMPLOADS]
Definition: processing.h:22
volatile bool b_reOrderLoads
Definition: processing.h:34
void initializeOptionalPins()
Initializes the optional pins.
Definition: processing.cpp:143
constexpr uint8_t sensorV[NO_OF_PHASES]
Definition: processing.h:18
constexpr uint8_t sensorI[NO_OF_PHASES]
Definition: processing.h:19
volatile float copyOf_energyInBucket_main
Definition: processing.h:42
volatile int32_t copyOf_sumP_atSupplyPoint[NO_OF_PHASES]
Definition: processing.h:40
volatile int32_t copyOf_sum_Vsquared[NO_OF_PHASES]
Definition: processing.h:41
volatile uint16_t copyOf_sampleSetsDuringThisDatalogPeriod
Definition: processing.h:44
volatile bool b_overrideLoadOn[NO_OF_DUMPLOADS]
Definition: processing.h:33
void printParamsForSelectedOutputMode()
Print the settings used for the selected output mode.
Definition: processing.cpp:799
volatile bool b_newMainsCycle
Definition: processing.h:32
volatile bool b_datalogEventPending
Definition: processing.h:31
volatile uint32_t absenceOfDivertedEnergyCount
Definition: processing.h:30
volatile bool b_diversionOff
Definition: processing.h:35
constexpr uint16_t initialDelay
Definition: processing.h:26
PayloadTx_struct< NO_OF_PHASES > tx_data
Definition: processing.h:50
void initializeProcessing()
Initializes the ports and load states for processing.
Definition: processing.cpp:91
volatile uint16_t copyOf_countLoadON[NO_OF_DUMPLOADS]
Definition: processing.h:45