add dew point caclualtor for scl
This commit is contained in:
parent
606ff8cb96
commit
b323da7288
53
dew-point-calulator.md
Normal file
53
dew-point-calulator.md
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
FUNCTION "FC_DewPoint" : Void
|
||||||
|
{ S7_Optimized_Access := 'TRUE' }
|
||||||
|
|
||||||
|
VAR_INPUT
|
||||||
|
Temperature_C : Real; // Air temperature in degrees Celsius
|
||||||
|
Humidity_RH : Real; // Relative humidity in percent: > 0 to 100
|
||||||
|
END_VAR
|
||||||
|
|
||||||
|
VAR_OUTPUT
|
||||||
|
DewPoint_C : Real; // Calculated dew point in degrees Celsius
|
||||||
|
Valid : Bool; // TRUE when calculation is valid
|
||||||
|
END_VAR
|
||||||
|
|
||||||
|
VAR_TEMP
|
||||||
|
Gamma : Real;
|
||||||
|
END_VAR
|
||||||
|
|
||||||
|
VAR_CONSTANT
|
||||||
|
B : Real := 17.625;
|
||||||
|
C : Real := 243.04;
|
||||||
|
END_VAR
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
// Validate the input range.
|
||||||
|
// RH must be greater than zero because LN(0) is undefined.
|
||||||
|
#Valid :=
|
||||||
|
(#Temperature_C >= -40.0) AND
|
||||||
|
(#Temperature_C <= 50.0) AND
|
||||||
|
(#Humidity_RH > 0.0) AND
|
||||||
|
(#Humidity_RH <= 100.0);
|
||||||
|
|
||||||
|
IF #Valid THEN
|
||||||
|
|
||||||
|
// Gamma =
|
||||||
|
// LN(RH / 100) + (B * Temperature) / (C + Temperature)
|
||||||
|
#Gamma :=
|
||||||
|
LN(#Humidity_RH / 100.0)
|
||||||
|
+
|
||||||
|
((#B * #Temperature_C) /
|
||||||
|
(#C + #Temperature_C));
|
||||||
|
|
||||||
|
// Dew point =
|
||||||
|
// (C * Gamma) / (B - Gamma)
|
||||||
|
#DewPoint_C :=
|
||||||
|
(#C * #Gamma) /
|
||||||
|
(#B - #Gamma);
|
||||||
|
|
||||||
|
ELSE
|
||||||
|
#Gamma := 0.0;
|
||||||
|
#DewPoint_C := 0.0;
|
||||||
|
END_IF;
|
||||||
|
|
||||||
|
END_FUNCTION
|
||||||
Loading…
Reference in a new issue