FB_Sequencer
Function-block to program light-sequences with up to 50 different steps.
This function-block is based on a ramp-function, which drives the output to a target-value (nTargetValue)i n a specified time (tRampTime) . When the target-value is reached, the light will stay at this level for a specified time (tProlongTime). Once tProlongTime has elapsed, the light will ramp to the next target value.
The Sequence table consists of 50 elements containing the target-value (nTargetValue), the ramp-time (tRampTime) and the time to hold a reached light-level (tProlongTime). It is not required to use all 50 elements of the table. An element containing only zeros for the target-value, ramp-time and prolong-time will be recognized as the end of a sequence. Furthermore it is possible to let a sequence start at a specific position with the input-value, nStartIndex. With nStartIndex it is possible to program different light-sequences within the 50 elements of the table which are separated by simple zero-elements (delimiters).
The light-level programmed with sequence No.1, for example, will show the following behaviour (nStartIndex=1, nOptions.bit0=TRUE, explanations see below):
The function-block has inputs to switch the light on and off (on: nLightLevel = 32767, off: nLightLevel = 0) as well as an input bToggle to invert the actual light-state. All inputs are only read by the function-block, if bEnable is set to TRUE. If bEnable is reset to FALSE, all inputs are inactive and nLightLevel will remain on its actual value.
VAR_INPUT
bEnable : BOOL;
bOn : BOOL;
bOff : BOOL;
bToggle : BOOL;
bStart : BOOL;
nStartIndex : USINT;
arrSequenceTable : ARRAY[1..50] OF ST_SequenceTable;
nOptions : DWORD;
bEnable: A positive input enables the function block. A negative state deactivates the inputs and sets the function-block to the idle-mode.
bOn: A rising edge sets the output nLightLevel directly to the maximum-level (32767).
bOff: A rising edge sets the output nLightLevel immediately to "0".
bToggle: Rising edges at this input toggle the nLightLevel between "0" and "32767".
bStart: This input lets the sequence begin with the element defined with nStartIndex.
nStartIndex: See bStart.
arrSequenceTable: Light-value-table with the information about the target-value, the ramp-time and the prolong-time.
TYPE ST_SequenceTable : STRUCT nTargetValue : UINT; tRampTime : TIME; tProlongTime : TIME; END_STRUCT END_TYPE nTargetValue: Target-value. tRampTime: Time to reach the target-value. tProlongTime: Time to stay on the target-value. |
nOptions: Parameter-input. Setting (resp. not-setting) of the single bits will affect the behaviour of the function-block as follows:
Constant | Description |
---|---|
OPTION_INFINITE_LOOP | After running through a sequence, the function-block will automatically restart at the element defined with nStartIndex. If this option is not set the function-block will stop after running through the sequence. In order to start again, a rising edge at bStart is neccessary. |
VAR_OUTPUT
nActualIndex : USINT;
bLight : BOOL;
bSequenceActive : BOOL;
bBusy : BOOL;
bError : BOOL;
nErrorId : UDINT;
nActualIndex: This output shows the actual element of the light-sequence. If the sequence is finished or stopped (bSequenceActive = FALSE , see below) , the output will fall back to "0".
bLight: As long as nLightLevel is greater than "0", this output is set to TRUE.
bSequenceActive: If a light-sequence is running, this output is set to TRUE.
bBusy: When the block is activated the output is set, and it remains active until execution of the command has been completed.
bError: This output is switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in nErrorId. bError is reset to FALSE by the execution of an instruction at the inputs.
nErrorId: Contains the command-specific error code of the most recently executed command. nErrorId is reset to 0 by the execution of an instruction at the inputs. See Error codes.
VAR_IN_OUT
nLightLevel : UINT;
nLightLevel: Reference to the actual light-level-output.