3-phase PV router
Loading...
Searching...
No Matches
CtFilter Namespace Reference

Classes

struct  Coefficients
 The coefficients of the filter, in fixed point: the multiples the filter needs, ready. More...
 
struct  LowPassBoost
 The state of the filter of one CT (one per phase), and the filter itself. More...
 

Functions

constexpr Coefficients coefficientsOf (const float gain, const float alpha)
 Converts the float settings to fixed point, at compile time.
 
constexpr bool isAccurate (const float gain, const float alpha)
 Whether the settings fit the fixed point, the coefficients within 1 % of them.
 

Variables

constexpr int16_t 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 LPF_FRACTION_BITS { 2 }
 The fractional bits of the low-pass state below the x64 scale of the samples: x256.
 
constexpr uint8_t MAX_ALPHA_SHIFT { 4 }
 The largest extra shift of alpha: more resolution for a small alpha, one more turn each.
 

Function Documentation

◆ coefficientsOf()

Coefficients CtFilter::coefficientsOf ( const float gain,
const float alpha )
constexpr

Converts the float settings to fixed point, at compile time.

Parameters
gainThe gain of the low-pass added back (lpf_gain), 0 to below 64.
alphaThe coefficient of the low-pass, above 0 to below 0.0625.
Returns
The coefficients, alpha with the most resolution (up to MAX_ALPHA_SHIFT extra bits).

Definition at line 72 of file ct_filter.h.

Here is the caller graph for this function:

◆ isAccurate()

bool CtFilter::isAccurate ( const float gain,
const float alpha )
constexpr

Whether the settings fit the fixed point, the coefficients within 1 % of them.

alpha below 0.0625 and the gain below 64, so that nothing overflows; alpha above about 0.00005, below which its 20 fractional bits are too coarse for its time constant.

Definition at line 95 of file ct_filter.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ALPHA_FIXED_LIMIT

int16_t CtFilter::ALPHA_FIXED_LIMIT { 4096 }
inlineconstexpr

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.

Definition at line 51 of file ct_filter.h.

◆ LPF_FRACTION_BITS

uint8_t CtFilter::LPF_FRACTION_BITS { 2 }
inlineconstexpr

The fractional bits of the low-pass state below the x64 scale of the samples: x256.

Definition at line 42 of file ct_filter.h.

◆ MAX_ALPHA_SHIFT

uint8_t CtFilter::MAX_ALPHA_SHIFT { 4 }
inlineconstexpr

The largest extra shift of alpha: more resolution for a small alpha, one more turn each.

Definition at line 45 of file ct_filter.h.