EcoRenovator  

Go Back   EcoRenovator > Improvements > Geothermal & Heat Pumps
Advanced Search
 


Blog 60+ Home Energy Saving Tips Recent Posts


Reply
 
Thread Tools Display Modes
Old 02-19-15, 02:26 AM   #41
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
Default

Quote:
Originally Posted by buffalobillpatrick View Post
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 View Post
How did you come up with such an accurate formula??
Multiple Polynomial Regression Analysis.

Quote:
Originally Posted by buffalobillpatrick View Post
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!

%%%%%%%%%

__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker...
AC_Hacker is offline   Reply With Quote
The Following User Says Thank You to AC_Hacker For This Useful Post:
buffalobillpatrick (02-19-15)
Old 02-19-15, 12:36 PM   #42
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

Thanks A/C

float degF=-40.3085122205+(1.81496452942*psi)+(-0.0101201804003*psi^2)+(3.05234258195e-005*psi^3)+(-3.37963005786e-008*psi^4);

Nope, don't compile:

sketch_subcool_3.ino: In function 'float calc_R290_Saturated_Temp(float)':
sketch_subcool_3:214: error: invalid operands of types 'double' and 'int' to binary 'operator^'
sketch_subcool_3:215: error: invalid operands of types 'double' and 'int' to binary 'operator^'
sketch_subcool_3:215: error: invalid operands of types 'double' and 'int' to binary 'operator^'


Code:
float calc_R290_Saturated_Temp(float psi)
{ 

double a = -4.03085122205E+001;
double b = 1.81496452942E+000;
double c = -1.01201804003E-002;
double d = 3.05234258195E-005;
double e = -3.37963005786E-008;

 return (a + (b * psi) + (c * psi*psi) + (d * psi*psi*psi)
           + (e * psi*psi*psi*psi));
       
}  // end calc_R290_Saturated_Temp
BTW, Arduino don't do double floats, it just pretends to, when double is specified in source code the compiler handles them same as single precision float, by actually doing integer add operations..

The above code generates exactly same object code as when data type float is used.

Last edited by buffalobillpatrick; 02-19-15 at 01:09 PM..
buffalobillpatrick is offline   Reply With Quote
Old 02-19-15, 12:46 PM   #43
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
Default

Quote:
Originally Posted by buffalobillpatrick View Post
Thanks A/C

Nope, don't compile:

sketch_subcool_3.ino: In function 'float calc_R290_Saturated_Temp(float)':
sketch_subcool_3:214: error: invalid operands of types 'double' and 'int' to binary 'operator^'
sketch_subcool_3:215: error: invalid operands of types 'double' and 'int' to binary 'operator^'
sketch_subcool_3:215: error: invalid operands of types 'double' and 'int' to binary 'operator^'
Bummer... the math is correct, but apparently, the syntax is in error, but can be corrected.

BBP, if you are interested in pursuing this route, and want me to work on an equation for a more precise fit, for operating over a more limited range, let me know.

-AC
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker...
AC_Hacker is offline   Reply With Quote
The Following User Says Thank You to AC_Hacker For This Useful Post:
buffalobillpatrick (02-19-15)
Old 02-19-15, 01:15 PM   #44
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

Thanks A/C
I'm only interested in 30-> 300PSI range if it won't be too much trouble.

My table lookup method works accurately & only produces 2% more object code.
buffalobillpatrick is offline   Reply With Quote
Old 02-19-15, 01:39 PM   #45
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
Default

Quote:
Originally Posted by buffalobillpatrick View Post
Thanks A/C
I'm only interested in 30-> 300PSI range if it won't be too much trouble.

My table lookup method works accurately & only produces 2% more object code.
OK, here you go:

Code:
MMF Model: y=(a*b+c*x^d)/(b+x^d)
Coefficient Data:
a =	-6.63511955666E+001
b =	6.30623048298E+001
c =	7.72874234743E+002
d =	5.32503085812E-001
Let me know how this works for you.

-AC
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker...
AC_Hacker is offline   Reply With Quote
The Following User Says Thank You to AC_Hacker For This Useful Post:
buffalobillpatrick (02-19-15)
Old 02-19-15, 01:52 PM   #46
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

A/C, Thanks

Works Damn great.

At 30PSI results are -.07*F
At 300PSI results are -.04*F

Code:
float calc_R290_Saturated_Temp(float psi)
{ 
//MMF Model: y=(a*b+c*x^d)/(b+x^d)
//Coefficient Data:
float a = -6.63511955666E+001;
float b =  6.30623048298E+001;
float c = 7.72874234743E+002;
float d = 5.32503085812E-001;
float p;

p = pow(psi,d);

return (((a * b) + (c * p)) / (b + p ));

}
added a fudge factor to get very close:

