MCUXpresso SDK Documentation

ecat_eoe#

Overview#

This example demonstrates how to use EtherCAT EoE based on digital_io example.

Note that the demo CAN NOT be built directly. Please see the “Prepare the Demo” section for more details.

For more information on digital_io example, please refer to ‘…\ecat_examples\digital_io’

Running the demo#

When the example is running, the serial port will output:

Start the SSC EoE example...

Hardware init success...

EoE interface init success...

***********************************************************
HTTP Server example
***********************************************************
IPv4 Address     : 192.168.1.66

IPv4 Subnet mask : 255.255.255.0

IPv4 Gateway     : 192.168.1.102

mDNS hostname    : lwip-eoe
***********************************************************

NOTE: To modify the html of http server, please refer to lwip_examples/lwip_httpsrv example.

TwinCAT Setup#

To demonstrate this EoE example, TwinCAT is used as the EtherCAT MainDevice.

Supported Boards#

MIMXRT1180-EVK
Hardware requirements
  • MIMXRT1180-EVK RevC

  • RJ45 Network cable

  • Mini/micro USB cable

  • Personal Computer on which the TwinCat3 has been installed(Windows 10 is recommended)

Board settings

No special settings are required.

EEPROM LPI2C Emulator
  1. i.MX RT1180 supports EEPROM LPI2C emulator, please skip this chapter if you used EEPROM hardware.

  2. Hardware Setting

    • Connection:

      J51: pin4 <–> J44: pin20

      J51: pin6 <–> J44: pin18

    • Remove EEPROM:

      U48

  3. Add EEPROM_I2C_EMULATOR macro

    • Add EEPROM_I2C_EMULATOR macro to enable eeprom i2c emulator funtion

  4. Now you can refer “Prepare the Demo” to setup ecat_examples

