FB_DALIVirtualCommunication

The individual DALI commands are temporarily stored in a command buffer within the Tc3_DALI library before further processing. The FB_DALIVirtualCommunication function block sequentially reads the DALI commands from this command buffer and forwards the DALI commands to the associated instances of FB_DALIVirtualControlGear.
One instance of the FB_DALIVirtualCommunication function block must be created for each DALI line that is to be simulated. This instance must be called in a separate, faster task. This faster communication task must have a higher priority than the task in which the function blocks for the individual DALI commands are called.
The utilization rate of the command buffer can be determined using the outputs of the function block. If you find that the command buffer is overflowing regularly, you should take the following steps:
- How heavily are the individual PLC tasks utilized? TwinCAT provides suitable analysis tools.
- Try reducing the cycle time of the task in which the FB_DALIVirtualCommunication function block is called. The value should not be greater than 6 ms. The optimum value is 2 ms or less.
- Check the cycle time of the PLC task in which the function blocks for the individual DALI commands are called. This value should not be greater than 10 ms. The optimum value is 8 ms or less.
- If possible avoid polling (regular reading) of values. Only read values when they are actually required.
- Distribute the individual simulated DALI devices evenly over several DALI lines. Since several DALI lines are processed simultaneously in each PLC cycle, this increases the data throughput.
Inputs
VAR_INPUT
bResetMaximumDemandCounter : BOOL;
bResetOverflowCounter : BOOL;
nOptions : DWORD := 0;
END_VAR
Name | Type | Description |
---|---|---|
bResetMaximumDemandCounter | BOOL | A positive edge resets the stored value for the maximum utilization of the command buffer, nBufferMaximumDemandMeter (0…100%). |
ResetOverflowCounter | BOOL | A positive edge resets the stored value for the number of overflows of the command buffer, nBufferOverflowCounter. |
nOptions | DWORD | Reserved for future extensions. |
Outputs
VAR_OUTPUT
bError : BOOL;
ipResultMessage : I_TcMessage;
bBusy : BOOL;
nBufferDemandMeter : BYTE;
nBufferMaximumDemandMeter : BYTE;
nBufferOverflowCounter : UINT;
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. |
nBufferDemandMeter | BYTE | Utilization rate of the command buffer (0…100%). |
nBufferMaximumDemandMeter | BYTE | Maximum utilization rate of the command buffer reached so far (0…100%). The counter can be reset via the input bResetMaximumDemandCounter. |
nBufferOverflowCounter | UINT | Number of command buffer overflows to date. The counter can be reset via the input bResetOverflowCounter. |
Requirements
Development environment | Required PLC library |
---|---|
TwinCAT from v3.1.4024.29 | Tc3_DALI from v3.11.0.0 |