.. _ecat_eoe_http_server: ECAT_EOE_HTTP_SERVER ====================== 1. Overview ------------ The ECAT_EOE_HTTP_SERVER example demonstrates HTTP Server functionality implemented based on EtherCAT EoE features. EtherCAT EoE is an extension feature of the EtherCAT protocol that allows transmission of standard Ethernet frames between EtherCAT master and slave devices. This example program supports initialization of ESC EEPROM data, which can simplify the process of updating ESC EEPROM. If the program code contains EEPROM data (eeprom.h) generated by SSC Tool, it will check the data stored in ESC EEPROM and update it based on conditions. If the checksum validation of the EtherCAT Slave Controller Configuration Area (first 8 Words) in EEPROM fails, it will initialize EEPROM using data from eeprom.h. If the checksum validation of the EtherCAT Slave Controller Configuration Area (first 8 Words) in EEPROM succeeds, it will further validate the Product Code and Revision Code in the EEPROM data. When the Product Code is different or the Revision Number in eeprom.h is greater than the Revision Number currently stored in EEPROM data, it will initialize EEPROM using data from eeprom.h. This method can solve the problem of checksum validation failure when EEPROM is empty during initial use, and can initialize EEPROM. During program upgrade, when the Revision Number in eeprom.h of the new program code is greater than the Revision Number currently stored in EEPROM data, it will initialize EEPROM using eeprom.h from the new program without needing to update EEPROM through master tools such as TwinCAT. 2. Preparation ---------------- Please refer to ECAT_IO README Software version: SSC Tool (SSC Version: 5.13.1; Config File Vers: 1.5.3.0) 3. Project Setup ------------------- Please refer to ECAT_IO README **Note**: When using FLASH to simulate EEPROM functionality, appropriate flash space needs to be allocated for FLASH_EEPROM content to avoid conflicts with other flash content. 4. Generate Slave Protocol Stack Code ---------------------------------------- Due to licensing issues, HPM_SDK does not provide EtherCAT slave protocol stack code (SSC). Users must download SSC Tool from Beckhoff's official website and generate slave protocol stack code. **Note**: Examples under /samples/ethercat/ecat_eoe share the same SSC configuration. Generating SSC slave protocol stack code only needs to be done once, and multiple eoe examples can share it. 4.1. Download SSC Tool ~~~~~~~~~~~~~~~~~~~~~~~~ Please refer to ECAT_IO README 4.2 Import Configuration File in SSC Tool ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Configuration file path: /samples/ethercat/ecat_eoe/SSC/Config/HPM_ECAT_EOE_Config.xml 4.3 SSC Tool Generates Protocol Stack Code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Create a new project and select the specified configuration file .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/eoe_ssc_create_project.png :alt: 2. Import application xlsx: /samples/ethercat/ecat_eoe/SSC/eoe.xlsx 3. Specify output directory and generate slave protocol stack code and device description file ESI 4.4 SSC EOE Protocol Stack Code Modification ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The SSC EOE protocol stack has an issue in processing sent data frames. When data is not completely sent and the mailbox is full, there is a problem with the processing logic that causes the remaining data content to not be sent. The following modification is required: .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/eoe_ssc_fix.png :alt: This modification can be completed by applying a patch. Execute the following command in the SSC directory command line window: patch -d Src < ssc_eoe_fix.patch .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/eoe_ssc_patch.png :alt: **Note**: If you don't have the patch command installed on your computer, you need to install GNU patch version 2.5.9 or higher. If already installed, please skip this step. Download the patch command from the `website `_ (current version is 2.5.9), and add the installation path of "patch.exe" to the system environment variables so that the patch command can be executed in the command line window. 5. TwinCAT Project Setup --------------------------- Please refer to ECAT_IO README 5.1. Add ESI File ~~~~~~~~~~~~~~~~~~~~ 1. Please modify the device attribute () in the ESI file generated by SSC tool according to the actual number of hardware ports. The default generated attribute is "YY", indicating that Port0 and Port1 are implemented. If Port0, Port1 and Port2 are actually implemented, please manually modify the attribute to "YYY". .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/esc_device_physics_eoe.png :alt: 2. Copy the ESI file to TwinCAT installation directory (e.g.: **C:/TwinCAT/3.1/Config/Io/EtherCAT**). 5.2 Create Project ~~~~~~~~~~~~~~~~~~~~ Please refer to ECAT_IO README 5.3 Software Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please refer to ECAT_IO README 5.4 Scan Devices ~~~~~~~~~~~~~~~~~~ Please refer to ECAT_IO README 5.5 Update EEPROM ~~~~~~~~~~~~~~~~~~~ Please select **eoe** device description file .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/twincat_eeprom_update_eoe.png :alt: Note: The current example already supports EEPROM initialization functionality. During initial use, it will automatically write EEPROM data generated by SSC Tool to ESC EEPROM. When running the example, there is no need to use TwinCAT to update EEPROM, but the functionality of updating EEPROM through tools such as TwinCAT is still available. 5.6 After scanning correctly, enter OP mode (EoE functionality only needs to be in Init or higher state to run). .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/eoe_freerun.png :alt: 6. EoE Function Testing --------------------------- 6.1 Set PC IP Address The PC's IP address needs to be in the same subnet as the slave device's IP address, otherwise communication through EoE functionality is not possible. .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/eoe_set_pc_ip.png :alt: 6.2 Set Slave Device IP Address in TwinCAT 1. Check EOE function settings .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/twincat_eoe_check_setting.png :alt: 2. Set slave device IP address .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/twincat_eoe_set_ip.png :alt: 3. Click **TwinCAT->Restart TwinCAT (Config Mode)** to activate IP settings. 6.3 Test ping functionality using the set slave device IP address .. image:: ../../../../../../samples/ethercat/ecat_eoe/doc/eoe_ping_test.png :alt: 6.4 Use browser client to input the set slave device IP address, for example input http://192.168.100.10, press Enter to display the following page: **Note**: This example can run successfully using browsers with 360 or IE kernel .. image:: ../../../../../../samples/ethercat/ecat_eoe/ecat_eoe_http_server/doc/eoe_http_server.png :alt: 7. Running Phenomenon ----------------------- When the project runs correctly, the serial terminal will output the following information: When EEPROM data initialization is needed, the EtherCAT initialization log is as follows: .. code-block:: console EtherCAT EOE HTTP Server sample with LwIP stack. Init EEPROM content. Init EEPROM content successful. EEPROM loading successful, no checksum error. When EEPROM data initialization is not needed, the EtherCAT initialization log is as follows: .. code-block:: console EtherCAT EOE HTTP Server sample with LwIP stack. No need to init EEPROM content. EEPROM loading successful, no checksum error. The correct running log is as follows: .. code-block:: console LwIP Version: 2.1.2 EoE IP address setting: IPv4 Address: 192.168.100.10 IPv4 Netmask: 255.255.255.0 IPv4 Gateway: 192.168.100.2 MAC : 02:01:05:20:03:E9 EoE IP address setting: IPv4 Address: 192.168.100.10 IPv4 Netmask: 255.255.255.0 IPv4 Gateway: 192.168.100.2 MAC : 02:01:05:20:03:E9