3-phase PV router
Loading...
Searching...
No Matches
config_derived.h File Reference

The configuration as the firmware uses it: the settings, and what is built from them. More...

#include "config_system.h"
#include "config.h"
#include "types.h"
#include "debug.h"
#include "calibration.h"
#include "adc_chain.h"
#include "datalog_math.h"
#include "remote_loads_core.h"
#include "rotation_groups.h"
#include "utils_dualtariff.h"
#include "utils_override.h"
#include "utils_relay.h"
#include "utils_temp.h"
#include "remote_loads.h"
Include dependency graph for config_derived.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Variables

constexpr uint8_t ADC_CLOCKS_PER_CONVERSION { 13 }
 
constexpr uint8_t ADC_PRESCALER { 128 }
 
constexpr BoostSchedule boostSchedule { scheduledBoosts, targetMap }
 
constexpr uint8_t DATALOG_POWER_SHIFT { Datalog::powerShift(MAX_SAMPLE_SETS_PER_DATALOG) }
 
constexpr float f_powerCal [NO_OF_PHASES]
 
constexpr float f_voltageCal [NO_OF_PHASES]
 
constexpr uint32_t MAX_SAMPLE_SETS_PER_DATALOG { static_cast< uint32_t >(DATALOG_PERIOD_IN_MAINS_CYCLES) * N_MAX }
 
constexpr uint8_t N_MAX { SAMPLE_SETS_PER_CYCLE + SAMPLE_SETS_MARGIN }
 
constexpr uint8_t N_MIN { SAMPLE_SETS_PER_CYCLE - SAMPLE_SETS_MARGIN }
 
constexpr bool NEW_BOARD_CALIBRATION { PCB_VERSION == PcbVersion::NEW }
 
constexpr uint8_t NO_OF_REMOTE_LOADS { Load::countRemoteLoads(physicalLoadPin) }
 
constexpr uint8_t NO_OF_REMOTE_UNITS { Load::countUnits(physicalLoadPin) }
 
constexpr OverrideTable overrideTable { overridePins, targetMap }
 
constexpr RelayDiverter relayDiverter { relays }
 
constexpr bool REMOTE_LOADS_PRESENT { NO_OF_REMOTE_LOADS != 0 }
 
RemoteLoadCore< NO_OF_REMOTE_UNITS > remoteLoads {}
 The one and only remote-load controller.
 
constexpr Rotation::Table rotationTable { rotationGroups, physicalLoadPin, loadPrioritiesAtStartup }
 The priority places each rotation group rotates in.
 
constexpr uint32_t SAMPLE_SET_PERIOD_US { 1UL * AdcChain::NO_OF_CONVERSIONS * ADC_CLOCKS_PER_CONVERSION * ADC_PRESCALER / (F_CPU / 1000000UL) }
 
constexpr uint8_t SAMPLE_SETS_MARGIN { 4 }
 
constexpr uint8_t SAMPLE_SETS_PER_CYCLE { 1000000UL / (SUPPLY_FREQUENCY * SAMPLE_SET_PERIOD_US) }
 
constexpr TargetMap targetMap { physicalLoadPin, relays, RELAY_DIVERSION }
 What LOAD(), RELAY() and ALL_...() stand for, in overridePins and scheduledBoosts.
 
constexpr TempSensors tempSensors { temperatureSensing }
 

Detailed Description

The configuration as the firmware uses it: the settings, and what is built from them.

Author
Frédéric Metrich (frede.nosp@m.ric..nosp@m.metri.nosp@m.ch@l.nosp@m.ive.f.nosp@m.r)
Version
1.0
Date
2026-11-24

The code includes this file, never config.h directly. config.h only holds the settings; here come the values derived from them and the objects built from them:

  • the calibration of the board (calibration.h): f_powerCal and f_voltageCal of PCB_VERSION, in the per-phase arrays the code uses;
  • the sample sets per mains cycle, and the counter of those of a datalog period;
  • the number of remote loads and units, from the load map;
  • remoteLoads, the remote-load controller, which holds the transmission state;
  • relayDiverter, the relay engine, from relays;
  • overrideTable and boostSchedule, the bitmasks that overridePins and scheduledBoosts force, once LOAD(), RELAY() and ALL_...() are turned into pins;
  • tempSensors, which reads the sensors of temperatureSensing.

Definition in file config_derived.h.

Variable Documentation

◆ ADC_CLOCKS_PER_CONVERSION

uint8_t ADC_CLOCKS_PER_CONVERSION { 13 }
inlineconstexpr

Definition at line 67 of file config_derived.h.

◆ ADC_PRESCALER

uint8_t ADC_PRESCALER { 128 }
inlineconstexpr

Definition at line 68 of file config_derived.h.

◆ boostSchedule

BoostSchedule boostSchedule { scheduledBoosts, targetMap }
inlineconstexpr

what each scheduled boost forces

Definition at line 114 of file config_derived.h.

◆ DATALOG_POWER_SHIFT

uint8_t DATALOG_POWER_SHIFT { Datalog::powerShift(MAX_SAMPLE_SETS_PER_DATALOG) }
inlineconstexpr

