Quantcast

Need formula to calculate head pressure from Volumes of CO2

HomeBrewTalk.com - Beer, Wine, Mead, & Cider Brewing Discussion Community.

Help Support Homebrew Talk:

trimixdiver1

Well-Known Member
Joined
Dec 29, 2013
Messages
894
Reaction score
132
Location
Pittsburgh
Im programing a carbonation calculator into my PLC to control my Brite Tank

Im looking for a formula that will give me the pressure to carbonate to, I will have the Temp of the tank and will know what volumes I want.

Thanks!!!
 

ajdelange

Well-Known Member
Lifetime Supporter
Joined
Aug 5, 2010
Messages
11,959
Reaction score
2,720
Location
McLean/Ogden
V = (P + 14.695)*(0.01821 + 0.090115*exp( -(T-32)/43.11) ) - 0.003342

with P in PSIG and T in °F is a pretty good (rmse = 0.01 Vol; peak error -0.044 Vols @37 °F, 10 psig, 3.27 Vols) fit to the ASBC table.
 

ajdelange

Well-Known Member
Lifetime Supporter
Joined
Aug 5, 2010
Messages
11,959
Reaction score
2,720
Location
McLean/Ogden
As you can see it is indeed a perfectly valid equation. I cannot explain this but the last minus sign was not a really a minus sign. i edited it and it copies and pastes into two programs OK now.
 
OP
trimixdiver1

trimixdiver1

Well-Known Member
Joined
Dec 29, 2013
Messages
894
Reaction score
132
Location
Pittsburgh
((R1096 + 14.695) * (0.01821 + (0.090115 ** (-(R1090 - 32) / 43.11)))) - 0.003342

This is how it lays out in my PLC

r1096 is pressure
r1090 is temperature

still not correct.

Also Im trying to input the volumes and output the pressure. Im not great with long equations, thanks
 

ajdelange

Well-Known Member
Lifetime Supporter
Joined
Aug 5, 2010
Messages
11,959
Reaction score
2,720
Location
McLean/Ogden
Don't know what language you are working in but 2 ** 3 in FORTRAN means raise 2 to the 3rd power with result = 8. Here we are raising a number to a power but it is e = 2.71828..., not 0.090115. The appropriate function in FORTRAN would be EXP and a FORTRAN compiler would have no problem with the formula as given in #2. If your compiler (or its math libraries) don't have an EXP function you will have to get it by recognizing that EXP(x) is equivalent to 2.718281828 ** x in FORTRAN notation.

Getting pressure from volume and temperature is a simple matter of solving for P

P = (V + 0.003342)/(0.01821 + 0.090115*exp( -(T-32)/43.11) ) -14.695
 
OP
trimixdiver1

trimixdiver1

Well-Known Member
Joined
Dec 29, 2013
Messages
894
Reaction score
132
Location
Pittsburgh
((R1096 + 0.003342) / (0.01821 + (0.090115 * (2.718282 ** (-(R1090 - 32) / 43.11))))) - 14.695

R1096 is Vols
R1090 is Temp


Im so lost right now.....

Here is a copy of the DoMore PLC instructions

The Math Raise to a Power operator ( ** ) will calculate the result of a base raised to the power of an exponent. The result of this calculation will always be a Real (floating point) value and should be placed in a Real memory location to preserve the fractional portion. This is especially important if the exponent is negative or if the exponent is a Real value,



Any value raised to the 0 power is 1. The value 0 raised to any power is 0. Note: 0 raised to the 0 power is 1.



The base and exponent can be any mix of signed integers, unsigned integers, real (floating point) numbers or discrete values. They can be any numeric or discrete memory location or any numeric or discrete structure member.



Traditional math precedence rules are used to solve the math expression. The use of parentheses to remove any ambiguity in the processing order is encouraged.



Refer to the examples below:








Signed Integers: assume D1 = 2 and D2 = 3




