|
OptoMMP3
|
Polynomial linearization object. More...
Public Member Functions | |
| Polynomial (Int32 i32Order) | |
| constructor More... | |
| Boolean | SetCoefficient (Int32 i32Index, Double dCoefficient) |
| Set a coefficient More... | |
| Double | Compute (Double dInput) |
| Compute the linearization. More... | |
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 (0C)
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 (40C)
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 (100C)
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 (300C)
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 (700C)
dMillivolts = 42.919;
dTemperature = poly.Compute(dMillivolts);
Console.WriteLine("J Thermocouple; {0} millivolts is {1} C", dMillivolts.ToString("F1"), dTemperature.ToString("F1"));
| Opto22.Linearization.Polynomial.Polynomial | ( | Int32 | i32Order | ) |
constructor
| i32Order | The polynomial order the object will be intialized with. Maybe larger than needed, unused powers are zero. |
| Double Opto22.Linearization.Polynomial.Compute | ( | Double | dInput | ) |
Compute the linearization.
Note, this method does not check for any out-of-bound condition.
| dInput | The input to linearize. |
| Boolean Opto22.Linearization.Polynomial.SetCoefficient | ( | Int32 | i32Index, |
| Double | dCoefficient | ||
| ) |
Set a coefficient
| i32Index | Coefficient index to set. The index is values of 0 to i32Order - 1 as set in the constructor method. |
| dCoefficient | The coefficient of this index. |