ExampleHotWater (FB)

FUNCTION_BLOCK ExampleHotWater

Example hot water boiler control

This example function block implements a simple hot water boiler control to demonstrate how to implement a plant / an aggregate in ST using CODESYS Building Automation library function blocks. All other examples are implemented using CFC, because this way it’s a bit more easy to read / understand. No matter of this ST is also a good choice to implement plants / aggregates. Here we demonstrate, that an implementation using ST is also easy to read / understand if structured nicely and well documented.

This example involves:

  • 2 point control of boiler temperature

  • steady control of boiler supply temperature

  • demand-based activation of loading pump

  • legionella prevention

  • optional unload protection using supply temperature sensor

Watch out for comments in the implementation where those aspects are covered.

../../../_images/ExampleHotWater.png
  1. supply temperature sensor

  2. mixing valve

  3. loading pump

  4. boiler supply temperature sensor

  5. upper boiler temperature sensor

  6. lower boiler temperature sensor

  7. circulation pump

2 point control of boiler temperature

A boiler load cycle is requested, if boiler temperature is below setpoint. The boiler load cycle is stopped, if boiler temperature exceeds setpoint plus hysteresis.

Legionella prevention

Boiler temperature is to be kept above 60°C for at least an hour the day. Circulation pump is enabled during this load cycle.

Optional unload protection

In case there is a supply temperature sensor ExampleHotWater checks the supply temperature before / during a load operation. In case the supply temperature is below boiler temperature the boiler will not be loaded.

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_legionellaPreventionDone, m_legionellaPreventionTimer, m_loadPump, m_circPump, m_mixingValve etc. is not or not completely exposed on the ExampleHotWater VAR_INPUT section)

  • input consistency checks (rHyst <= 0, implausible measurement values, …)

  • no legionella warning issued, if legionella prevention load cycle is missed due to unload conditions

  • sensors missing (both pumps - service / error indication, …)

  • xError / eErrorID not computed at all, see ExampleAirConditioning2 how to do this

  • sensor / actuator process I/O not mapped (FB sensor inputs, m_loadPump, m_circPump, m_mixingValve, …)

InOut:

Scope

Name

Type

Initial

Comment

Input

rSetpt

REAL

50.0

Hot water temperature setpoint

rHyst

REAL

5.0

Hot water temperature hysteresis

rSupplyTemp

REAL

Supply temperature

xSupplyTempSensor

BOOL

FALSE

Optional supply temperature sensor exists

rBoilerSupplyTemp

REAL

Boiler supply temperature

rBoilerTemp1

REAL

Upper boiler temperature

rBoilerTemp2

REAL

Lower boiler temperature

xCircPumpRequest

BOOL

FALSE

Request circulation pump

tLegionella

TIME

TIME#1440m0s0ms

Time to next legionella prevention boiler load cycle

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

rRequestedBoilerTemp

REAL

Requested boiler temperature

xLegionellaPreventionDone

BOOL

Legionella prevention has been done in the last 24 hours

xLoad

BOOL

Boiler will be loaded actually.

xLoadPump

BOOL

Loading pump running

xCircPump

BOOL

Circulation pump running

rValve

REAL

Mixing valve

tLegionellaRemaining

TIME

Remaing time to next legionella prevention boiler load cycle