FB_BARStairwellAutomatic
Function block for a stairwell light circuit.
The function block knows 3 different modes, which can be set via the input uiLightCtrlMode:
- Automatic mode
- Manual On mode
- Manual Off mode
The stairwell control is active in automatic mode (uiLightCtrlMode=0). A positive edge on bSwitch initially only switches the light on (output bOn). A negative edge starts the holding time generator. If the hold time uiHoldTime [s] has expired, a flash sequence with a number of flash pulses programmable by uiNumberPulses begins as a warning of the impending switch-off. These pulses have an on-time of uiPulseTimeOn [ms] and an off-time of uiPulseTimeOff [ms].
The sequence can be restarted at any time:
In the manual operation modes the input bSwitch has no function: with uiLightCtrlMode=1 the output value bOn is constantly set to TRUE and with uiLightCtrlMode=2 it is constantly set to FALSE.
Changing to manual mode resets any lighting sequence that had started up to that point.
VAR_INPUT
eDataSecurityType: E_HVACDataSecurityType;
uiLightCtrlMode : UINT;
bSwitch : BOOL;
eDataSecurityType:if eDataSecurityType:= eDataSecurityType_Persistent, the persistent VAR_IN_OUT variables of the function block are stored in the flash of the computer if a value changes. For this to work, the function block FB_HVACPersistentDataHandling must be instanced once in the main program, which is called cyclically. Otherwise the instanced FB is not internally released.
A change of value can be initiated by the building management system, a local operating device or via a write access from TwinCAT. When the computer is restarted, the saved data are automatically read back from the flash into the RAM.
Application example: Example_PERSISTENT.zip
If eDataSecurityType:= eHVACDataSecurityType_Idle the persistently declared variables are not saved in a fail-safe manner.
Notice | |
A cyclically changing variable must never be linked with the IN_OUT variable of a function block, if eDataSecurityType:= eHVACDataSecurityType_Persistent. It would lead to early wear of the flash memory. |
uiLightCtrlMode : operation mode.
- 0: automatic mode; the stairwell circuit is active and reacts to the input bSwitch.
- 1: Manual On mode; the stairwell circuit is inactive - the output bOn is set constantly to TRUE.
- 2: Manual Off mode; the stairwell circuit is inactive - the output bOn is set constantly to FALSE.
bSwitch: a rising edge switches the light on in automatic mode (uiLightCtrlMode=0), a falling edge starts the holding time generator. This input has no function in manual operation mode (uiLightCtrlMode=1 or 2).
VAR_OUTPUT
lrDimValue : LREAL;
bOn : BOOL;
uiRemainingHoldTime: UINT;
bError : BOOL;
udiErrorId : UDINT;
lrDimValue : in order to keep this function the same as the other light user functions, a light output value exists here too in the form of a floating point number in percent, even though the light is only switched on or off. This means: light off: lrDimValue = 0.0, light on: lrDimValue = 100.0.
bOn : switching output for the lighting.
uiRemainingTimeHold: remaining hold time in seconds. If the light is off or if manual operation mode is active, then this output is "0". With a rising edge on bSwitch in automatic mode, this output initially indicates the complete number of seconds of the hold time (uiHoldTime), in order to illustrate the countdown of the hold time, starting with a falling edge on bSwitch. This output is 0 as long as no countdown of the time is taking place.
bError: this output is switched to TRUE if the parameters entered are erroneous.
udiErrorId : contains the error code if the values entered should be erroneous. See error codes.
VAR_IN_OUT
In order for the registered parameters to be retained beyond a controller failure, it is necessary to declare them as In-Out variables. A reference variable is then assigned to them in the program. Each change of the value of these reference variables is persistently stored in the function block and written back to the reference variable following a controller failure and restart. If the parameters were only declared as input variables, they would not be able to write a reference variable.
Application example: Example_PERSISTENT.zip.
uiHoldTime : UINT;
uiPulseTimeOn : UINT;
uiPulseTimeOff : UINT;
uiNumberPulses : UINT;
uiHoldTime : hold time [s] of the stairwell controller after a falling edge on bSwitch.
uiPulseTimeOn: ON-time of the early warning pulses in milliseconds.
uiPulseTimeOff: OFF-time of the early warning pulses in milliseconds.
uiNumberPulses: number of early warning pulses.