FB_DALIV2Ramp
Function-block creating a light-ramp.
With a rising-edge at bOn the light will be switched immediately to the maximum-level of the master-device and a rising edge at bOff turns the light off. Triggering the input bToggle inverts the actual light-state. A rising-edge at bStart starts dimming the light from the actual to the end-level (nEndLevel) - the required time is defined by tRampTime.
As long as bEnable is TRUE all inputs are active, otherwise the controlling inputs bOn, bOff, bToggle and bStart are deactivated and the function-block turns to its idle-mode. With every start of the dim-ramp the target-value nEndLevel is checked if it is within the allowed range of the DALI-Master-Device (MIN LEVEL ... MAX LEVEL or „0“).
Ramp-Calculation
The functionality of this function-block is based on whether up- or down-dimming has been selected through the OnAndStepUp- or StepDownAndOff-command. The required number of step-commands are calculated and sent to the lamps equally distributed over the ramp-time.
For ramp times less than 11s it is possible that the calculated time for one step will be less than the time required to run the commands themselves. To achieve these short ramp times (<11s), the function block switches its mode. It will no longer work with a calculated number of steps, but rather with a single DirectArcPower-command. This command dims the addressed lamps from their actual-level to the end-level in a specified FADE TIME which is programmed in the control-devices of the lamps. 16 different values are possible for this Fade-Time:
nFadeTime | tFadeTime (s) |
---|---|
0 | <0,0707 |
1 | 0,707 |
2 | 1,000 |
3 | 1,414 |
4 | 2,000 |
5 | 2,828 |
6 | 4,000 |
7 | 5,657 |
8 | 8,000 |
9 | 11,314 |
10 | 16,000 |
11 | 22,627 |
12 | 32,000 |
13 | 45,255 |
14 | 64,000 |
15 | 90,510 |
The value closest to the desired ramp-time will be taken and programmed into all selected devices. For example, with a desired ramp-time of 6s the function block will select level 7 = 5,657 s. After driving the ramp successfully, all selected devices will be re-programmed with the original Fade-Time of the master-device.
During the ramp-driving the output-value nActualLevelMasterDev will be given as a calculated value, in order not to stress the DALI-Bus with query-commands. This calculation is based upon the difference of start- and end-level and the selected ramp-time from the table above. Because this value is a calculated one it may not be exact at any time and is only to be seen as an orientation. After the ramp-driving a query-command is sent to read an exact value for nActualLevelMasterDev.
Parameter nMasterDevAddr
The DALI system provides facilities not just for controlling lamps individually, but also for addressing them as groups or through common commands. Because the individual devices can be members of a variety of groups, it can happen that, prior to the issue of a group or common control command, the individual lamps have different brightness levels. So that it is nevertheless possible to be clear whether the lamps now are to be switched on or off, a master device is assigned to each group, whose state is followed by the other devices. It is not necessary to specify a master device if the function block is to be used to control a single lamp, eAddrType = eAddrTypeShort. In this case, the nMasterDevAddr parameter has no significance.
VAR_INPUT
bEnable : BOOL := TRUE;
bOn : BOOL;
bOff : BOOL;
bToggle : BOOL;
bStart : BOOL;
nEndLevel : BYTE := 254;
tRampTime : TIME := t#8s;
nOptions : DWORD := 0;
nAddr : BYTE := 0;
eAddrType : E_DALIV2AddrType := eDALIV2AddrTypeShort;
nMasterDevAddr : BYTE := 0;
tCycleActualLevelMasterDev : TIME := t#0s;
bEnable: A positive input enables the function block. A negative state deactivates the inputs bOn, bOff, bToggle and bStart and sets the function-block to the idle-mode, after the last necessary DALI-commands are sent. Except for the cyclic query of the light-level of the master-device, the function-block sends no further DALI-commands.
bOn: A rising edge sets the addressed lamps directly to the maximum-level of the master-device.
bOff: A rising edge turns the addressed lamps immediately off.
bToggle: Rising edges at this input toggle the state the addressed lamps.
bStart: This input starts the dim-ramp from the actual value (of the master-device) to the target-value nEndLevel within the time defined as tRampTime. This can be interrupted by bOn, bOff or bToggle at any time.
nEndLevel: Target-value of the dim-ramp. (Valid range: 0 or MIN LEVEL ... MAX LEVEL).
tRampTime: Ramp-time, see bStart. (initial value: 8s).
nOptions: Reserved for future developments.
nAddr: The address of a participating device or of a group.
eAddrType: Short address, group address or broadcast.
nMasterDevAddr: The address of the master device for group and common switching operations.
tCycleActualLevelMasterDev: Cycle time required to read the current actual value (ACTUAL DIM LEVEL) in the background. In order not to disturb the dimming of the lamps, reading always has the lowest priority. If the value is set to 0, reading is deactivated.
VAR_OUTPUT
nActualLevelMasterDev : BYTE;
bBusy : BOOL;
bError : BOOL;
nErrorId : UDINT;
ActualLevelMasterDev: The current output value of the master device (if eAddrType = eAddrTypeShort this is always the device being addressed at the time).
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
stCommandBuffer : ST_DALIV2CommandBuffer;
stCommandBuffer: A reference to the structure for communication with the FB_DALIV2Communication() (KL6811) or FB_KL6821Communication() (KL6821) block.