MCUXpresso SDK Documentation

ecat_servo_motor#

Overview#

This example is a implementation of EtherCAT servo motor system which is compliance with CiA402 profile running on one core.

The example only support one motor with quadrature encoder.

Running the demo#

Note that this code CAN NOT be compiled directly. Please follow the steps below:

  1. Generate the SSC source code

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

    • Create a new folder to save all files generated by SSC tool.

    • Open Slave Stack Code Tool.

    • Click ‘File’ -> ‘New’ -> ‘Import’ to import the Congfig file.
      Select servo_motor.xml under the path: “\boards<board>\ecat_examples\servo_motor<core>\SSC”.

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

    • Click ‘File’ -> ‘Save’ to save the project to the new folder.

    • Click ‘Project’ -> ‘Create new Slave Files’.
      Select ‘Source Folder’ to the new folder.

    • Click ‘Start’.
      The ESI file and SSC source code is saved on the new folder.

  2. Copy SSC souce code to the mcuxsdk folder

    • Delete the “Src” folder under the path: “\boards<board>\ecat_examples\servo_motor<core>\SSC’

    • Copy the whole “Src” folder in the new folder to “\boards<board>\ecat_examples\servo_motor<core>\SSC’

  3. Apply the patch
    Change working directory to “\boards<board>\ecat_examples\servo_motor<core>\SSC”.

    • Linux:

      1. Download dos2unix command
        apt-get install dos2unix

      2. Transfer SSC source code format
        dos2unix Src/*

      3. Apply patch
        patch -d Src < CiA402-combine-the-SSC-slave-with-ec_pmsm-support.patch

    • Windows:

      1. Download patch.exe and Unix2Dos.exe tool
        Download Windows Patch Utility from http://gnuwin32.sourceforge.net/downlinks/patch-bin-zip.php .
        Download Dos2Unix/Unix2Dos-Text file format converters from https://sourceforge.net/projects/dos2unix/ .

      2. Transfer the patch format
        $(Dos2Unix/Unix2Dos-DIR)/bin/unix2dos.exe CiA402-combine-the-SSC-slave-with-ec_pmsm-support.patch

      3. Apply patch
        patch.exe -i CiA402-combine-the-SSC-slave-with-ec_pmsm-support.patch ./Src

After compilation and image download, the serial console will output:

Start the SSC servo_motor example...

Now this servo system is ready to wait EtherCAT MainDevice connection.

TwinCAT Setup#

To demonstrate this servo system, TwinCAT is used as the EtherCAT MainDevice.

Supported Boards#