Prepare the Demo
  1. Generate the SSC source code

    • Download Slave Stack Code Tool(SSC Tool V5.13) from BECKHOFF official website and install it

    • Open Slave Stack Code Tool

    • Click ‘File’ -> ‘New’ -> ‘Import’ to import the Congfig file Select eoe.xml under path ‘.\boards\evkmimxrt1180\ecat_examples\eoe<core>\SSC’.

    • Click ‘Custom’ -> ‘NXP ECAT…’ -> ‘OK’ to select the subdevice description file

    • Click ‘Tool’ -> ‘Application’ -> ‘Import’ to import Application information Select eoe_freertos.xlsx under path ‘.\boards\evkmimxrt1180\ecat_examples\eoe<core>\SSC’.

    • Click ‘Project’ -> ‘Create new Slave Files’ ‘Source Folder’(default): ‘.\boards\evkmimxrt1180\ecat_examples\eoe<core>\SSC\Src’. Click ‘Start’.

    • Remove eoe_freertos.c under Src folder

  2. Connect EtherCAT Port0 with TwinCAT3

    • RJ45 interface labeled as J28 is the EtherCAT Port0 and RJ45 interface labeled as J32 is the EtherCAT Port1.

  3. Connect a USB cable between the host PC and the OpenSDA USB port on the target board

  4. Open a serial terminal with the following settings

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  5. Download the program to the target board

  6. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo

  7. Update ESI file to EEPROM

    • Copy ESI file ‘ECAT-EOE.xml’ generated by SSC TOOL to <TwinCAT_installation_folder>/<twincat_version>/Config/io/EtherCAT/

    • Restart TwinCAT3 IDE

    • Scan Device and Update EEPROM

  8. Scan and load this device.

    The PLC Main code is as follows:

     PROGRAM MAIN
     VAR 
     	Delay : TON;
     	LedIn AT %I* : BOOL; 
     	LedOut AT %Q* : BOOL;
     END_VAR
     
     Delay(IN := TRUE, PT := T#1S);
     IF Delay.Q THEN
     	LedOut := NOT LedIn;
     	Delay(IN := FALSE);
     END_IF;
    
  9. EoE configuration setting

    • Set the address of the network card used to connect to the demo board on PC side

      ip address: 192.168.1.102

      subnet mask: 255.255.255.0

      gateway: 192.168.1.0

    • Set the address of the demo board on TwinCAT EoE configuration page

      ip address: 192.168.1.66

      subnet mask: 255.255.255.0

      gateway: 192.168.1.102

  10. Activate configuration

    • Click ‘TwinCAT’ -> ‘Restart TwinCAT(Config Mode)’ to activate configuration

  11. Test ping and http server

    • Open cmd.exe and execute “ping 192.168.1.66”

    • Make sure browser proxy disabled

    • Open browser and access “http://192.168.1.66”

FRDM-MIMXRT1186
Hardware requirements
  • FRDM-IMXRT1186 A2

  • RJ45 Network cable

  • Type-C USB cable

  • Personal Computer on which the TwinCat3 has been installed(Windows 10 is recommended)

Board settings
  • J12(2-3)/J13(2-3): eCAT0 Function Via J57A(Default).

  • J18(2-3)/J17(2-3): eCAT1 Function Via J57B(Default).

EEPROM LPI2C Emulator
  1. FRDM-IMXRT1186 supports EEPROM LPI2C emulator, please skip this chapter if you used EEPROM hardware.

  2. Hardware Setting

    • Remove Jumper:

      J31: pin1 - pin2

      J35: pin1 - pin2

    • Remove Resistors:

      R297: pin1 - pin2

      R299: pin1 - pin2

    • Add Resistors:

      R30

      R31

      R297: pin1 - pin3

      R299: pin1 - pin3

    • Connection:

      J31: pin1 <–> J2: pin18

      J35: pin1 <–> J2: pin20

  3. Add EEPROM_I2C_EMULATOR macro

    • Add EEPROM_I2C_EMULATOR macro to enable eeprom i2c emulator funtion

  4. Now you can refer “Prepare the Demo” to setup ecat_examples

Prepare the Demo
  1. Generate the SSC source code

    • Download Slave Stack Code Tool(SSC Tool V5.13) from BECKHOFF official website and install it

    • Open Slave Stack Code Tool

    • Click ‘File’ -> ‘New’ -> ‘Import’ to import the Congfig file Select eoe.xml under path ‘.\boards\frdmimxrt1186\ecat_examples\eoe<core>\SSC’.

    • Click ‘Custom’ -> ‘NXP ECAT…’ -> ‘OK’ to select the subdevice description file

    • Click ‘Tool’ -> ‘Application’ -> ‘Import’ to import Application information Select eoe_freertos.xlsx under path ‘.\boards\frdmimxrt1186\ecat_examples\eoe<core>\SSC’.

    • Click ‘Project’ -> ‘Create new Slave Files’ ‘Source Folder’(default): ‘.\boards\frdmimxrt1186\ecat_examples\eoe<core>\SSC\Src’. Click ‘Start’.

    • Remove eoe_freertos.c under Src folder

  2. Connect EtherCAT Port0 with TwinCAT3

    • RJ45 interface labeled as J57A is the EtherCAT Port0 and RJ45 interface labeled as J57B is the EtherCAT Port1.

  3. Connect a USB cable between the host PC and the OpenSDA USB port on the target board

  4. Open a serial terminal with the following settings

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  5. Download the program to the target board

  6. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo

  7. Update ESI file to EEPROM

    • Copy ESI file ‘ECAT-EOE.xml’ generated by SSC TOOL to <TwinCAT_installation_folder>/<twincat_version>/Config/io/EtherCAT/

    • Restart TwinCAT3 IDE

    • Scan Device and Update EEPROM

  8. Scan and load this device.

    The PLC Main code is as follows:

     PROGRAM MAIN
     VAR 
     	Delay : TON;
     	LedIn AT %I* : BOOL; 
     	LedOut AT %Q* : BOOL;
     END_VAR
     
     Delay(IN := TRUE, PT := T#1S);
     IF Delay.Q THEN
     	LedOut := NOT LedIn;
     	Delay(IN := FALSE);
     END_IF;
    
  9. EoE configuration setting

    • Set the address of the network card used to connect to the demo board on PC side

      ip address: 192.168.1.102

      subnet mask: 255.255.255.0

      gateway: 192.168.1.0

    • Set the address of the demo board on TwinCAT EoE configuration page

      ip address: 192.168.1.66

      subnet mask: 255.255.255.0

      gateway: 192.168.1.102

  10. Activate configuration

    • Click ‘TwinCAT’ -> ‘Restart TwinCAT(Config Mode)’ to activate configuration

  11. Test ping and http server

    • Open cmd.exe and execute “ping 192.168.1.66”

    • Make sure browser proxy disabled

    • Open browser and access “http://192.168.1.66”

i.MX943-EVK
Hardware requirements
  • IMX943-EVK board

  • RJ45 Network cable

  • Mini/micro USB cable

  • Personal Computer on which the TwinCat3 has been installed

Board settings

No special settings are required.

Prepare the Demo
  1. Generate the SSC source code

    • Download Slave Stack Code Tool(SSC Tool V5.13) from BECKHOFF official website and install it

    • Open Slave Stack Code Tool

    • Click ‘File’ -> ‘New’ -> ‘Import’ to import the Congfig file Select eoe.xml under path ‘.\boards\imx943evk\ecat_examples\eoe<core>\SSC’.

    • Click ‘Custom’ -> ‘NXP ECAT…’ -> ‘OK’ to select the subdevice description file

    • Click ‘Tool’ -> ‘Application’ -> ‘Import’ to import Application information Select eoe_freertos.xlsx under path ‘.\boards\imx943evk\ecat_examples\eoe<core>\SSC’.

    • Click ‘Project’ -> ‘Create new Slave Files’ ‘Source Folder’(default): ‘.\boards\imx943evk\ecat_examples\eoe<core>\SSC\Src’. Click ‘Start’.

    • Remove eoe_freertos.c under Src folder

  2. Connect EtherCAT Port0 with TwinCAT3

    • Connect EtherCAT0 labeled as J24B with TwinCAT3 using RJ45 Network cable.

  3. Connect a USB cable between the host PC and the OpenSDA USB port on the target board

  4. Open a serial terminal with the following settings

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  5. Download the program to the target board

  6. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo

  7. Update ESI file to EEPROM

    • Copy ESI file ‘ECAT-EOE.xml’ generated by SSC TOOL to <TwinCAT_installation_folder>/<twincat_version>/Config/io/EtherCAT/

    • Restart TwinCAT3 IDE

    • Scan Device and Update EEPROM

  8. Scan and load this device.

    The PLC Main code is as follows:

     PROGRAM MAIN
     VAR 
     	Delay : TON;
     	LedIn AT %I* : BOOL; 
     	LedOut AT %Q* : BOOL;
     END_VAR
     
     Delay(IN := TRUE, PT := T#1S);
     IF Delay.Q THEN
     	LedOut := NOT LedIn;
     	Delay(IN := FALSE);
     END_IF;
    
  9. EoE configuration setting

    • Set the address of the network card used to connect to the demo board on PC side

      ip address: 192.168.1.102

      subnet mask: 255.255.255.0

      gateway: 192.168.1.0

    • Set the address of the demo board on TwinCAT EoE configuration page

      ip address: 192.168.1.66

      subnet mask: 255.255.255.0

      gateway: 192.168.1.102

  10. Activate configuration

    • Click ‘TwinCAT’ -> ‘Restart TwinCAT(Config Mode)’ to activate configuration

  11. Test ping and http server

    • Open cmd.exe and execute “ping 192.168.1.66”

    • Make sure browser proxy disabled

    • Open browser and access “http://192.168.1.66”