3-phase PV router
Loading...
Searching...
No Matches
calibration.h
Go to the documentation of this file.
1
11
12#ifndef CALIBRATION_H
13#define CALIBRATION_H
14
15#include "config.h"
16
17//
18// Calibration values
19//-------------------
20// Each board has its own set below: the router uses the one of PCB_VERSION (config.h).
21// f_powerCal converts the products of voltage and current samples into watts, for the power the
22// router diverts. f_voltageCal converts the voltage samples into volts, for the voltage shown in
23// the datalog only. To calibrate, compare with a reference meter:
24// new value = old value x reference reading / router reading
25//
26// ---- Old board (PcbVersion::OLD) ----
27//
28// When calculating real power, which is what this code does, the individual
29// conversion rates for voltage and current are not of importance. It is
30// only the conversion rate for POWER which is important. This is the
31// product of the individual conversion rates for voltage and current. It
32// therefore has the units of ADC-steps squared per Watt. Most systems will
33// have a power conversion rate of around 20 (ADC-steps squared per Watt).
34//
35// powerCal is the RECIPROCAL of the power conversion rate. A good value
36// to start with is therefore 1/20 = 0.05 (Watts per ADC-step squared)
37//
38inline constexpr float f_powerCalOldBoard[NO_OF_PHASES]{ 0.05000F, 0.05000F, 0.05000F };
39//
40// For datalogging purposes, f_voltageCal has been added too. Because the range of ADC values is
41// similar to the actual range of volts, the optimal value for this cal factor is likely to be
42// close to unity.
43inline constexpr float f_voltageCalOldBoard[NO_OF_PHASES]{ 0.8151F, 0.8184F, 0.8195F };
44//
45// ---- New board (PcbVersion::NEW, rev. 6.0+) ----
46//
47// f_powerCal is given per amp of CT rating: f_powerCal = f_powerCalPerAmp x f_ctRating, so
48// changing a CT only means entering its rating. The default values suit 333 mV voltage-output CTs;
49// they come from the design of the board, corrected by the calibration of a first board (see
50// docs/calibration.md). With a current-output CT and a burden resistor R (YHDC SCT-013-000,
51// 2000:1), f_ctRating = 666 / R: the current giving 333 mV across the burden.
52inline constexpr float f_ctRating[NO_OF_PHASES]{ 50.0F, 50.0F, 50.0F };
53inline constexpr float f_powerCalPerAmp[NO_OF_PHASES]{ 0.0029588F, 0.0029588F, 0.0029588F };
54inline constexpr float f_voltageCalNewBoard[NO_OF_PHASES]{ 0.888065256F, 0.888065256F, 0.888065256F };
55//
56// ---- Both boards ----
57//
58// f_phaseCal is used to alter the phase of the voltage waveform relative to the current waveform.
59// The algorithm interpolates between the most recent pair of voltage samples according to the value of f_phaseCal.
60//
61// With f_phaseCal = 1, the most recent sample is used.
62// With f_phaseCal = 0, the previous sample is used
63// With f_phaseCal = 0.5, the mid-point (average) value in used
64//
65// NB. Any tool which determines the optimal value of f_phaseCal must have a similar
66// scheme for taking sample values as does this sketch.
67//
68inline constexpr float f_phaseCal{ 1 };
69
70// CT filter: a low-pass of the current added back with a gain, to offset the high-pass behaviour of the CTs.
71// Turned into fixed point at compile time (ct_filter.h): alpha from 0.00005 to below 0.0625, gain below 64.
72inline constexpr float lpf_gain{ 0 };
73inline constexpr float alpha{ 0.002 };
74
75#endif // CALIBRATION_H
constexpr float f_ctRating[NO_OF_PHASES]
Definition calibration.h:52
constexpr float alpha
Definition calibration.h:73
constexpr float f_phaseCal
Definition calibration.h:68
constexpr float f_powerCalPerAmp[NO_OF_PHASES]
Definition calibration.h:53
constexpr float lpf_gain
Definition calibration.h:72
constexpr float f_powerCalOldBoard[NO_OF_PHASES]
Definition calibration.h:38
constexpr float f_voltageCalOldBoard[NO_OF_PHASES]
Definition calibration.h:43
constexpr float f_voltageCalNewBoard[NO_OF_PHASES]
Definition calibration.h:54
Router configuration: loads, relays, control pins and features.
constexpr uint8_t NO_OF_PHASES