FB_Sequencer

FB_Sequencer 1:

Function block for realizing light sequences with up to 50 interpolation points.

At the core of this function block is a ramp that approaches individual brightness values defined in a table within an adjustable time and then remains at this brightness value for a time that can also be defined. After the dwell time the next value is then driven to. As already mentioned, the table arrSequenceTable consists of 50 entries with the values for nTargetValue (target value), tRampTime (time taken to reach the target value) and tProlongTime (dwell time at the target value). It is not absolutely necessary to use all 50 values. A 0 entry of all 3 values marks the end of a sequence. Beyond that it is possible using the nStartIndex input to have a light sequence begin at any desired place in the table. This allows several different light sequences to be programmed even within the 50 entries, the sequences being separated from one another by 0 entry elements:

FB_Sequencer 2:

Over the course of time sequence 1, for example, looks like the following (nStartIndex=1, nOptions.bit0=TRUE, see below for explanation):

FB_Sequencer 3:

In addition, the function block can be switched on and off "normally" (On: nLightLevel = 32767, Off: nLightLevel = 0) or toggled between "On" and "Off" via the input bToggle. However, none of the command inputs is active unless the bEnable input is TRUE. If it is reset to FALSE, no more commands are accepted and the light value retains its current state – even from a ramp.

VAR_INPUT

bEnable            : BOOL;
bOn                : BOOL;
bOff               : BOOL;
bToggle            : BOOL;
bStart             : BOOL;
nStartIndex        : USINT;
arrSequenceTable   : ARRAY[1..50] OF ST_SequenceTable;
nOptions           : DWORD;

bEnable: The bOn, bOff, bToggle and bStart inputs are active as long as this input is TRUE. A negative state deactivates the inputs and resets the function block.

bOn: A rising edge directly switches nLightLevel to the maximum value (32767).

bOff: A rising edge directly switches nLightLevel to "0".

bToggle: Switches the light state between On (32767) and Off (0).

bStart: A positive edge starts a light sequence from the beginning defined under nStartIndex.

nStartIndex: See bStart.

arrSequenceTable: Light value table with the corresponding ramp and dwell times (see ST_SequenceTable).

nOptions: Parameterization input. The setting (or non-setting) of the individual bits of this variable of the type DWORD has the following effect:

Constant

Description

OPTION_INFINITE_LOOP

Following the expiry of a sequence, the function block automatically continues at the point defined at nStartIndex. If this option is not set, the sequence stops after it has elapsed. A new positive edge at bStart would be necessary to restart a sequence.

VAR_OUTPUT

nActualIndex       : USINT;
bLight             : BOOL;
bSequenceActive    : BOOL;
bBusy              : BOOL;
bError             : BOOL;
nErrorId           : UDINT;

nActualIndex: Reference to the current element in the sequence table. If a sequence has been completed (bSequenceActive = FALSE, see below), this output goes to "0".

bLight: This output is set as long as nLightLevel is greater than "0".

bSequenceActive: On processing a sequence this output is set to TRUE.

bBusy: This output is always active as long as the processing of a command (bOn, bOff, bToggle or ramp) is active.

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 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.

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4020.32

Tc2_BABasic from v3.1.0.0