FB_KL6811Communication
The function blocks for the DALI commands do not directly access the process image of the KL6811, but store the individual DALI commands in three different buffers. The function block FB_KL6811Communication sequentially reads the DALI commands from these three buffers and forwards the DALI commands to the KL6811. This prevents multiple function blocks accessing the KL6811 process image simultaneously. Each of these three buffers is processed with a different priority (high, medium or low). The parameter eCommandPriority, which is available for most function blocks, can be used to influence the priority with which the respective DALI command is processed by the function block FB_KL6811Communication.
All buffers in which the DALI commands are stored are associated with a variable of type ST_DALIV2CommandBuffer. For each KL6811 there is one instance of the function block FB_KL6811Communication and one variable of type ST_DALIV2CommandBuffer. If possible, the function block FB_KL6811Communication should be called in a separate, faster task.
The extent to which the buffers are utilized can be determined from the outputs of the function block. Three arrays are output for this in which each element (0, 1 or 2) represents one of the three buffers (high, middle or low). If you detect regular overflow for one of the three buffers, you should consider the following:
- How heavily are the individual PLC tasks utilized? The TwinCAT System Manager offers various appropriate utilities for the analysis.
- Try to reduce the cycle time of the task in which the function block FB_KL6811Communication is called. The value should not exceed 6 ms. Ideally it should be 2 ms.
- Check the cycle time of the PLC task in which the function blocks for the individual DALI commands are called. These values should be between 10 ms and 60 ms.
- If possible avoid polling (regular reading) of values. Only read values when they are actually required.
- Distribute the individual control gears evenly over several DALI lines. Overall data throughput is increased by the fact that several DALI lines are processed simultaneously during each PLC cycle.
Inputs
VAR_INPUT
bResetMaximumDemandCounter : BOOL;
bResetOverflowCounter : BOOL;
END_VAR
Name | Type | Description |
---|---|---|
bResetMaximumDemandCounter | BOOL | A positive edge resets the stored value of the maximum command buffer utilization, arrBufferMaximumDemandMeter (0 - 100 %, see VAR_OUTPUT). |
bResetOverflowCounter | BOOL | A positive edge resets the stored value of the number of command buffer overflows, arrBufferOverflowCounter (see VAR_OUTPUT). |
Inputs/outputs
VAR_IN_OUT
stDALIInData : ST_KL6811InData;
stDALIOutData : ST_KL6811OutData;
stCommandBuffer : ST_DALIV2CommandBuffer;
END_VAR
Name | Type | Description |
---|---|---|
stDALIInData | Structure in the input process image of the KL6811. It is used for communication from the KL6811 to the PLC. | |
stDALIOutData | Structure in the output process image of the KL6811. It is used for communication from the PLC to the KL6811. | |
stCommandBuffer | ST_DALIV2CommandBuffer | Reference to the internal structure for communication with FB_KL6821Communication (KL6821). |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrorId : BYTE;
arrBufferDemandMeter : ARRAY [0..2] OF BYTE;
arrBufferMaximumDemandMeter : ARRAY [0..2] OF BYTE;
arrBufferOverflowCounter : ARRAY [0..2] OF UINT;
bLineIsBusy : BOOL;
bLineIsInitialized : BOOL;
END_VAR
Name | Type | Description |
---|---|---|
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). |
arrBufferDemandMeter | ARRAY | Demand of the respective buffer (0 - 100 %) |
arrBufferMaximumDemandMeter | ARRAY | Previous maximum demand of the respective buffer (0 - 100 %) |
arrBufferOverflowCounter | ARRAY | Number of buffer overflows so far |
bLineIsBusy | BOOL | This output is set as long as the function block FB_KL6811Communication is active. |
bLineIsInitialized | BOOL | If the function block is called up for the first time (e.g. when starting the controller), initialization is carried out. No DALI commands can be processed during this time. |
Requirements
Development Environment | PLC library to include |
---|---|
TwinCAT from v3.1.4022.4 | Tc2_DALI from v3.6.2.0 |