In this step, we added the control architecture. How the control is partitioned into various subcontrollers depends usually on the need to avoid communication over the network and on how control is distributed to different field controllers. Here, we used the four controllers indicated by the shaded background in the figure of Buildings.Examples.Tutorial.CDL. One controller switches the overall system on and off, one switches the boiler on and off, one tracks the supply water temperature to the room and one tracks the return water temperature that is fed to the boiler.
This model was built as follows:
First, we determined what functionality should be implemented in which controller, and what the inputs and outputs of the controllers are. In this example, we used these controllers:
Boiler return water controller, with input being the return water temperature TRet
and output being the valve control signal yVal
.
Radiator loop temperature controller, with input being the measured supply water temperature TSup
,
the measured room air temperature TRoo
and output being the valve control signal yVal
.
System on/off controller, with inputs being the outdoor temperature TOut
and the
room air temperature TRoo
, and output being the system on/off signal onSys
.
Note that how inputs and outputs are named can simplify usability. For example, we called the output onSys
so that a value of true
is clearly understood as the system being on. If we had called it
y
, then it would not have been clear what a value of true
means.
Equipment controller, with inputs being the system on/off command and the boiler temperature,
and outputs being
the pump on/off signal onPum
and the boiler on/off signal onBoi
.
To organize our code, we created package that we called Controls
.
Next, we added the open loop controller for the boiler return water temperature.
This controller is implemented in
Buildings.Examples.Tutorial.CDL.Controls.OpenLoopBoilerReturn.
To implement it, we created a Modelica block, and added an input, using a
Buildings.Controls.OBC.CDL.Interfaces.RealInput, called it TRet
for the measured return water temperature, and a
Buildings.Controls.OBC.CDL.Interfaces.RealOutput
for the valve control signal, which we called yVal
.
To output the valve control signal, which we set for now to a constant value of 1, we used an instance of Buildings.Controls.OBC.CDL.Reals.Sources.Constant, set its parameter to 1, and connected it to the output.
At this stage, because the control is open loop, we leave the input of the controller unconnected.
Looking at the Modelica file shows that we also added documentation in an info
section,
a defaultComponentName
, as well as graphical elements so that it is easily distinguishable
in a schematic diagram.
We also added the unit
and displayUnit
attributes.
In the next step of this tutorial, we will provide an actual implementation of the controller. To better distinguish the open loop controller from the closed loop controller, we color the icon of open loop controllers grey, and will change this color to white when we implement the actual control logic.
We did a similar process to add the other three open loop controllers. As before, we added all inputs and outputs, and set the outputs to a constant.
Lastly, we instantiated these four controllers in the system model. Because the pumps and the boiler take as a control input a real-valued signal, we used Buildings.Controls.OBC.CDL.Conversions.BooleanToReal to convert between the boolean-valued signal and the real-valued inputs of these components. Whether this conversion is part of the controller or done outside the controller is an individual design decision.
Create a model, such as this model. To do so,
Implement all four open loop controllers.
Delete the constant control inputs, instantiate the open loop controllers,
convert the signal as needed from Boolean
to Real
,
and connect the control inputs and outputs.
Simulate the system to verify that you get the response shown below. As we have not changed any of the control logic, simulating the system should give the same response as for Buildings.Examples.Tutorial.CDL.System1.