D0 = D1 ** D2

D0 = 2 ** 3
D0 = 8



Both the base and the exponent are integer memory locations.



The result is placed in an integer memory location.




D0 = (D1 ** D2) ** D1



D0 = (2 ** 3) ** 2
D0 = 8 ** 2

D0 = 64



The base and exponents are integer memory locations.



The result is placed in an integer memory location.




D0 = D1 ** (D2 ** D1)



D0 = 2 ** (3 ** 2)
D0 = 2 ** 8

D0 = 256



The base and exponents are integer memory locations.



The use of parentheses specifies the order of operation which yields a different result than the same values above.



The result is placed in an integer memory location.




R0 = D1 ** 0.5

R0 = 2 ** 0.5

R0 = 1.414

The base is an integer memory locations, the exponent is a Real constant.



The exponent is non-integer, which will generate a non-integer result. Place the result in a Real memory location to preserve the fractional portion.



The result is placed in a Real memory location.




R0 = D1 ** -3

R0 = 2 ** -3

R0 = 0.1250

The base is an integer memory locations, the exponent is an integer constant.



The exponent is negative, which will generate a non-integer result. Place the result in a Real memory location to preserve the fractional portion.



The result is placed in a Real memory location.











Numeric Structure Members: assume D1 = 10 and Timer T0.Acc = 5ms




D0 = D1 ** T0.Acc



D0 = 10 ** 5

D0 = 100000



The base is an integer memory location, the exponent is a structure member.



The .Acc member of a Timer structure contains the amount of time in milliseconds that has accumulated in a Timer.



The result is placed in an integer memory location.










Casting Numeric Values: assume DLV2000 and DLV2001 as a 32-bit Real = 123.45




R0 = DLV2000:RD ** 2



R0 = 123.45 ** 2

R0 = 15239.9



The base is using the 'Real and DWord' cast operators, the exponent is an integer constant.



The result is placed in a floating point memory location.



DLV memory locations are 16-bit Unsigned used by external DirectLOGIC devices. In this example a remote DirectLOGIC CPU has written a 32-bit floating point value into two successive DLV memory locations. Using the :RD cast operator will interpret the 32-bit value in DLV2000 and DLV2001 as a REAL number.
 

ajdelange

Well-Known Member
Lifetime Supporter
Joined
Aug 5, 2010
Messages
11,959
Reaction score
2,720
Location
McLean/Ogden
If I cut your line from the post, change R1096 to 2.73175 volumes and R1090 to 40 °F and replace ** with ^ which is the raise to a power operator in the program I use and then type

•print ((2.73175 + 0.003342) / (0.01821 + (0.090115 * (2.718282 ^(-(40 - 32) / 43.11))))) - 14.695

it returns 14.695 which is the correct answer. IOW you have an instruction which, as far as I can tell, is correct. The instructions you posted confirm this. The only thing I can think of the variables you are passing are not floating point numbers.

I don't know what else I can advise here. You have a formula which compilers can understand. Perhaps you could break it down into smaller parts, trying each one out in Excel, for example.
 
OP
trimixdiver1

trimixdiver1

Well-Known Member
Joined
Dec 29, 2013
Messages
894
Reaction score
132
Location
Pittsburgh
((R1096 + 0.003342) / (0.01821 + (0.090115 * (2.718282 ^ (-(R1090 - 32) / 43.11))))) - 14.695

With
R1096 = 2.75
R1090= 32.0

I get -0.920851

My numbers are REAL

Dont know whats going on?
 
Joined
Jul 17, 2012
Messages
2,909
Reaction score
357
Location
Eagleville
I got 10.8224198 using 2.75 for r1096 and 32for r1090 so not sure what you have going on. I'd double check your equations with care as to which parentheses go where around your exponent gets a bit confusing at least as shown here. Could be where you issue is. If not I'm sure one of the more knowledgeable members will point out where.
 
Top