FB_SMISlaveIdCompare
The function block FB_SMISlaveIdCompare compares a specified slave ID (32-bit key ID) with the slave ID (32-bit key ID) defined on the motor side for one or more drives. The command can also be sent also to several SMI slaves.
The result of the query is forwarded by four outputs. Each of these outputs can assume three states:
- The condition applies to at least one drive.
- The condition does not apply to any drive.
- The condition could not be determined.
Some examples of this are explained further below.
Inputs
VAR_INPUT
bStart : BOOL;
dwAddr : DWORD := 0;
eAddrType : E_SMIAddrType := eSMIAddrTypeAddress;
dwAddrOption : DWORD := 0;
eCommandPriority : E_SMICommandPriority := eSMICommandPriorityMiddle;
dwSlaveId : 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. |
dwAddr | DWORD | Manufacturer code (0-15), address of a device (0-15), bit field (16 bits) for group addressing or slave ID (32-bit key ID). This input has no meaning if a broadcast is sent. |
eAddrType | Defines whether the input dwAddr is to be evaluated as a manufacturer code, the address of a device, for group addressing or as a slave ID. | |
dwAddrOption | DWORD | If the SMI device is addressed by slave ID (eAddrType = eSMIAddrTypeSlaveId), then the manufacturer code must be specified via this input. |
eCommandPriority | Priority (high, medium or low) with which the command is processed by the PLC library. | |
dwSlaveId | DWORD | The Slave ID with which the Slave ID on the motor side is compared. |
Inputs/outputs
VAR_IN_OUT
stCommandBuffer : ST_SMICommandBuffer;
END_VAR
Name | Type | Description |
---|---|---|
stCommandBuffer | Reference to the structure for communication (buffer) with the function block FB_KL6831KL6841Communication() |
Outputs
VAR_INPUT
bBusy : BOOL;
bError : BOOL;
udiErrorId : UDINT;
eResSlaveAddrET0AndSlaveIdLTSerachId : E_SMICompResSlaveAddrET0AndSlaveIdLTSearchId;
eResSlaveAddrET0AndSlaveIdGTSerachId : E_SMICompResSlaveAddrET0AndSlaveIdGTSearchId;
eResSlaveAddrET0AndSlaveIdETSerachId : E_SMICompResSlaveAddrET0AndSlaveIdETSearchId;
eResSlaveAddrNE0 : E_SMICompResSlaveAddrNE0;
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). |
eResSlaveAddrET0AndSlaveIdLTSerachId | At least one motor / no motor has the address 0 and the slave ID is smaller than the slave ID sought (dwSlave-Id) / the value is undefined. | |
eResSlaveAddrET0AndSlaveIdGTSerachId | At least one motor / no motor has the address 0 and the slave ID is larger than the slave ID sought (dwSlave-Id) / the value is undefined. | |
eResSlaveAddrET0AndSlaveIdETSerachId | At least one motor / no motor has the address 0 and the slave ID is also the same as the slave ID sought (dwSlave-Id) / the value is undefined. | |
eResSlaveAddrNE0 | At least one motor / no motor has an address unequal 0 / the value is undefined. |
Examples
The following tables show the results of the function block with different output situations. In all cases two SMI devices are connected to an SMI terminal and both addresses are greater than 0.
The slave ID (dwSlaveId) sought lies between the slave IDs of the two drives:
Outputs | Meaning |
---|---|
eResSlaveAddrET0AndSlaveIdLTSerachId = eSMIDiagResAtLeastOneSlaveAddrET0AndSlaveIdLTSearchId | At least one motor has the slave address equal 0 and the slave ID is smaller than the slave ID sought. |
eResSlaveAddrET0AndSlaveIdGTSerachId = eSMIDiagResAtLeastOneSlaveAddrET0AndSlaveIdGTSearchId | At least one motor has the slave address equal 0 and the slave ID is greater than the slave ID sought. |
eResSlaveAddrET0AndSlaveIdETSerachId = eSMIDiagResNoSlaveAddrET0AndSlaveIdETSearchId | No motor has the slave address equal 0 and the slave ID is the same as the slave ID sought. |
eResSlaveAddrNE0 = eSMIDiagResNoSlaveAddrNE0 | No motor has the slave address unequal 0. |
The slave ID (dwSlaveId) sought is greater than the slave IDs of the two drives:
Outputs | Meaning |
---|---|
eResSlaveAddrET0AndSlaveIdLTSerachId = eSMIDiagResAtLeastOneSlaveAddrET0AndSlaveIdLTSearchId | At least one motor has the slave address equal 0 and the slave ID is smaller than the slave ID sought. |
eResSlaveAddrET0AndSlaveIdGTSerachId = eSMIDiagResNoSlaveAddrET0AndSlaveIdGTSearchId | No motor has the slave address equal 0 and the slave ID is greater than the slave ID sought. |
eResSlaveAddrET0AndSlaveIdETSerachId = eSMIDiagResNoSlaveAddrET0AndSlaveIdLTSearchId | No motor has the slave address equal 0 and the slave ID is smaller than the slave ID sought. |
eResSlaveAddrNE0 = eSMIDiagResNoSlaveAddrNE0 | No motor has the slave address unequal 0. |
The slave ID (dwSlaveId) sought is smaller than the slave IDs of the two drives:
Outputs | Meaning |
---|---|
eResSlaveAddrET0AndSlaveIdLTSerachId = eSMIDiagResNoSlaveAddrET0AndSlaveIdLTSearchId | No motor has the slave address equal 0 and the slave ID is smaller than the slave ID sought. |
eResSlaveAddrET0AndSlaveIdGTSerachId = eSMIDiagResAtLeastOneSlaveAddrET0AndSlaveIdGTSearchId | At least one motor has the slave address equal 0 and the slave ID is greater than the slave ID sought. |
eResSlaveAddrET0AndSlaveIdETSerachId = eSMIDiagResNoSlaveAddrET0AndSlaveIdETSearchId | No motor has the slave address equal 0 and the slave ID is the same as the slave ID sought. |
eResSlaveAddrNE0 = eSMIDiagResNoSlaveAddrNE0 | No motor has the slave address unequal 0. |
The slave ID (dwSlaveId) sought is the same as the slave ID of a drive:
Outputs | Meaning |
---|---|
eResSlaveAddrET0AndSlaveIdLTSerachId = eSMIDiagResNoSlaveAddrET0AndSlaveIdLTSearchId | No motor has the slave address equal 0 and the slave ID is smaller than the slave ID sought. |
eResSlaveAddrET0AndSlaveIdGTSerachId = eSMIDiagResAtLeastOneSlaveAddrET0AndSlaveIdGTSearchId | At least one motor has the slave address equal 0 and the slave ID is greater than the slave ID sought. |
eResSlaveAddrET0AndSlaveIdETSerachId = eSMIDiagResAtLeastOneSlaveAddrET0AndSlaveIdETSearchId | At least one motor has the slave address equal 0 and the slave ID is the same as the slave ID sought. |
eResSlaveAddrNE0 = eSMIDiagResNoSlaveAddrNE0 | No motor has the slave address unequal 0. |
Requirements
Development Environment | PLC library to include |
---|---|
TwinCAT from v3.1.4020.14 | Tc2_SMI from 3.3.5.0 |