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

Committer:
pratima_hb
Date:
Thu Jan 30 16:11:22 2020 +0000
Revision:
0:ba190577ec8a
Child:
1:ee9b73e47960
Hello World program for EtherCAT Arduino Shield by Esmacat(EASE). EASE is a Shield with the form factor of Arduino UNO. It stacks onto base boards. Using this shield you could build an EtherCAT network without having to understand the details of it.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pratima_hb 0:ba190577ec8a 1
pratima_hb 0:ba190577ec8a 2 #include "mbed.h"
pratima_hb 0:ba190577ec8a 3 #include <EsmacatShield.h> //Include EsmacatShield Library
pratima_hb 0:ba190577ec8a 4
pratima_hb 0:ba190577ec8a 5
pratima_hb 0:ba190577ec8a 6 int counter;
pratima_hb 0:ba190577ec8a 7 int v[8]; //an array of integer is declared for reading the
pratima_hb 0:ba190577ec8a 8 //data packet of EtherCAT from EASE 8 registers
pratima_hb 0:ba190577ec8a 9 Serial pc(USBTX, USBRX); // Configuring the serial port to host PC
pratima_hb 0:ba190577ec8a 10
pratima_hb 0:ba190577ec8a 11 DigitalOut selectPin(D10); // D10 is used to drive chip enable low
pratima_hb 0:ba190577ec8a 12 SPI spi(D11, D12, D13); // mosi, miso, sclk
pratima_hb 0:ba190577ec8a 13
pratima_hb 0:ba190577ec8a 14
pratima_hb 0:ba190577ec8a 15 int main()
pratima_hb 0:ba190577ec8a 16 {
pratima_hb 0:ba190577ec8a 17
pratima_hb 0:ba190577ec8a 18 EsmacatShield slave(spi, selectPin); //Create an Esmacat slave object with defined
pratima_hb 0:ba190577ec8a 19 // spi and chip SelectPin
pratima_hb 0:ba190577ec8a 20
pratima_hb 0:ba190577ec8a 21 slave.setup_spi(); //Setup SPI for EASE
pratima_hb 0:ba190577ec8a 22
pratima_hb 0:ba190577ec8a 23 while(1)
pratima_hb 0:ba190577ec8a 24 {
pratima_hb 0:ba190577ec8a 25 slave.get_ecat_registers(v); //read all registers
pratima_hb 0:ba190577ec8a 26 slave.write_reg_value(0,counter++, true); //Write register data (register,value, led_on)
pratima_hb 0:ba190577ec8a 27 wait_us(1000000); //sleep for 1000 ms
pratima_hb 0:ba190577ec8a 28 slave.write_reg_value(0,counter++, false); //Write register data (register,value, led_on)
pratima_hb 0:ba190577ec8a 29 wait_us(1000000); //sleep for 1000 ms
pratima_hb 0:ba190577ec8a 30 pc.printf("Next Iteration \n");
pratima_hb 0:ba190577ec8a 31 for (int i=0;i<8;i++) //Print out read registers to host PC terminal
pratima_hb 0:ba190577ec8a 32 {
pratima_hb 0:ba190577ec8a 33 pc.printf("%d",i);
pratima_hb 0:ba190577ec8a 34 pc.printf("\t");
pratima_hb 0:ba190577ec8a 35 pc.printf("%d",v[i]);
pratima_hb 0:ba190577ec8a 36 pc.printf("\n");
pratima_hb 0:ba190577ec8a 37 }
pratima_hb 0:ba190577ec8a 38
pratima_hb 0:ba190577ec8a 39 }
pratima_hb 0:ba190577ec8a 40
pratima_hb 0:ba190577ec8a 41 }