Quote:
Originally Posted by buffalobillpatrick
A/C did I get this right?
|
It looks like you are handling the equation correctly, although I do believe that there is an exponentiation operator that is available to you.
Other than that, I must assume that you are using the floating point precision appropriate to this application.
Quote:
Originally Posted by buffalobillpatrick
How did you come up with such an accurate formula??
|
Multiple Polynomial Regression Analysis.
Quote:
Originally Posted by buffalobillpatrick
Either the formula or the table are off by a little bit.
OR Arduino floating point math is a bit in-accurate.
I would bet on this option, as Arduino does floating point by actually doing integer add operations.
This one line of code: y = ( a + (b * x) + (c * x*x) + (d * x*x*x) + (e * x*x*x*x));
Produces 348 bytes of Arduino object code.
At 30PSI: formula = 5.83*F, table = 7.93*F, difference = -2.1*F
At 300PSI: formula = 143.75*F, table = 142.2*F, difference = +1.55*F
|
I used the values of the table to generate the curve. And the equation I gave you was the best fit.
If the process you are trying to address, primarily functions in only part of that range, I can recalculate, for maximum fit over that specified range, which will give you much greater accuracy within that specified range but would be a less accurate fit in the rest of the range (that you will not use).
BTW, I replicated the equation I gave to you, on a high-quality spreadsheet, without Arduino limitations, and got the very same results, when rounded.
You did good.
Best,
-AC
P.S.:
if your input pressure variable was called "psi", and your calculated output temperature variable was called "degF", then your one-line formula would be:
Code:
degF=-40.3085122205+(1.81496452942*psi)+(-0.0101201804003*psi^2)+(3.05234258195e-005*psi^3)+(-3.37963005786e-008*psi^4)
This code will run on my spreadsheet, and I'm pretty sure that it should compile on the Arduino IDE.
Good luck!
%%%%%%%%%