FB_DALI102Dimmer1Switch

FB_DALI102Dimmer1Switch 1:

The function block FB_DALI102Dimmer1Switch provides the main functions for implementing a push-dimmer.

Operation

The input bSwitch is intended for linking with a push button. Pressing the button briefly switches the DALI control gears on or off. Pressing the button longer causes the output value of the DALI control gears to dim cyclically between the minimum and maximum values (see below).

The output value of the DALI control gears can be changed by positive edges at the inputs bRecallMinLevel, bRecallMaxLevel, bOn, bOff, bToogle, bGoToScene and bSetLevel (see below).

The function block offers the option to address a single DALI control gear via a short address, several DALI control gears via a group address or all DALI control gears of a DALI line via a broadcast.

The variables minLevel, maxLevel, fadeRate, fadeTime, extendedFadeTimeBase and extendedFadeTimeMultiplier are parameters that are stored separately in each DALI control gear. These variables can be changed in the DALI control gears via the properties and via the input bInitialize.

If DALI commands are sent for setting the output values (bBusy = TRUE), further positive edges at the inputs are ignored. New commands can be executed as soon as bBusy has been reset again.

Operation via the input bSwitch

A short signal at the input bSwitch switches the DALI control gears on or off, depending on the state of the reference DALI control gear. If the signal is present for longer, the system switches to dimmer mode and the output values of the DALI control gears move cyclically between minLevel and maxLevel until bSwitch is FALSE again. If the output value of the reference DALI control gear reaches the limit value minLevel or maxLevel, the function block changes its dimming direction.

If bSwitch is set to FALSE again, the current output values of the DALI control gears remain unchanged. A new pulse at the input bSwitch sets the output values to 0. If the input bSwitch is briefly deactivated in dimmer mode, the function block changes its dimming direction.

The speed at which the output values of the DALI control gears change in dimmer mode is determined by the variable fadeRate in the individual DALI control gears. The speed at which the DALI control gears are switched on again is specified by the variables fadeTime, extendedFadeTimeBase, and extendedFadeTimeMultiplier.

Operation via the inputs bOn, bOff, bGoToScene and bSetLevel

The output value of the DALI control gears can be changed immediately by positive edges at the inputs bOn, bOff, bGoToScene, and bSetLevel.

For bOn, bGoToScene and bSetLevel, the speed at which the specified value is to be reached is specified by the variables fadeTime, extendedFadeTimeBase and extendedFadeTimeMultiplier. bOff switches the DALI control gears off immediately.

Memory mode

When switching on, a distinction must be made as to whether memory mode (see nOptions) is active or not. If memory mode is active, the last set value is adopted as the output value for the DALI control gears when the device is switched on. If memory mode is not active, the output value from the parameter nLevelMemoryMode is used for the DALI control gears. It is irrelevant whether the DALI control gears are switched via the input bOn, bToggle or bSwitch.

DALI short address reference device (nReferenceDeviceAddress)

If several DALI control gears are addressed, the current output value of the reference DALI control gear is read out via nReferenceDeviceAddress. The DALI control gears are set to the desired value, depending on the state of the reference DALI control gear.

The parameter nReferenceDeviceAddress is also used if the output value of the reference DALI control gear is read out cyclically in the background (tCycleActualLevel > 0 sec).

No reference DALI control gear is required if a single DALI control gear is to be controlled with the function block (eAddressType = E_DALIAddressType.Short). The output value of the individual DALI control gear is determined via nAddress. The parameter nReferenceDeviceAddress has no meaning in this case.

If nReferenceDeviceAddress is used, it must always contain the short address of a DALI control gear, which is also contained in the addressed DALI group. For a broadcast a DALI control gear with the corresponding short address must be present on the DALI line.

FB_DALI102Dimmer1Switch 2: Inputs

VAR_INPUT
  bInitialize              : BOOL := FALSE;
  nAddress                 : BYTE;
  eAddressType             : E_DALIAddressType := E_DALIAddressType.Short;
  bSwitch                  : BOOL;
  bRecallMaxLevel          : BOOL;
  bRecallMinLevel          : BOOL;
  bOn                      : BOOL;
  bOff                     : BOOL;
  bToggle                  : BOOL;
  bGoToScene               : BOOL;
  nScene                   : BYTE;
  bSetLevel                : BOOL;
  nLevel                   : BYTE := 254;
  nLevelMemoryMode         : BYTE := 254;
  nReferenceDeviceAddress  : BYTE;
  tCycleActualLevel        : TIME := T#30S;
  nOptions                 : DWORD := 0;
END_VAR

Name

Type

Description

bInitialize

BOOL

A positive edge at this input writes the values of all properties to the DALI control gears. Writing the properties to the DALI control gears is only possible if no other functions are being executed by the function block (bBusy = FALSE).

nAddress

BYTE

Address of a DALI control gear or a DALI group.

eAddressType

E_DALIAddressType

