Build an EtherCAT Slave

Dependencies:   EsmacatShield

Quick Build EtherCAT Slave

Esmacat is an easy yet powerful EtherCAT solution for robot mechatronics developed by Harmonic Bionics. It provides a full EtherCAT hardware and software solution for Master and Slave devices which allows developers to set up and run an EtherCAT application within minutes. It also supports Power-over-EtherCAT (POE) technology which allows high-speed communication and logic-power supply over a single Ethernet cable simplifying the cabling and wiring needs of the system significantly.

EtherCAT Arduino Shield by Esmacat (EASE) is a shield which can be used to build a Slave device. It stacks onto Mbed boards with form factor of Arduino UNO. The Mbed Base board communicates with EASE over SPI. EASE communicates with the Master over EtherCAT. Multiple EASE boards can be connected with Ethernet cables in a daisy-chain topology.

Product Page

Buy this Product

https://os.mbed.com/media/uploads/pratima_hb/ethercat.png

https://os.mbed.com/media/uploads/pratima_hb/ease_multiple.png

Information about the hardware needs and setup is provided in the link below. https://os.mbed.com/users/pratima_hb/code/EASE_Example/wiki/Hardware-Setup

Information about the structure of the system and it's software is provided in the link below. https://os.mbed.com/users/pratima_hb/code/EASE_Example/wiki/Software

Revision:
0:ba190577ec8a
Child:
1:ee9b73e47960
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 30 16:11:22 2020 +0000
@@ -0,0 +1,41 @@
+
+#include "mbed.h"
+#include <EsmacatShield.h> //Include EsmacatShield Library
+
+
+int counter;
+int v[8];                  //an array of integer is declared for reading the 
+                           //data packet of EtherCAT from EASE 8 registers
+Serial pc(USBTX, USBRX);   // Configuring the serial port to host PC
+
+DigitalOut selectPin(D10); // D10 is used to drive chip enable low
+SPI spi(D11, D12, D13);    // mosi, miso, sclk
+
+
+int main() 
+{
+
+    EsmacatShield slave(spi, selectPin);  //Create an Esmacat slave object with defined
+                                          // spi and chip SelectPin
+    
+    slave.setup_spi();            //Setup SPI for EASE
+    
+    while(1)
+    {
+      slave.get_ecat_registers(v);  //read all registers
+      slave.write_reg_value(0,counter++, true);   //Write register data (register,value, led_on)
+      wait_us(1000000);                      //sleep for 1000 ms
+      slave.write_reg_value(0,counter++, false);   //Write register data (register,value, led_on)
+      wait_us(1000000);                      //sleep for 1000 ms
+      pc.printf("Next Iteration \n");
+      for (int i=0;i<8;i++)         //Print out read registers to host PC terminal
+      {
+        pc.printf("%d",i);
+        pc.printf("\t");
+        pc.printf("%d",v[i]);
+        pc.printf("\n");
+      }
+        
+    }
+
+}