the shift of the datalog power sum in the ISR: 0, or 4 when the period needs it (Datalog::powerShift())

Definition at line 78 of file config_derived.h.

◆ f_powerCal

float f_powerCal[NO_OF_PHASES]
inlineconstexpr
Initial value:
constexpr float f_ctRating[NO_OF_PHASES]
Definition calibration.h:52
constexpr float f_powerCalPerAmp[NO_OF_PHASES]
Definition calibration.h:53
constexpr float f_powerCalOldBoard[NO_OF_PHASES]
Definition calibration.h:38
constexpr bool NEW_BOARD_CALIBRATION

f_powerCal of each phase, as the router uses it

Definition at line 49 of file config_derived.h.

◆ f_voltageCal

float f_voltageCal[NO_OF_PHASES]
inlineconstexpr
Initial value:

f_voltageCal of each phase, as the router uses it

Definition at line 54 of file config_derived.h.

◆ MAX_SAMPLE_SETS_PER_DATALOG

uint32_t MAX_SAMPLE_SETS_PER_DATALOG { static_cast< uint32_t >(DATALOG_PERIOD_IN_MAINS_CYCLES) * N_MAX }
inlineconstexpr

the most sample sets in a datalog period: 54000 at 30 s, within the 16-bit counter (validation.h)

Definition at line 76 of file config_derived.h.

◆ N_MAX

uint8_t N_MAX { SAMPLE_SETS_PER_CYCLE + SAMPLE_SETS_MARGIN }
inlineconstexpr

Definition at line 73 of file config_derived.h.

◆ N_MIN

uint8_t N_MIN { SAMPLE_SETS_PER_CYCLE - SAMPLE_SETS_MARGIN }
inlineconstexpr

Definition at line 72 of file config_derived.h.

◆ NEW_BOARD_CALIBRATION

bool NEW_BOARD_CALIBRATION { PCB_VERSION == PcbVersion::NEW }
inlineconstexpr

Whether the router runs with the set of the new board

Definition at line 46 of file config_derived.h.

◆ NO_OF_REMOTE_LOADS

uint8_t NO_OF_REMOTE_LOADS { Load::countRemoteLoads(physicalLoadPin) }
inlineconstexpr

number of loads controlled via RF

Definition at line 83 of file config_derived.h.

◆ NO_OF_REMOTE_UNITS

uint8_t NO_OF_REMOTE_UNITS { Load::countUnits(physicalLoadPin) }
inlineconstexpr

number of remote units to talk to

Definition at line 84 of file config_derived.h.

◆ overrideTable

OverrideTable overrideTable { overridePins, targetMap }
inlineconstexpr

what each override pin forces

Definition at line 113 of file config_derived.h.

◆ relayDiverter

RelayDiverter relayDiverter { relays }
inlineconstexpr

the relay engine

Definition at line 112 of file config_derived.h.

◆ REMOTE_LOADS_PRESENT

bool REMOTE_LOADS_PRESENT { NO_OF_REMOTE_LOADS != 0 }
inlineconstexpr

true if remote loads are configured

Definition at line 85 of file config_derived.h.

◆ remoteLoads

RemoteLoadCore< NO_OF_REMOTE_UNITS > remoteLoads {}
inline

The one and only remote-load controller.

Declared non-const on purpose: it holds the per-unit transmission state. RemoteLoadCore has a constexpr default constructor and brace-or-equal member initialisers, so this object is constant-initialized. It therefore lands in .bss with no entry in .init_array, and --gc-sections drops it outright when no remote unit is configured.

Definition at line 98 of file config_derived.h.

◆ rotationTable

The priority places each rotation group rotates in.

Definition at line 117 of file config_derived.h.

◆ SAMPLE_SET_PERIOD_US

uint32_t SAMPLE_SET_PERIOD_US { 1UL * AdcChain::NO_OF_CONVERSIONS * ADC_CLOCKS_PER_CONVERSION * ADC_PRESCALER / (F_CPU / 1000000UL) }
inlineconstexpr

624 us

Definition at line 69 of file config_derived.h.

◆ SAMPLE_SETS_MARGIN

uint8_t SAMPLE_SETS_MARGIN { 4 }
inlineconstexpr

covers crossing jitter and frequency drift

Definition at line 71 of file config_derived.h.

◆ SAMPLE_SETS_PER_CYCLE

uint8_t SAMPLE_SETS_PER_CYCLE { 1000000UL / (SUPPLY_FREQUENCY * SAMPLE_SET_PERIOD_US) }
inlineconstexpr

32 at 50 Hz, 26 at 60 Hz

Definition at line 70 of file config_derived.h.

◆ targetMap

TargetMap targetMap { physicalLoadPin, relays, RELAY_DIVERSION }
inlineconstexpr

What LOAD(), RELAY() and ALL_...() stand for, in overridePins and scheduledBoosts.

Definition at line 110 of file config_derived.h.

◆ tempSensors

TempSensors tempSensors { temperatureSensing }
inlineconstexpr

the temperature sensors

Definition at line 115 of file config_derived.h.