Defines whether the input nAddress contains a short address (0…63) or a group address (0…15). The input nAddress has no meaning if a broadcast or a broadcast to unaddressed devices (BroadcastUnaddr) has been selected.

bSwitch

BOOL

A short signal at these inputs switches the DALI control gears on or off. If the signal is present for a longer period, the system switches to dimmer mode and the output values of the DALI control gears move to minLevel or maxLevel.

bRecallMaxLevel

BOOL

A positive edge at this input sets the DALI control gears to maxLevel

bRecallMinLevel

BOOL

A positive edge at this input sets the DALI control gears to minLevel.

bOn

BOOL

If memory mode is active (see nOptions), a positive edge at this input sets the DALI control gears to their output value before the last switching off. If memory mode is not active, the DALI control gears are set to nLevelMemoryMode.

bOff

BOOL

The DALI control gears are switched off via a positive edge at this input. The previous output value is stored internally to be used for switching on if memory mode is active (see nOptions).

bToggle

BOOL

Each positive edge at this input causes the DALI control gears to switch between off and their output value before the last switch-off (memory mode active) or nLevelMemoryMode (memory mode not active).

bGoToScene

BOOL

A positive edge at this input sets the output value of the DALI control gears to the value stored in nScene.

nScene

BYTE

Scene (0...15) to be called up in the DALI control gears by bGoToScene. Each DALI control gear has its own output value for each scene.

bSetLevel

BOOL

A positive edge at this input sets the output value of the DALI control gears to the value specified by nLevel.

nLevel

BYTE

Output value (0, minLevel...maxLevel, 255) to be called up in the DALI control gears by bSetLevel. The output value remains unchanged if the value is 255 (MASK).

nLevelMemoryMode

BYTE

Output value (minLevel...maxLevel) for switching on the DALI control gears when memory mode is not active.

nReferenceDeviceAddress

BYTE

Short address (0...63) of the reference DALI control gear for group call and broadcast. This parameter is not evaluated if eAddressType = E_DALIAddressType.Short. In this case, the reference DALI control gear is read out via nAddress.

tCycleActualLevel

TIME

Cycle time with which the current output value of the reference DALI control gear is read out in the background. Set the cycle time such that as few DALI commands as possible are sent. If the time is set to 0 sec, no reading takes place.

nOptions

DWORD

Options that affect the behavior of the function block. The individual constants must be linked with OR operators.

Constant

Description

Tc3_DALI.GVL.cMemoryMode

Activates memory mode.

FB_DALI102Dimmer1Switch 3: Outputs

VAR_OUTPUT
  bError               : BOOL;
  ipResultMessage      : I_TcMessage;
  bBusy                : BOOL;
  bInitializing        : BOOL;
  nActualLevel         : BYTE;
END_VAR

Name

Type

Description

bError

BOOL

This output is switched to TRUE if an error occurs during the execution. Further information about the error can be queried via the variable ipResultMessage. The output is set to FALSE again as soon as bBusy switches to TRUE.

ipResultMessage

I_TcMessage

Interface pointer (see error evaluation) that can be used to obtain detailed information about the processing of the function block (see runtime messages). The interface pointer is valid after bBusy has changed from TRUE to FALSE.

bBusy

BOOL

The output is set as soon as execution of the DALI commands has commenced. It remains active until all DALI commands have been processed.

bInitializing

BOOL

The output is set as soon as the initialization of the DALI control gears has been started, and remains active until all DALI commands have been executed.

nActualLevel

BYTE

Current output value (0, minLevel...maxLevel, 255) of the reference DALI control gear that is addressed via nReferenceDeviceAddress. If eAddressType = E_DALIAddressType.Short, the reference DALI control gear is read out via nAddress. A value of 255 (MASK) indicates that an error occurred while reading the output value from the reference DALI control gear. The cause could be, for example, a technical defect or that the DALI control gear is in the start-up phase. In this case bError is not set to TRUE.

FB_DALI102Dimmer1Switch 4: Properties

All parameters that are written to the DALI control device via bInitialize are available as properties.

Name

Type

Access

Initial value

Description

nMaxLevel

BYTE

Get, Set

254

See variable maxLevel.

nMinLevel

BYTE

Get, Set

126

See variable minLevel.

eFadeRate

E_DALIFadeRate

Get, Set

N045StepsPerSec

See variable fadeRate.

eFadeTime

E_DALIFadeTime

Get, Set

Disabled

See variable fadeTime.

eExtendedFadeTimeBase

E_DALIExtendedFadeTimeBase

Get, Set

Base01

See variable extendedFadeTimeBase.

eExtendedFadeTimeMultiplier

E_DALIExtendedFadeTimeMultiplier

Get, Set

Disabled

See variable extendedFadeTimeMultiplier.

ipDALICommunication

I_DALICommunication

Get, Set

0

Interface pointer to the communication block (see Transfer of the reference to the communication block).

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.15

Tc3_DALI from v3.6.2.0