How to Perform EtherCAT Diagnostics for Beckhoff PLC Using Programs?
When using Beckhoff PLC, EtherCAT program diagnostics are crucial for on-site debugging and maintenance. Local I/O modules, AD/DA modules, other functional modules, as well as peripherals such as servos, valve islands, and barcode scanners connected via couplers, are all linked through EtherCAT. If any local modules fail to enter the OP (Operational) state (resulting in situations where the software PLC outputs but the hardware PLC doesn't respond), it's essential to write relevant programs to check if all modules are in the OP state. If any modules fail to enter the OP state, it's necessary to retrieve the module's name and error status, and summarize them into EtherCAT communication error flags. This allows on-site personnel to promptly address anomalies and facilitates quick recovery of equipment status.
1,Required Function Blocks and Functions:
1.1,FB_EcGetAllSlaveAddr
By obtaining the addresses of all slave stations and then employing relevant logic processing, the names of each station can be acquired and stored in an array. This process requires coordination with IOF_GetBoxNameByAddr.
1.2,IOF_GetBoxNameByAddr
Note: The "DEVICEID" pin needs to be associated with the DevID of the relevant EtherCAT master module.
1.3,FB_EcGetAllSlaveStates
SNetId: It needs to be obtained using F_CreateAmsNetId.
nIds: It needs to be defined as a T_AmsNetIdArr data type and linked to the AmsNetId of the InfoData of the EtherCAT master module.
PStateBuf: It is a structure data type.
PStateBuf: It is a structure data type containing two states: device state and connection state.
- Device state: The value is 8, indicating that the device is in OP (Operational) state.
- Connection state: The value is 2, indicating port error.
|
Description(Photo:https://infosys.beckhoff.com)
|
2.Programming
2.1 Obtaining NET_ID
2.2 Obtaining Slave Addresses
2.3 Getting Names of All Slave Stations
2.4 Getting Names and Status of Abnormal Slave Stations
3.Conclusion
For Beckhoff PLCs to retrieve offline slave stations via EtherCAT, it's necessary to write programs to achieve this functionality. While it may be slightly more complicated compared to Siemens PLCs using PN or Mitsubishi using CC-Link, once this functionality is implemented, it can typically be reused in subsequent projects. The provided programs are for reference purposes only.