FB_KL8524
Application
This function block is used to configure the KL8524, to read out the digital signals and to set the outputs/LEDs.
The function block must be called once per cycle.
The parameters are transferred to the terminal with a positive edge on bExecCfg.
The variable byDisCh switches the standard function of the LEDs off. The LEDs can now be switched independently of the digital input signal via the PLC with the variables byLEDGn or byLEDYe. Each LED can be changed individually here.
The respective output can be set to "TRUE" with byKBusOff in the event of a K-bus error (or PLC stopped) and switch position "auto". Bit 0..7 for the outputs 1..8. If the flag in byKBusOff is not set the output goes "FALSE" in the event of a K-bus error (or PLC stopped).
VAR_INPUT
bEn : BOOL;
bExecCfg : BOOL;
byDisCh : BYTE := 0;
byKBusOff : BYTE := 0;
byOutMode : BYTE;
byTurnOnDelayCh1 : BYTE;
byTurnOnDelayCh2 : BYTE;
byTurnOnDelayCh3 : BYTE;
byTurnOnDelayCh4 : BYTE;
byOut : BYTE;
byLEDGn : BYTE;
byLEDYe : BYTE;
dwOpt : DWORD := 0;
bEn: The function block is enabled by setting bEn to TRUE in the PLC program. With bEn = FALSE the execution of the function block will be stopped and all outputs reset.
bExecCfg: The configurations byDisCh, byKBusOff, byOutMode, byTurnOnDelayCh1, byTurnOnDelayCh2, byTurnOnDelayCh3 and byTurnOnDelayCh4 are written to the terminals. bBusy goes TRUE. Note that the inputs/outputs are not updated during this time.
byDisCh: Configuration: Disablement of the standard function of the LEDs. The LEDs can be set by the PLC. Bit 0 = LED 1, ... , bit 7 = LED 8. 255dec (FFhex) deactivates the standard function of all LEDs. These can then be set from the PLC via byLEDGn or byLEDYe.
byKBusOff: Configuration: Reaction of the outputs in the event of a K-bus error. The respective output is set with bit 0 = output 1,…, bit 7 =output 8 in the event of a K-bus error (or PLC stopped) provided that the switch is set to "auto". Note: 2 outputs are assigned to a channel and only one output may be activated per channel. If the value 255dec (FFhex) is transferred, for example, no output is set when the PLC stops.
byOutMode: Configuration: The outputs assigned to a channel can be set in 2 variants. Bit 0 = FALSE = channel 1 output mode 1, bit 0 = TRUE = channel 1 output mode 2,…, bit 3 = FALSE = channel 4 output mode 1, bit 3 = TRUE = channel 4 output mode 2.
Output mode 1: Output 1 is switched if the three-step switch is in position 1; output 2 is switched if the three-step switch is in position 2
Output mode 2: Output 1 is switched if the three-step switch is in position 1 or position 2; output 2 is switched if the three-step switch is in position 2, following a delay which can be set with byTurnOnDelayChx.
byTurnOnDelayCh1: Configuration: Switching time for channel 1 output mode 2. 1 bit = 10 ms -> with default 255dec, FFhex the second output is switched on after 2550 ms if the three-step switch is in position 2.
byTurnOnDelayCh2: Configuration: Switching time for channel 2 output mode 2. 1 bit = 10 ms -> with default 255dec, FFhex the second output is switched on after 2550 ms if the three-step switch is in position 2.
byTurnOnDelayCh3: Configuration: Switching time for channel 3 output mode 2. 1 bit = 10 ms -> with default 255dec, FFhex the second output is switched on after 2550 ms if the three-step switch is in position 2.
byTurnOnDelayCh4: Configuration: Switching time for channel 4 output mode 2. 1 bit = 10 ms -> with default 255dec, FFhex the second output is switched on after 2550 ms if the three-step switch is in position 2.
byOut: Bit 0 = TRUE, ... , Bit 7 = TRUE sets the respective output, provided the switch is set to "auto". All outputs are set with 255dec (FFhex). The FB_KL85xx8BitToByte function block is available for preparing the signals for the graphic programming languages.
byLEDGn: Bit 0 = TRUE,..., bit 7 = TRUE sets the green LEDs, provided that the standard function of the LEDs has been disabled with byDisCh. All green LEDs are set with 255dec (FFhex). The FB_KL85xx8BitToByte function block is available for preparing the signals for the graphic programming languages.
byLEDYe: Bit 0 = TRUE,..., bit 7 = TRUE sets the yellow LEDs, provided that the standard function of the LEDs has been disabled with byDisCh. All yellow LEDs are set with 255dec (FFhex). The FB_KL85xx8BitToByte function block is available for preparing the signals for the graphic programming languages.
dwOpt: For future options.
VAR_OUTPUT
bBusy : BOOL;
byStatSwiAuto : BYTE;
byStatSwi : BYTE;
byStatOut : BYTE;
bErr : BOOL;
udiErrID : UDINT;
bBusy: bBusy is TRUE as long as the configuration is being written (start with bExecCfg). Note that the inputs are not updated during this time.
byStatSwiAuto: Status of the "auto" switch. Bit 0 = channel 1, ... , bit 3 = channel 4. The FB_KL85xxByteTo8Bit function block is available for preparing the signals for the graphic programming languages.
byStatSwi: Status of the three-step switch. Bit 0 = channel 1 position 1, bit 1 = channel 1 position 2 ... , bit 7 = channel 4 position 2. The FB_KL85xxByteTo8Bit function block is available for preparing the signals for the graphic programming languages.
byStatOut: Status of the digital output signals. Bit 0 = channel 1 output 1, bit 1 = channel 1 output 2, ... , bit 7 = channel 4 output 2. The FB_KL85xxByteTo8Bit function block is available for preparing the signals for the graphic programming languages.
bErr: The bError output goes TRUE as soon as an error occurs. This error is described via the udiErrID variable.
udiErrID: In the event of an error the output issues an error code (see error codes). bError goes TRUE at the same time.
VAR_IN_OUT
stInData : ST_KL8524InData;
stOutData : ST_KL8524OutData;
stInData: Process image of the inputs (see ST_KL8524InData).
stOutData: Process image of the outputs (see ST_KL8524OutData).