|
3-phase PV router
|
The CT filter: a low-pass of the current added back with a gain, one per phase. More...


Go to the source code of this file.
Classes | |
| struct | CtFilter::Coefficients |
| The coefficients of the filter, in fixed point: the multiples the filter needs, ready. More... | |
| struct | CtFilter::LowPassBoost |
| The state of the filter of one CT (one per phase), and the filter itself. More... | |
Namespaces | |
| namespace | CtFilter |
Functions | |
| constexpr Coefficients | CtFilter::coefficientsOf (const float gain, const float alpha) |
| Converts the float settings to fixed point, at compile time. | |
| constexpr bool | CtFilter::isAccurate (const float gain, const float alpha) |
| Whether the settings fit the fixed point, the coefficients within 1 % of them. | |
Variables | |
| constexpr int16_t | CtFilter::ALPHA_FIXED_LIMIT { 4096 } |
| alpha x 2^(16 + shift) stays below this: 4 x alpha fits an int16, and 4 x alpha x the largest difference (2^16 at x64) an int32 with 2 bits to spare. | |
| constexpr uint8_t | CtFilter::LPF_FRACTION_BITS { 2 } |
| The fractional bits of the low-pass state below the x64 scale of the samples: x256. | |
| constexpr uint8_t | CtFilter::MAX_ALPHA_SHIFT { 4 } |
| The largest extra shift of alpha: more resolution for a small alpha, one more turn each. | |
The CT filter: a low-pass of the current added back with a gain, one per phase.
A current transformer acts as a high-pass filter. Robin's sketches offset it with an IIR low-pass filter of the current, added back with a gain (lpf_gain, alpha in calibration.h). This is his filter, Mk2_fasterControl_Full/processing.cpp, in fixed point instead of his float maths (two float multiplies and four conversions took ~1100 cycles of the ADC interrupt, per phase; this takes ~210):
The firmware's sample is DC-removed and left-aligned (x64 scale, int16): it is filtered at x256, the output is back at x64, saturated to the int16 range, so that a peak beyond full scale cannot wrap and flip the sign of the power.
Pure C++, no Arduino: the native tests include it.
Definition in file ct_filter.h.