From b323da7288c113f332469ccd07b7ceb243c8859a Mon Sep 17 00:00:00 2001 From: Dejan Date: Mon, 13 Jul 2026 10:23:21 +0000 Subject: [PATCH] add dew point caclualtor for scl --- dew-point-calulator.md | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dew-point-calulator.md diff --git a/dew-point-calulator.md b/dew-point-calulator.md new file mode 100644 index 0000000..095672f --- /dev/null +++ b/dew-point-calulator.md @@ -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 \ No newline at end of file