FB_DALIV2Ramp
The function block FB_DALIV2Ramp is used to implement a light ramp.
A rising edge at the input bOn switches the light to the maximum value of the master lamp. A rising edge at input bOff switches the light off. Rising edges at the input bToggle invert the respective light state. A positive edge at the input bStart allows the function block to dim the light from the current level to nEndLevel. The time required for this is defined by tRampTime. All inputs are only active as long as bEnable is TRUE, otherwise the function block is reset internally and no further DALI commands are issued.
Each time the dimming ramp is started, a check is carried out to ensure that the nEndLevel value is within the permissible limits (MIN LEVEL ... MAX LEVEL) of the master device. The value "0" is also allowed.
Ramp implementation
Basically, the function block is designed such that it issues the required number of OnAndStepUp or StepDownAndOff commands at uniform intervals within the specified ramp time.
The processing of these step and query commands, however, takes time. The further the ramp time is reduced, the more likely it is that the internally calculated time for a StepUp or StepDown command is no longer sufficient; the actual ramp time becomes longer and longer compared to the set time.
In order to be able to realize small ramps, the function of the function block is switched from step mode to DirectArcPower mode below an internally preset limit value of 11 s ramp time. The DALI command DirectArcPowerControl brings the corresponding lamps from their current value to the set end value within the FADE TIME. There are a total of 16 different fade time values, which are stored in the control device of each lamp and can assume the following values:
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 next value for the ramp that is set at the function block is taken from the table and programmed for all control gears to be controlled. At 6 s, step 7 = 5.657 s would apply, for example. The same value would also be used for a ramp time of 5 s. Precise timing would then no longer be possible. After successful completion of the ramp control, the value that the master device had before the time setting is transferred back to all control gears.
During the ramp, the output value nActualLevelMasterDev is output as an internally calculated value so as not to burden the DALI bus with constant query commands. This calculation is based on the difference between start and end value and the selected ramp time. Since it is a calculated value, it can be subject to errors caused by rounding and command delays and should only be used as a guide. After completion of the ramp the brightness is queried directly and the output value is exact again.
Comment on the nMasterDevAddr parameter
The DALI system provides facilities not just for controlling lamps individually, but also for addressing them as groups or through common commands. Since the individual devices may belong to different groups, the individual lamps may have different brightness states before a group or common control command. 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.
Inputs
VAR_INPUT
bEnable : BOOL := TRUE;
bOn : BOOL;
bOff : BOOL;
bToggle : BOOL;
bStart : BOOL;
nEndLevel : BYTE;
tRampTime : TIME := t#8s;
nOptions : DWORD := 0;
nAddr : BYTE := 0;
eAddrType : E_DALIV2AddrType := eDALIV2AddrTypeShort;
nMasterDevAddr : BYTE := 0;
tCycleActualLevelMasterDev : TIME := t#0s;
END_VAR
Name | Type | Description |
---|---|---|
bEnable | BOOL | 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 after processing the last necessary DALI commands. No further DALI commands are then output, apart from the cyclic querying of the brightness of the master device. |
bOn | BOOL | A rising edge directly switches the controlled lamps to the maximum value of the master lamp. |
bOff | BOOL | A rising edge immediately switches off the controlled lamps. |
bToggle | BOOL | A rising edge immediately switches the controlled lamps off if the master lamp is not switched off and switches them on if the master lamp is off. |
bStart | BOOL | If a rising edge is applied to this input, the light is dimmed up or down respectively from the current value (the master device is decisive here) to nEndLevel. The time required for this is defined by tRampTime. The dimming procedure can be interrupted at any time by bOn, bOff or bToggle. |
nEndLevel | BYTE | Target value of the dimming procedure. (Valid value range:0 or MIN LEVEL ... MAX LEVEL) |
tRampTime | TIME | Ramp time, see bStart. (Preset value: 8 seconds) |
nOptions | DWORD | Reserved for future developments. |
nAddr | BYTE | Address of the single device for individual control or of the group for group control |
nMasterDevAddr | BYTE | The address of the master device (reference device) for group and common switching operations |
eAddrType | Short address, group address or broadcast | |
tCycleActualLevelMasterDev | TIME | Cycle time required to read the current actual value in the background (see ACTUAL DIM LEVEL). So that the dimming of the lamps is not disturbed, reading always has the lowest priority. If the value is set to 0, reading is prohibited. |
Inputs/outputs
VAR_IN_OUT
stCommandBuffer : ST_DALIV2CommandBuffer;
END_VAR
Name | Type | Description |
---|---|---|
stCommandBuffer | ST_DALIV2CommandBuffer | Reference to the internal structure for communication with FB_KL6811Communication (KL6811) or FB_KL6821Communication (KL6821). |
Outputs
VAR_OUTPUT
nActualLevelMasterDev : BYTE;
bBusy : BOOL;
bError : BOOL;
nErrorId : UDINT;
END_VAR
Name | Type | Description |
---|---|---|
nActualLevelMasterDev | BYTE | Current output value of the master device (always the respectively addressed device if eAddrType = eAddrTypeShort) |
bBusy | BOOL | When the function block is activated the output is set, and it remains active until execution of the command has been completed. |
bError | BOOL | 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 | UDINT | 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). |
Requirements
Development Environment | PLC library to include |
---|---|
TwinCAT from v3.1.4020.14 | Tc2_DALI from v3.4.3.0 |