Control Loops
BACnet specifies a Loop object type to provide the parameters for control loops (e. g. P, I, D, Bias, Maximum_Output, etc.). These values are provided as properties of the Loop object type.
In case the setpoint, manipulated variable value and the controlled variable value should be visible for BACnet clients, analog objects may be specified in addition to the loop object. TwinCAT provides two implementations for control loops:
FB_BACnet_Loop: Loop object w/o external references, the setpoint and manipulated and control values are taken from internal variables.
FB_BACnet_Loop_Ref: Loop object with external references. A typical implementation may include an Analog Value object for the setpoint, Analog Output for the manipulated variable value and an Analog Input for the controlled variable value.
Example:
VAR
// control loop using internal variables
fbLoopInternal : FB_BACnet_Loop := (
bEn := TRUE,
sDescription := 'Loop using internal control parameters',
eOutputUnit := E_BA_Unit.eOther_Percent,
eAction := E_BA_Action.eReverse,
fProportionalConstant := 5.0,
fIntegralConstant := 180,
fSetpoint := 20
);
fCtrlVal : REAL := 18;
// control loop using external BACnet objects
fbLoopRef_Setpt : FB_BACnet_AV_Setp := (fValue := 20);
fbLoopRef_CtrlVar : FB_BACnet_AI := (fVal := 18);
fbLoopRef_Y : FB_BACnet_AO := ();
fbLoopRef : FB_BACnet_Loop_Ref := (
bEn := TRUE,
sDescription := 'Loop using reference objects',
stControlledVariableReference :=
F_BACnet_Reference(fbLoopRef_CtrlVar, PropPresentValue),
stSetpointReference :=
F_BACnet_Reference(fbLoopRef_Setpt, PropPresentValue),
stManipulatedVariableReference :=
F_BACnet_Reference(fbLoopRef_Y, PropPresentValue),
eOutputUnit := E_BA_Unit.eOther_Percent,
eAction := E_BA_Action.eReverse,
fProportionalConstant := 5.0,
fIntegralConstant := 180
);
END_VAR
------------------------------------------------------------------
// internal control loop
fbLoopInternal.fCtrlVar := fCtrlVal;
fbLoopInternal();
// control loop using external object references
fbLoopRef_Setpt();
fbLoopRef_CtrlVar();
fbLoopRef_Y();
fbLoopRef();