ExampleHeating (FB)¶
FUNCTION_BLOCK ExampleHeating
Example heating circuit
This example function block implements a simple outside temperature dependent water heating circuit to demonstrate how to:
- implement a plant / an aggregate in CFC using CODESYS Building Automation library function blocks 
- SequenceControl can be used for one sequence as well 
- use DailyMeanTemperature to enable / disable heating circuit in “atomatic”-mode 
- use HeatingCharacteristicCurve to compute supply temperature setpoint 
This example involves:
- heating circuit operation enabled / disabled in “auto”-mode using DailyMeanTemperature or outdoor temperature 
- computation of supply temperature setpoint using HeatingCharacteristicCurve 
- night time setpoint reduction vs. switching off heating circuit operation 
- economy mode - switching off circulation pump and mixing valve if supply temperature to low to provide sufficient energy 
- optional anti-freeze 
Watch out for comments in the implementation where those aspects are covered.
 
- outdoor air temperature sensor 
- indoor air temperature sensor 
- supply temperature sensor 
- circulation pump 
- mixing valve 
Heating circuit operation¶
Heating circuit operation could be enabled / disabled manually setting eOnOff accordingly. Heating circuit operation could be determined automatically setting eOnOff to Auto. In “auto”-mode the operation is enabled if either the daily mean temperature or the outdoor temperature (xUseOdaTemp = TRUE) is below rTempLimitEnable.
Night time setpoint reduction vs. switching off heating circuit operation¶
ExampleHeating allows to use either a reduced supply temperature setpoint (rSupplyTempSetpt) at night, or to switch off operation at all.
Economy mode¶
Economy mode is switching off circulation pump and mixing valve if rSupplyTempSetpt is to low to provide sufficient energy. It differentiates low / high temperature heating systems by HeatingCharacteristicCurve gradient. Gradient < 1.0 assumes a low temperature heating system (for example floor heating).
Gradient <= 1.0 - low temperature heating system:
rSupplyTempSetpt < rIdaTempSetpt => switch off rSupplyTempSetpt > rIdaTempSetpt + 2.0K => switch on
Gradient > 1.0 - high temperature heating system:
rSupplyTempSetpt < rIdaTempSetpt + 5.0K => switch off rSupplyTempSetpt > rIdaTempSetpt + 7.0K => switch on
Optional anti-freeze¶
If anti-freeze is activated, there are three separate measures activated:
- low outdoor temperature (rOdaTemp < rAntiFreezeOdaTempLimit) cause the circulation pump to be enabled 
- low supply temperature (rSupplyTemp < rAntiFreezeSupplyTempLimit) cause the heating circuit operation to be enabled anyway 
- low indoor air temperature (rIdaTemp < rAntiFreezeIdaTempLimit) cause the heating circuit operation to be enabled anyway 
Caveats¶
To keep complexity as low as possible this example omits - amongst others - the following real world application aspects worth mentioning:
- configuration missing (configuration of m_heatingCharacteristicCurve, m_circulationPump, m_sequenceControl, m_mixingValve, etc. is not or not completely exposed on the ExampleHeating VAR_INPUT section) 
- sensors missing (circulation pump service / error indication, …) 
- input consistency checks (implausible measurement values, …) 
- day / night operation does often fullfill more complex needs 
- scheduling (for example via BACnet scheduler) might set setpoint instead of day / night 
- ramping up/down the setpoint instead of switching over between day / night setpoint 
- xError / eErrorID not computed at all, see ExampleAirConditioning2 how to do this 
- sensor / actuator process I/O not mapped (FB sensor inputs, m_circulationPump, m_mixingValve) 
- InOut:
- Scope - Name - Type - Initial - Comment - Input - eOnOff- AutoOnOff.Auto - Operation mode preset - rSupplyTemp- REAL- Supply temperature - rOdaTemp- REAL- Outdoor temperature - rIdaTemp- REAL- 21.0 - Indoor air temperature - rIdaTempSetpt- REAL- 21.0 - Indoor air temperature setpoint - rTempLimitAutoEnable- REAL- 16.0 - Temperature limit to enable operation in “auto”-mode - xUseOdaTemp- BOOL- FALSE - Decides whether to use daily mean temperature or outdoor temperature to enable operation in “auto”-mode. xUseOdaTemp := FALSE => use daily mean temperature. xUseOdaTemp := TRUE => use outdoor temperature. - xDayNight- BOOL- TRUE - Decides whether to use day / night operation - rGradient- REAL- 1.2 - HeatingCharacteristicCurve gradient. - rShift- REAL- 0.0 - HeatingCharacteristicCurve parallel shift - rMinimumSupplyTemp- REAL- 20.0 - Supply temperature minimum - rMaximumSupplyTemp- REAL- 80.0 - Supply temperature maximum - xNightSetptReductionEnable- BOOL- TRUE - Decides whether to use night time setpoint reduction vs. switching off heating circuit operation - rNightSetptReduction- REAL- -12.0 - Night time setpoint reduction - xEconomyEnable- BOOL- TRUE - Enables economy mode - xAntiFreezeEnable- BOOL- TRUE - Enables anti-freeze - rAntiFreezeOdaTempLimit- REAL- 4.0 - Anti-freeze outdoor temperature limit - rAntiFreezeSupplyTempLimit- REAL- 10 - Anti-freeze supply temperature limit - rAntiFreezeIdaTempLimit- REAL- 14.0 - Anti-freeze indoor air temperature limit - xReset- BOOL- FALSE - Reset - itfDateTimeProvider- Util.IDateTimeProvider- Globals.g_dtpDateTimeProvider - Source for the current date and time information in milliseconds since 1.1.1970 00:00:00.000 - Output - xOn- BOOL- Heating circuit is activated / enabled - xHeat- BOOL- Heating circuit in operation - rSupplyTempSetpt- REAL- Supply temperature setpoint - xEconomy- BOOL- Economy mode active - xFrostAlarm- BOOL- Frost alarm indication - xCircPump- BOOL- Circulation pump running - rValve- REAL- Mixing valve 