return (((a * b) + (c * p)) / (b + p ) + .05); //.05 is fudge factor

Last edited by buffalobillpatrick; 02-19-15 at 02:39 PM..
buffalobillpatrick is offline   Reply With Quote
Old 02-19-15, 02:19 PM   #47
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
Default

Quote:
Originally Posted by buffalobillpatrick View Post
A/C, Thanks

Works Damn great.
Glad I could help.

Best,

-AC
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker...
AC_Hacker is offline   Reply With Quote
Old 02-19-15, 03:45 PM   #48
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
Default

BBP,

Yeah, hit it pretty close.

1st column is P-T chart pressure
2nd column is P-T chart temperature
3rd column is calculated temperature
4th column is % change

Best,

-AC

Code:
PSIG	TempF	TempF	% change
30	7.93	7.86	0.887%
31	9.1	9.05	0.552%
32	10.26	10.22	0.408%
33	11.39	11.37	0.210%
34	12.51	12.49	0.124%
35	13.61	13.60	0.043%
36	14.7	14.70	0.028%
37	15.76	15.77	-0.066%
38	16.82	16.83	-0.051%
39	17.86	17.87	-0.061%
40	18.88	18.90	-0.095%
41	19.89	19.91	-0.102%
42	20.88	20.91	-0.136%
43	21.87	21.89	-0.105%
44	22.84	22.86	-0.107%
45	23.8	23.82	-0.097%
46	24.74	24.77	-0.119%
47	25.68	25.70	-0.092%
48	26.6	26.63	-0.100%
49	27.51	27.54	-0.103%
50	28.42	28.44	-0.067%
51	29.31	29.33	-0.066%
52	30.19	30.21	-0.064%
53	31.06	31.08	-0.063%
54	31.92	31.94	-0.063%
55	32.77	32.79	-0.064%
56	33.62	33.63	-0.039%
57	34.45	34.47	-0.047%
58	35.28	35.29	-0.030%
59	36.1	36.11	-0.018%
60	36.91	36.91	-0.012%
61	37.71	37.71	-0.011%
62	38.5	38.51	-0.016%
63	39.29	39.29	-0.001%
64	40.07	40.07	0.007%
65	40.84	40.84	0.008%
66	41.6	41.60	0.002%
67	42.36	42.35	0.013%
68	43.11	43.10	0.016%
69	43.86	43.85	0.034%
70	44.59	44.58	0.021%
75	48.19	48.17	0.051%
80	51.63	51.61	0.045%
85	54.95	54.92	0.059%
90	58.13	58.11	0.035%
95	61.23	61.19	0.061%
100	64.21	64.18	0.054%
105	67.1	67.06	0.053%
110	69.9	69.87	0.046%
115	72.62	72.59	0.041%
120	75.27	75.24	0.043%
125	77.84	77.81	0.032%
130	80.35	80.33	0.030%
135	82.79	82.77	0.019%
140	85.18	85.16	0.019%
145	87.51	87.50	0.014%
150	89.78	89.78	0.001%
155	92.01	92.01	0.000%
160	94.19	94.19	-0.004%
165	96.32	96.33	-0.012%
170	98.41	98.43	-0.017%
175	100.5	100.48	0.019%
180	102.5	102.49	0.005%
185	104.4	104.47	-0.068%
190	106.4	106.41	-0.011%
195	108.3	108.32	-0.015%
200	110.2	110.19	0.010%
205	112	112.03	-0.026%
210	113.8	113.84	-0.033%
215	115.6	115.62	-0.015%
220	117.3	117.37	-0.058%
225	119.1	119.09	0.008%
230	120.8	120.79	0.011%
235	122.4	122.46	-0.047%
240	124.1	124.10	-0.003%
245	125.7	125.72	-0.020%
250	127.3	127.32	-0.018%
255	128.9	128.90	0.001%
260	130.4	130.45	-0.040%
265	132	131.98	0.012%
270	133.5	133.50	0.003%
275	135	134.99	0.010%
280	136.5	136.46	0.030%
285	137.9	137.91	-0.009%
290	139.4	139.35	0.038%
295	140.8	140.76	0.026%
300	142.2	142.16	0.026%
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker...
AC_Hacker is offline   Reply With Quote
The Following 2 Users Say Thank You to AC_Hacker For This Useful Post:
buffalobillpatrick (02-19-15), WoodBurner (07-09-24)
Old 02-19-15, 09:02 PM   #49
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

Thanks A/C for graph, I removed the fudge_factor after looking at it.

buffalobillpatrick is offline   Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Ad Management by RedTyger
Inactive Reminders By Icora Web Design