Table of Contents

Class EtherCatMaster

Namespace
TwinSharp
Assembly
TwinSharp.dll

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

DeviceType

The device type of the EtherCAT master.

public ushort DeviceType { get; }

Property Value

ushort

MasterDevState

Can be used to read the current state of the EtherCAT master. Corresponds to the PLC FB: FB_EcGetMasterDevState

public ushort MasterDevState { get; }

Property Value

ushort

Name

The name of the EtherCAT master.

public string Name { get; }

Property Value

string

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

uint

SlaveCountConfigured

Count of number of slaves configured in TwinCAT.

public ushort SlaveCountConfigured { get; }

Property Value

ushort

Methods

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[]

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

ST_EcSlaveState[]

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

ST_EcSlaveConfigData[]

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.

MasterDevStateToString(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 MasterDevStateToString(ushort masterDevState)

Parameters

masterDevState ushort

Returns

string

ToString()

Returns a string representation of the EtherCAT master.

public override string ToString()

Returns

string