ExampleRoomAutomation (FB)¶
FUNCTION_BLOCK ExampleRoomAutomation
Example room automation
This example function block implements a very simple room temperature control using a fan coil to demonstrate:
- how to implement a complex control strategy in CFC using CODESYS Building Automation library function blocks 
- how to use certain room automation related function blocks 
- how to use SequenceControl 
This example involves following real world application aspects:
- presence controlled energy level 
- room temperature control using a fan coil Fancoil3Stage 
- energy optimization (night cooling, energy lock, summer compensation) 
- fast heat / cool at “pre-comfort” 
- window alarm 
Watch out for comments in the implementation where those aspects are covered.
 
- outdoor air temperatur sensor 
- room control panel including indoor air temperatur sensor, manual control elements (presence, temperature setpoint, fan speed) 
- presence sensor 
- fan coil (4-pipe system) 
- window actuator 
- window contact 
Air types¶
Air types - terms, abbreviations and colors oriented towards DIN EN 16798-3 - see ExampleAirConditioning1.
Presence controlled energy level¶
In this example energy level is selected by local information - presence information from room control panel and presence sensor. More complex scenarios might involve using a “pre-comfort” energy level controlled by building managment system / room occupancy control system. To keep the example simple, xPrecomfort := TRUE does switch the energy level from “economy” to “pre-comfort”, but doesnt effect an active energy level “comfort”. Dealing with “pre-comfort” is a bit more complex in real world applications.
Night cooling¶
Cooling down the room using cooler outdoor air is done using HeatCoolUsingOutdoorAir.
Energy lock¶
The energy lock function prevents energy consumption if window is opened. Nevertheless building protection is taken care for running the sequence controller with the related building protection setpoints. In case control actions are executed and energy is spent xBuildingProtectionActive is signalling this. The energy lock does imply an on-delay, so window needs to be open for tEnergyLockOnDelay before building protection setpoints are used. Also there is a tEnergyLockMaxTime limiting the duration of the energy lock function.
Sommer compensation¶
Sommer compensation is done shifting the setpoints (in “comfort” energy level only) using a CommandVariable to adjust setpoints.
Fast heat / cool¶
Fast heat / cool is about to bring a room the “comfort” conditions during “pre-comfort” mode because a switch to “comfort” is going to happen soon. Common use case - hotel receptionist does a checkin procedure, starting fast heat / cool right away.
Window alarm¶
Window alarm is signalled, if room is not occupied, window contact is signalling open window and night cooling does not open the window.
Manual fan control¶
Manual fan control can be done via room control panel if room is occupied.
Hints¶
Unused pins of function block instances are hidden, so refer to the function block documentation for more details.
Caveats¶
To keep complexity as low as possible this example omits the following real world application aspects worth mentioning:
- configuration missing (configuration of m_energyLevelSetpoint, m_sequenceControl etc. is not exposed on the ExampleAirConditioning1 VAR_INPUT section) 
- input consistency checks (implausible measurement values, …) 
- simplistic energy level selection - usually their is more complex state machinery in room control panel / building managment system / room occupancy control system 
- “pre-comfort” energy level controlled by building managment system / room occupancy control system 
- xError / eErrorID not computed from xError / eErrorID of function block instances used, see ExampleAirConditioning2 how to do this 
- sensor / actuator process I/O not mapped (FB sensor inputs, m_windowActuator, m_valveHeat, m_valveCool, m_condensatePump, …) 
- InOut:
- Scope - Name - Type - Initial - Comment - Input - xEnable- BOOL- TRUE - Enable - xPresenceSetting- BOOL- TRUE - Presence signalled by room control panel - rIdaTemp- REAL- 22.0 - Indoor air temperature signalled by room control panel - usiFanStageManual- USINT (0..3) - 0 - Fan speed manual control requested by room control panel - 0 => off, or stage 1 .. 3 - xFanStageManual- BOOL- FALSE - Fan speed manual manual control requested by room control panel. - xPrecomfort- BOOL- FALSE - Enables the “pre-comfort” energy level. - xFastHeatCool- BOOL- FALSE - Enables the fast heat / cool mode. - xPresence- BOOL- TRUE - Presence signalled by presence sensor - rOdaTemp- REAL- 10.0 - Outdoor air temperature - xWindowOpen- BOOL- FALSE - Window contact signalling open window. - xNightCooling- BOOL- FALSE - Enable night cooling - xEnergyLock- BOOL- FALSE - Enable energy lock - tEnergyLockOnDelay- TIME- TIME#10s0ms - Energy lock on-delay - tEnergyLockMaxTime- TIME- TIME#10m0s0ms - Energy lock maximum duration - xSummerCompensation- BOOL- FALSE - Enable summer compensation - 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 - eLevel- Energy level - eMode- Operation mode. - xWindowAlarm- BOOL- Window alarm - xBuildingProtectionActive- BOOL- There are control actions / energy consumption to keep indoor air temperature in the building protection setpoint range. 
