ApossC SDK  V01.15
Functions
SDK_Bussystem_EtherCat.mh File Reference

Declaration of the EtherCat functions. More...

Go to the source code of this file.

Functions

long sdkEtherCATMasterInitialize (void)
 Initialization of an EtherCAT master. More...
 
long sdkEtherCATMasterDoMapping (void)
 Mapping of EtherCAT Master IO Image. More...
 
long sdkEtherCATMasterStart (void)
 Start an EtherCAT Master. More...
 
long sdkEtherCATSetupDC (long slaveNo, long cycleTime_ms, long offset_us)
 Sets the DC cycle for an individual slave. More...
 

Detailed Description

Declaration of the EtherCat functions.

Revision
228

Definition in file SDK_Bussystem_EtherCat.mh.

Function Documentation

◆ sdkEtherCATMasterDoMapping()

long sdkEtherCATMasterDoMapping ( void  )

Mapping of EtherCAT Master IO Image.

Scans through the slave's PDO setup and generates mapping. The slaves PDO setup has to be done by SDO commands before this function is called. The slaves are SAFEOP state after this function.

Parameters
-
Returns
value: Number of slaves found on bus
value > 0 Process successful
value < 0 Error

Definition at line 46 of file SDK_Bussystem_EtherCat.mc.

47 {
48  print("map input/output");
49  return ECatMasterCommand(0x1000, 2); // Map Input and Output buffers (go to safeop)
50 }

◆ sdkEtherCATMasterInitialize()

long sdkEtherCATMasterInitialize ( void  )

Initialization of an EtherCAT master.

Initializes an EtherCAT master and scans the EtherCat bus for slaves. The slaves are now in PREOP state.

Parameters
-
Returns
value: Number of slaves found on bus
value > 0 Process successful
value = 0 Process is active
value < 0 Error

Definition at line 23 of file SDK_Bussystem_EtherCat.mc.

24 {
25  long slaveCount = 0;
26 
27  ECatMasterCommand(0x1000, 0); // disable Master
28  ECatMasterCommand(0x1000, 1); // start Master
29  ECatMasterInfo(0x1000, 0, slaveCount); // slave count
30 
31  print(" ECAT salve count: ",slaveCount);
32  return(slaveCount);
33 }

◆ sdkEtherCATMasterStart()

long sdkEtherCATMasterStart ( void  )

Start an EtherCAT Master.

If DC is configured, this function will block until the slaves are synchronized to the master. This can take some seconds. After that the system waits until all slaves are in the OP state.

Parameters
-
Returns
value: Always 1 in this function
value > 0 Process successful
value = 0 Process is active
value < 0 Error

Definition at line 86 of file SDK_Bussystem_EtherCat.mc.

87 {
88  long offsetValue;
89  long dcActive = 0;
90 
91  Delay(2); //Wait for ECatMasterInfo(0x1000, 12) value to be updated the first time
92 
93  ECatMasterInfo(0, 30, dcActive); //is DC configured?
94  print("DC Active: ", dcActive);
95 
96  if(dcActive)
97  {
98  print("wait for DC to lock");
99  offsetValue = 100001;
100  while(abs(offsetValue) > 1000)
101  {
102  ECatMasterInfo(0x1000, 12, offsetValue);
103  print("Offset time [ns]: ",offsetValue);
104  Delay(300);
105  }
106  }
107 
108  print("wait for op");
109  ECatMasterCommand(0x1000, 3); // request & wait OP state for all slaves
110 
111  return(1);
112 }

◆ sdkEtherCATSetupDC()

long sdkEtherCATSetupDC ( long  slaveNo,
long  cycleTime_ms,
long  offset_us 
)

Sets the DC cycle for an individual slave.

DC0 clock output will be configured with the selected cycle time and offset. Typically, Cycle time is 1ms and offset 0. This function has to be called after sdkEtherCATMasterDoMapping.

Parameters
slaveNoID of the EhterCAT slave
cycleTime_mscycletime in milliseconds
offset_usshift offset
Returns
value: Always 1 in this function
value > 0 Process successful
value = 0 Process is active
value < 0 Error

Definition at line 67 of file SDK_Bussystem_EtherCat.mc.

68 {
69  ECatMasterCommand(slaveNo, ( (cycleTime_ms<<8) + (offset_us<<16)));
70 
71  return(1);
72 }

Data Sheets | Released Software | Software Manuals | Hardware Manuals | Maxon Shop

Maxon Support Center