DUECA/DUSIME
|
Implementation of a rotary scaling/converting device, using a polynomial for final correction and optionally tracking of the angle. More...
#include <CircularWithPoly.hxx>
Public Member Functions | |
CircularWithPoly (double K, double xzero, double norm_start, size_t n, const double ai[]) | |
Constructor. | |
CircularWithPoly (const CircularWithPoly &o) | |
Copy constructor. | |
CircularWithPoly & | operator= (const CircularWithPoly &o) |
assignment | |
~CircularWithPoly () | |
Destructor. | |
double | operator() (const double x) const |
The operator. | |
std::ostream & | print (std::ostream &os) const |
Print the object. | |
Public Member Functions inherited from dueca::SimpleFunction | |
SimpleFunction () | |
Constructor. | |
virtual | ~SimpleFunction () |
Destructor. | |
Implementation of a rotary scaling/converting device, using a polynomial for final correction and optionally tracking of the angle.
This class is a functor, with a double as input and another double as output. The application for this in DUECA is as an input calibrator for IO signals, see also the InputCalibrator and OutputCalibrator documentation.
The input is first scaled with a gain K, and then normalized to a range \(n_0\) .. \(n_0+1\). The polynomial is then applied to this normalized result.
Implements in step 1:
\[ x_t(x) = (K\left(x-x_0\right) - n_0) \mod 1 + n_0 \]
And with that result (ranging from
\[ y(x_t) = a_0 + a_1 x_t \ldots + a_n (x_t)^n \]
As an example, consider a 10 bit synchro measuring angle of attack, with output values from 0 to 1023. At 0 degrees angle of attack, the output from the measurement is 980, and so with different inputs the measurement is likely to flip around from 1023 to 0. Determine \(x_0=980\), \(K=1/1024\) and \(n_0=-0.5\), then the output from the first step ranges from -0.5 to 0.5 for a -180 to 180 degree (hypothetical) input. With the polynomial from the second step the scaling may be further defined.
dueca::CircularWithPoly::CircularWithPoly | ( | double | K, |
double | xzero, | ||
double | norm_start, | ||
size_t | n, | ||
const double | ai[] ) |
Constructor.
K | Gain coefficient, 1.0/(increments in full rotation) |
xzero | Input value when angle is zero |
norm_start | Normalised start value of first step, for example -0.5, to get a -0.5 to 0.5 output, or zero to get a 0 to 1 output |
n | Order of the calibrating polynomial |
ai | Array with polynomial coefficients, polynomial is \(a_0 + a_1 x + \ldots + a_n x^n \) |
The operator.
Implements dueca::SimpleFunction.