FB_ConstantLightControlEco
The function block is used for constant light control.
The system tries to match a specified setpoint through cyclic dimming. The control dynamics are determined by a dead time (tDeadTime) and the step size (nStepSize). The dead time specifies the waiting time between the individual steps or increments of the control value, which are determined by the set step size. The smaller the dead time, the faster the control. A freely definable hysteresis (nHysteresis) prevents continuous oscillation around the setpoint. If the actual value is within the hysteresis range around the setpoint, the lamps brightness remains unchanged.
Note | |
If the set step size nStepSize is too large or the hysteresis nHysteresis is too small, the hysteresis range may be "missed". This cannot be prevented by the function block, because the light output nLightLevel is only physically linked to the recorded actual light value, nActualLevel. |
VAR_INPUT
bEnable : BOOL;
bOn : BOOL;
bOff : BOOL;
bToggle : BOOL;
nSetpointValue : UINT := 16000;
nActualValue : UINT;
nHysteresis : UINT := 100;
nMaxLevel : UINT := 32767;
nMinLevel : UINT := 3276;
nStepSize : UINT := 10;
tDeadTime : TIME := t#50ms;
nOptions : DWORD;
bEnable: Enables the function block. If this input is FALSE, the inputs bOn, bOff and bToogle are disabled. The control value remains unchanged.
bOn: Switches the controlled devices to nMaxLevel and activates constant light control.
bOff: Switches the addressed devices off and disables constant light control.
bToggle: The lighting is switched on or off, depending on the state of the reference device.
nSetpointValue: This input is used for specifying the setpoint.
nActualValue: The actual value is applied at this input.
nHysteresis: Control hysteresis around the setpoint. If the actual value is within this range, the control values for the lamps remain unchanged.
nMaxLevel: Maximum value of the control value at nLightLevel.
nMinLevel: Minimum value of the control value at nLightLevel. If this value is to be undercut by a dimming process, nLightLevel is set directly to "0". On the other hand, if nLightLevel is set to "0" when control is active, the dimming process starts directly at this value.
nStepSize: Step size with which the control value nLightLevel is changed.
tDeadTime: Dead time between the individual steps (up or down) of the control value.
nOptions: Currently not used. Reserved for future extensions.
VAR_OUTPUT
nDeviation : INT;
bControllerIsActive : BOOL;
bBusy : BOOL;
bError : BOOL;
nErrorId : UDINT;
nDeviation: Current control deviation (setpoint/actual value).
bControllerIsActive: This output is set once the control is activated.
bBusy: When the function block is activated, this output is always active when changes are made to the control value.
bError: This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in nErrorId. Is reset to FALSE by the execution of a command at the inputs.
nErrorId: Contains the command-specific error code of the most recently executed command. Is reset to "0" by the execution of a command at the inputs.
See Error codes.
VAR_IN_OUT
nLightLevel : UINT;
nLightLevel: Output control value of the function block and reference to the light output value. This value is defined as In-Out variable because the function block reads and writes the light value.
Flow diagram
The following diagram illustrates the regular control behavior:
The control is enabled by a TRUE signal at input bEnable. When a positive edge is encountered at bOn, nLightLevel is set to the maximum value. This also influences the measured light value nActualValue, which increases, so that dimming becomes necessary. nLightLevel is now reduced step-by-step until the measured light value nActualValue is in the hysteresis range around the setpoint (nSetpointValue - 0.5*nHysteresis < x < nSetpointValue + 0.5*nHysteresis).
If, for example, the measured light value then falls, e.g. due to cloudiness, the control system counteracts this by gradually increasing the lighting level until the light value is back in the hysteresis band.
If the step size nStepSize is too large or the hysteresis is too small, an oscillation around the setpoint can occur. Because the hysteresis is small compared to the step changes, the hysteresis range is constantly missed:
Requirements
Development environment | Required PLC library |
---|---|
TwinCAT from v3.1.4020.32 | Tc2_BABasic from v3.1.0.0 |