FB_SMIAddressing

FB_SMIAddressing 1:

This function block addresses the connected SMI devices according to the random principle. Which SMI device is assigned to which address is beyond the control of the user. The addresses are assigned in descending order, starting with the address specified by the parameter byHighestAddress.

Applying a positive edge to the input bStart starts the function block, and the output bBusy goes TRUE. The function block now independently addresses all SMI devices. The output variable arrAddressedDevices provides information which SMI devices have already received an address. Once all SMI devices have been addressed, the output bBusy goes FALSE again. Addressing can be aborted through a positive edge at input bCancel. Processing this function block can take several minutes, depending on how many SMI devices are connected.

FB_SMIAddressing 2: Inputs

VAR_INPUT
  bStart           : BOOL;
  bCancel          : BOOL;
  byHighestAddress : BYTE := 15;
  dwOptions        : DWORD := 0;
END_VAR

Name

Type

Description

bStart

BOOL

The function block is activated and the command is sent by applying a positive edge to this input.

bCancel

BOOL

The function block is deactivated and the search is aborted on applying a positive edge to this input.

byHighestAddress

BYTE

Address from which the SMI devices are addressed in descending order (0-15).

dwOptions

DWORD

Reserved for future extensions

FB_SMIAddressing 3: Inputs/outputs

VAR_IN_OUT
  stCommandBuffer : ST_SMICommandBuffer;
END_VAR

Name

Type

Description

stCommandBuffer

ST_SMICommandBuffer

Reference to the structure for communication (buffer) with the function block FB_KL6831KL6841Communication()

FB_SMIAddressing 4: Outputs

VAR_OUTPUT
  bBusy                  : BOOL;
  bError                 : BOOL;
  udiErrorId             : UDINT;
  dwCurrentSearchSlaveId : DWORD;
  byCurrentManufacturer  : BYTE;
  byCurrentSlaveAddr     : BYTE;
  arrAddressedDevices    : ARRAY [0..15] OF BOOL;
END_VAR

Name

Type

Description

bBusy

BOOL

This output is set as soon as the function block processes a command and remains active until the command has been processed.

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 udiErrorId. The output is reset to FALSE by the reactivation of the function block via the input bStart.

udiErrorId

UDINT

Contains the command-specific error code of the most recently executed command. It is reset to 0 by the reactivation of the function block via the input bStart (see error codes).

dwCurrentSearchSlaveId

DWORD

Current slave ID used in the search algorithm.

byCurrentManufacturer

BYTE

Current manufacturer code used in the search algorithm.

byCurrentSlaveAddr

BYTE

Current address used in the search algorithm.

arrAddressedDevices

ARRAY OF BOOL

If an address is assigned to an SMI device, then the corresponding element in the array is set to TRUE.

Requirements

Development Environment

PLC library to include

TwinCAT from v3.1.4020.14

Tc2_SMI from 3.3.5.0