OptoMMP2
Opto22.Linearization.Polynomial Class Reference

Polynomial linearization object. More...

Public Member Functions

 Polynomial (int i32Order)
 constructor More...
 
bool SetCoefficient (int i32Index, double dCoefficient)
 Set a coefficient More...
 
double Compute (double dInput)
 Compute the linearization. More...
 

Detailed Description

Polynomial linearization object.

Computes a linearization equation like: F(x) = c(0) + c(1)x + c(2)x^2 + c(3)x^3 + ... + c(n)x^n where: c(n) is the coefficient x^n is the input raised to the power of 'n'

Polynomial linearization is commonly used for various thermocouples or non-linear displacement measurement.

(C#) Polynomial poly = new Polynomial(9);

// initialize the polynomial coefficients, "Inverse coefficients for Type J", // http://srdata.nist.gov/its90/download/type_j.tab // for 0 to 760 C, 0 to 42.919 mv // an example... in the SNAP series, the Cold-Junction-Compensation is not available to read // so you can't calculate the compensated probe temperature poly.SetCoefficient(0, 0.0); poly.SetCoefficient(1, 1.978425e1); poly.SetCoefficient(2, -2.001204e-1); poly.SetCoefficient(3, 1.036969e-2); poly.SetCoefficient(4, -2.549687e-4); poly.SetCoefficient(5, 3.585153e-6); poly.SetCoefficient(6, -5.344285e-8); poly.SetCoefficient(7, 5.099890e-10); poly.SetCoefficient(8, 0.0);

double dMillivolts; double dTemperature;

// 0.0 millivolts dMillivolts = 0.0; dTemperature = poly.Compute(dMillivolts); Console.WriteLine("J Thermocouple; {0} millivolts is {1} C", dMillivolts.ToString("F1"), dTemperature.ToString("F1"));

// 2.059 millivolts (40 C) dMillivolts = 2.059; dTemperature = poly.Compute(dMillivolts); Console.WriteLine("J Thermocouple; {0} millivolts is {1} C", dMillivolts.ToString("F1"), dTemperature.ToString("F1"));

// 5.269 millivolts (100 C) dMillivolts = 5.269; dTemperature = poly.Compute(dMillivolts); Console.WriteLine("J Thermocouple; {0} millivolts is {1} C", dMillivolts.ToString("F1"), dTemperature.ToString("F1"));

// 16.327 millivolts dMillivolts = 16.327; dTemperature = poly.Compute(dMillivolts); Console.WriteLine("J Thermocouple; {0} millivolts is {1} C", dMillivolts.ToString("F1"), dTemperature.ToString("F1"));

// 42.919 millivolts dMillivolts = 42.919; dTemperature = poly.Compute(dMillivolts); Console.WriteLine("J Thermocouple; {0} millivolts is {1} C", dMillivolts.ToString("F1"), dTemperature.ToString("F1"));

Constructor & Destructor Documentation

Opto22.Linearization.Polynomial.Polynomial ( int  i32Order)

constructor

Parameters
i32OrderThe polynomial order the object will be intialized with. Maybe larger than needed, unused powers are zero.

Member Function Documentation

double Opto22.Linearization.Polynomial.Compute ( double  dInput)

Compute the linearization.

Note, this method does not check for any out-of-bound condition.

Parameters
dInputThe input to linearize.
Returns
The linearized output.
bool Opto22.Linearization.Polynomial.SetCoefficient ( int  i32Index,
double  dCoefficient 
)

Set a coefficient

Parameters
i32IndexCoefficient index to set. The index is values of 0 to i32Order - 1 as set in the constructor method.
dCoefficientThe coefficient of this index.
Returns
true when the coefficient is set, false if the index is out of range.

The documentation for this class was generated from the following file: