Class EtherCatMaster
The EtherCatMaster class provides methods to interact with an EtherCAT master device. It allows for reading the current state, device type, and name of the master, as well as retrieving information about connected slaves, such as their configuration, state, and topology. Additionally, it can read unexpected state changes and convert device status to a string representation.
public class EtherCatMaster
- Inheritance
-
EtherCatMaster
- Inherited Members
Properties
AmsNetId
The AmsNetId of the EtherCAT master.
public AmsNetId AmsNetId { get; }
Property Value
- AmsNetId
DevState
Can be used to read the current state of the EtherCAT master. Corresponds to the PLC FB: FB_EcGetMasterDevState
public ushort DevState { get; }
Property Value
DeviceType
The device type of the EtherCAT master.
public ushort DeviceType { get; }
Property Value
FrameCount
Can be used to determine the number of EtherCAT frames configured in the master. Equivavalent to the function block FB_EcMasterFrameCount.
public uint FrameCount { get; }
Property Value
Name
The name of the EtherCAT master.
public string Name { get; }
Property Value
SlaveCount
Can be used to determine the number of slaves that are connected to the master. Corresponds to the PLC FB: FB_EcGetSlaveCount.
public uint SlaveCount { get; }
Property Value
SlaveCountConfigured
Count of number of slaves configured in TwinCAT.
public ushort SlaveCountConfigured { get; }
Property Value
State
Can be used to read the EtherCAT state of the master. Equivavalent to the function block FB_EcGetMasterState.
public EcDeviceState State { get; }
Property Value
Methods
DevStateToString(ushort)
Converts the device status of the EtherCAT master to a string. For masterDevState == 0 'OK' is returned, otherwise, 'Not OK – Link error', e.g. for masterDevState == 1. If several errors are pending, they are separated by hyphens.
public string DevStateToString(ushort masterDevState)
Parameters
masterDevStateushort
Returns
FrameStatisticClearCRC()
Can be used to delete the CRC error counters of all EtherCAT slaves. Equivavalent to the function block FB_EcMasterFrameStatisticClearCRC.
public void FrameStatisticClearCRC()
FrameStatisticClearFrames()
Can be used to delete the lost frame counters. Equivavalent to the function block FB_EcMasterFrameStatisticClearFrames.
public void FrameStatisticClearFrames()
GetAllSlaveAbnormalStateChanges()
Can be used to read the unexpected EtherCAT state changes of all the slaves connected to the master. It returns the number of unexpected state changes of all slaves as an array of UDINTs. EtherCAT state changes are unexpected if they were not requested by the EtherCAT master, e.g. if an EtherCAT slave spontaneously switches from OP state to SAFEOP state. Corresponds to the function block FB_EcGetAllSlaveAbnormalStateChanges.
public uint[] GetAllSlaveAbnormalStateChanges()
Returns
- uint[]
GetAllSlaveAddr()
Allows the addresses of all the slaves connected to the master to be read. Equivavalent to the FB_EcGetAllSlaveAddr function block.
public ushort[] GetAllSlaveAddr()
Returns
- ushort[]
GetAllSlaveStates()
Reads the EtherCAT status and the Link status of all the slaves connected to the master. Corresponds to the function block FB_EcGetAllSlaveStates.
public ST_EcSlaveState[] GetAllSlaveStates()
Returns
GetConfiguredSlaves()
Generates an array of all configured Slaves from the Master object directory. Corresponds to the function block FB_EcGetConfSlaves
public ST_EcSlaveConfigData[] GetConfiguredSlaves()
Returns
GetSlave(ushort)
Gets an EtherCAT slave to this master by its address.
public EtherCatSlave GetSlave(ushort slaveAdress)
Parameters
slaveAdressushortTypically starts at 1001.
Returns
GetSlaveTopologyInfo()
Can be used to determine topology information. Equivavalent to the function block FB_EcGetSlaveTopolgyInfo.
public ST_TopologyDataEx[] GetSlaveTopologyInfo()
Returns
- ST_TopologyDataEx[]
An array of structures of type ST_TopologyDataEx, which contains the topology data.
RequestState(EcDeviceState)
With this function the EtherCAT state of a master device can be requested. Equivavalent to the function block FB_EcReqMasterState.
public void RequestState(EcDeviceState state)
Parameters
stateEcDeviceState
ToString()
Returns a string representation of the EtherCAT master.
public override string ToString()