SmartPLC DataLine with EtherCAT slave interface
161
>
Example: Set the operating mode of AS-i master 2 to "Projection mode"
42896
Task:
Set the operating mode of AS-i master 2 to "Projection mode"
Solution:
Execute command 0x0005
Preparations
►
Create data structure for values to be transferred to the device (arTxData):
Word
Value
Description
1
UID
User ID (value between 0 and 65535 to mark the request)
2
0x0005
Command number
→
Command 0x0005 – Change the operating mode of the AS-i master
3
0x0001
0x01 = projection mode
►
Create empty data structure for status message of the command processing (bRxStatus)
Byte
Value
Description
1
blank
Status message of command processing (index 0x02)
►
Create empty data structure for values of the command response (arRxData):
Word
Value
Description
1
blank
UID value between 0 and 65535 to mark the request
2
blank
reflected command number
3
blank
MSB = reserved, LSB = command status
4
blank
Command error code
1 Send command request to the device
►
Execute function block FB_EcCoESdoWrite with the following input values:
Input
Value
Description
nNetId
depends on the project
AMS network ID of the EtherCAT master
nSlaveAddr
depends on the project
EtherCAT address of the device
nSubIndex
0x01
subindex of the fieldbus object (command request)
nIndex
0x2012
Index of the fieldbus object (AS-i Master 2 command)
pSrcBuf
ADR(arTxData)
address of the buffer storage with the data to be transmitted
cbBufLen
SIZEOF(arTxData)
Number of words to be transferred
2 Evaluate command status
►
Execute function block FB_EcCoESdoRead with the following input values:
Input
Value
Description
nNetId
depends on the project
AMS network ID of the EtherCAT master
nSlaveAddr
depends on the project
EtherCAT address of the device
nSubIndex
0x02
subindex of the fieldbus object (status message)
nIndex
0x2012
Index of the fieldbus object (AS-i Master 2 command)
pSrcBuf
ADR(bRxStatus)
Buffer storage for data to be transmitted
cbBufLen
SIZEOF(bRxStatus)
Number of words to be transferred