IoDrvEthercat_Diag.SetCommunicationState (METH) ¶ METHOD SetCommunicationState : DED.ERROR InOut: Scope Name Type Return SetCommunicationState DED.ERROR Input eRequestedState DED.DEVICE_TRANSITION_STATE
ETCMasterGlobals (GVL) ¶ InOut: Name Type Initial Comment g_pFirstMaster POINTER TO IoDrvEtherCAT CAA.gc_pNULL Pointer to the first master in the EtherCAT stack library. All master are linked with NextInstance and LastInstance.
ETCSlave (FB) ¶ FUNCTION_BLOCK ETCSlave EXTENDS ETCSlaveStack Implicit Instance of Slave ¶ An instance of the data type ETCSlave is generated for each EtherCAT slave inserted in the device tree. The name of the instance corresponds to the name of the slave in the device tree. The availability of the instance is indicated in the IEC Objects area of the EtherCAT I/O Mapping dialog of the slave. The slave instance is used in the application in order to query or change the state of the slave at runtime. InOut: Scope Name Type Comment Inherited from Input xSetOperational BOOL Rising edge: An attempt is made to switch to the ETC_SLAVE_OPERATIONAL mode. ETCSlaveStack Output wState ETC_SLAVE_STATE Current state of the slave: 0: ETC_SLAVE_BOOT 1: ETC_SLAVE_Init 2: ETC_SLAVE_PREOPERATIONAL 4: ETC_SLAVE_SAVEOPERATIONAL 8: ETC_SLAVE_OPERATIONAL Configuration was successfully completed. If errors occur during the configuration, the slave can fall back into an earlier state. ETCSlaveStack
ETC_Parameter (PARAMS) ¶ InOut: Scope Name Type Initial Comment Constant ETC_MAX_SLAVES WORD 1024 Not used anymore: left for compatibility Maximum number of slaves for the Ethercat stack MAX_ASYNC_MSG UINT 4 Maximum parallel asynchronous messages for ReadMemory/WriteMemory MAX_SDO_CHANNELS WORD 100 Number of parallel CoE SDO commands MAX_MAILBOX_CHANNELS WORD 100 Number of parallel requests for mailbox commands (VoE, FoE, SoE) MAX_STATUS_CYCLE_DELAY WORD 3 Number of bus cycles until a slave is marked as missing if no answer is received ETC_FOE_TIMEOUT WORD 10000 Timeout for FoE Download und Upload for request and slave response of each packet in milliseconds
EthercatMaster_GetVersion (FUN) ¶ FUNCTION EthercatMaster_GetVersion : DWORD returns the current version of the EtherCAT stack library InOut: Scope Name Type Return EthercatMaster_GetVersion DWORD
IoDrvEtherCAT (FB) ¶ FUNCTION_BLOCK IoDrvEtherCAT EXTENDS IoDrvBase IMPLEMENTS ICmpIoDrvParameter Implicit Master Instance ¶ The function block instance for the EtherCAT master. An instance type IoDrvEtherCAT is generated for each EtherCAT master that is inserted into the device tree. The name of the instance corresponds to the name of the master in the device tree. The availability of the instance is shown in the IEC Objects area of the EtherCAT I/O Mapping dialog box of the master Examples how to use the master instance ¶ Restarting the master with the xRestart variable: EtherCAT_Master.xRestart := xRestart; EtherCAT_Master(); Stopping communication on the bus with the xStop variable: EtherCAT_Master.xStopBus := xStop; EtherCAT_Master(); Calling the master for retrieving information about the download success of the configuration parameters: EtherCAT_Master(); xFinish := EtherCAT_Master.xConfigFinished; Chained List for Checking of All Slaves ¶ For the monitoring of individual slaves in the program the instance is called and the state is determined via wState. For simplification all masters and slaves can be determined by chained lists and all slaves can be checked by a simple WHILE loop. The properties NextInstance and LastInstance exist for both the master and the slave. These properties point to the next or previous slave. For the master there is an additional property, FirstSlave, which provides a pointer to the first slave. In accordance with the following example you can check all slaves: Example Following example code checks all slaves for operational mode PROGRAM PLC_PRG VAR pSlave : POINTER TO ETCSlave ; END_VAR pSlave := EtherCAT_Master.FirstSlave ; WHILE pSlave <> 0 DO pSlave ^(); IF pSlave ^. wState = ETC_SLAVE_STATE.ETC_SLAVE_OPERATIONAL THEN ; END_IF pSlave := pSlave ^. NextInstance ; END_WHILE Initially, the first slave is fetched to the master via EtherCAT_Master.FirstSlave. In the WHILE loop the respective instance is called and wState is thus determined. The status can then be checked. The pointer to the next slave is fetched with pSlave^.NextInstance. If the list is finished, the pointer is ZERO and the loop ends. InOut: Scope Name Type Initial Comment Input xRestart BOOL FALSE Rising edge: The master is restarted and all configuration parameters are reloaded. xStopBus BOOL FALSE Stop the bus when signal is true Output xConfigFinished BOOL TRUE: Transfer of all configuration parameters was completed with no errors. Communication is running on the bus. xDistributedClockInSync BOOL If distributed clocks are used, then the PLC is synchronized with the first EtherCAT slave with the DC option activated. The output is TRUE as soon as the synchronization is ended successfully. This signal can be used, for example, for activating SoftMotion function blocks when the PLC is in synchronous mode. Otherwise position jumps can occur. When starting the PLC, the output is FALSE and switches to TRUE after a few seconds. If the synchrony is lost due to an error, then the output is reset to FALSE. xError BOOL The output is TRUE when an error occurs when starting the EtherCAT stack, or communication with the slaves is interrupted because no more messages can be received (for example, due to a damaged cable). xSyncInWindow BOOL The output is TRUE when the Sync Window Monitoring option is activated and the synchronization of all slaves is within the Sync Window. Properties: AutoSetOperational BusLoad CheckLastPort ConfigRead DCClockReferenceTime DCInSyncWindow DCIntegralDivider DCPropFactor DCSyncToMaster DCSyncToMasterWithSysTime DCSyncToMasterWithSysTimeFrom2000 EnableTaskOutputMessage EnableTimeMeasurements FirstPortActive FirstSlave FrameAtTaskStart InstanceNumber LastError LastInstance LastMessage MasterState NbrSlavesFirstPort NbrSlavesSecondPort NextInstance NumberActiveSlaves OpenTimeout PdoOnlyInOperational SecondPortActive SplitFrame StartConfigWithLessDevice TaskSync WaitForPackets Methods: ClearStatistics EtherCAT_Task GetCurrentTimeInCycle GetStatistics DeviceIsInvisible Structure: AutoSetOperational (Property) BusLoad (Property) CheckLastPort (Property) ClearStatistics (Method) Config DeviceIsInvisible (Method) ConfigRead (Property) DCClockReferenceTime (Property) DCInSyncWindow (Property) DCIntegralDivider (Property) DCPropFactor (Property) DCSyncToMaster (Property) DCSyncToMasterWithSysTime (Property) DCSyncToMasterWithSysTimeFrom2000 (Property) EnableTaskOutputMessage (Property) EnableTimeMeasurements (Property) EtherCAT_Task (Method) FirstPortActive (Property) FirstSlave (Property) FrameAtTaskStart (Property) GetCurrentTimeInCycle (Method) GetStatistics (Method) InstanceNumber (Property) LastError (Property) LastInstance (Property) LastMessage (Property) MasterState (Property) NbrSlavesFirstPort (Property) NbrSlavesSecondPort (Property) NextInstance (Property) NumberActiveSlaves (Property) OpenTimeout (Property) PdoOnlyInOperational (Property) SecondPortActive (Property) SplitFrame (Property) StartConfigWithLessDevice (Property) TaskSync (Property) WaitForPackets (Property)
IoDrvEtherCAT.AutoSetOperational (PROP) ¶ PROPERTY AutoSetOperational : BOOL Sets the auto restart of slave behavior. If true then the master automatically retries to set all slaves in operational mode. If one or more slaves are added as optional devices and connected to the network then the master will start the new slaves, download all required parameters and then set the slaves to operational. If the network cable is disconnected from the PLC to first slave and reconnected then the master will work like xRestart. All data is reset and the master restarts completely.
IoDrvEtherCAT.BusLoad (PROP) ¶ PROPERTY BusLoad : USINT Returns the busload in percentage
IoDrvEtherCAT.CheckLastPort (PROP) ¶ PROPERTY CheckLastPort : BOOL Sets and returns the status of the port status check of the last slave If enabled and redundancy is not active then the port status register 16#110 of the last slave must show only port 0 active. Otherwise the in and out port of one device is wrong and it could happen that a wrong slave is used
IoDrvEtherCAT.NumberActiveSlaves (PROP) ¶ PROPERTY NumberActiveSlaves : UINT This property returns the number of actually connected slaves. StartConfigWithLessDevice := TRUE: the number of physical devices can be detected.