|
3-phase PV router
|
The load priority state machine: which load to switch at each mains cycle. More...


Go to the source code of this file.
Classes | |
| struct | LoadPriorities::Bucket |
| The fixed levels of the energy bucket, in bucket units. More... | |
| struct | LoadPriorities::Switching< N > |
| The switching decision, once per mains cycle, and its state. More... | |
Namespaces | |
| namespace | LoadPriorities |
Functions | |
| template<uint8_t N> | |
| uint8_t | LoadPriorities::nextToAdd (const uint8_t(&priorities)[N]) |
| The next logical load to switch ON: the first one OFF, in priority order. | |
| template<uint8_t N> | |
| uint8_t | LoadPriorities::nextToRemove (const uint8_t(&priorities)[N]) |
| The next logical load to switch OFF: the last one ON, in priority order. | |
| template<uint8_t N> | |
| void | LoadPriorities::rotate (uint8_t(&priorities)[N]) |
| Rotates the priorities by one: the last load becomes the first, the others move down one place. Each load keeps its state. | |
| template<bool CALIBRATION, uint8_t N, typename IsOverridden> | |
| void | LoadPriorities::toPhysical (const uint8_t(&priorities)[N], LoadStates(&physical)[N], const bool diversionEnabled, IsOverridden isOverridden) |
| Maps the logical load states to the physical ones. | |
Variables | |
| constexpr uint8_t | loadStateMask { 0x7FU } |
| constexpr uint8_t | loadStateOnBit { (uint8_t)(~loadStateMask) } |
The load priority state machine: which load to switch at each mains cycle.
Each element of the priority array is one logical load, the highest priority first: its low 7 bits are the physical load number (an index of physicalLoadPin[]), its high bit says whether the load is ON.
Once per mains cycle, the ISR compares the energy bucket with two thresholds: above the upper one, the first load OFF in priority order comes ON; below the lower one, the last load ON goes OFF. After a switch, no other load may switch for POST_TRANSITION_MAX_COUNT cycles, so that the switch has time to show in the bucket: only the load just switched may switch back. The threshold follows the bucket meanwhile.
A threshold goes back to its default only when the bucket is in the other half: while the bucket stays in the upper half, the upper threshold keeps the level the bucket reached during the last post-transition period, and a load comes ON only if the bucket rises above it. The same for the lower threshold in the lower half.
Then the logical states give the physical ones: a load is ON if its override is active, or if diversion is enabled and its logical state is ON. Calibration mode keeps every load OFF.
Definition in file load_priorities.h.
|
inlineconstexpr |
bit mask for masking load state
Definition at line 45 of file load_priorities.h.
|
inlineconstexpr |
bit mask for load state ON
Definition at line 46 of file load_priorities.h.