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 ./ -p1 -i ./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 -d ./ -p1 -i ./CiA402-combine-the-SSC-slave-with-ec_pmsm-support.patch

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#

MIMXRT1180-EVK
Hardware requirements
  • MIMXRT1180-EVK RevC

  • FRDM-MC-LVPMSM

  • Teknic2311P Motor

  • RJ45 Network cable

  • Mini/micro USB cable

  • Personal Computer on which the TwinCat3 has been installed

Board settings
  • Jumper setting:

    Jumper

    Setting

    Jumper

    Setting

    Jumper

    Setting

    JP1

    1-2

    J58

    2-3

    J78

    1-2

    J4

    1-2

    J59

    2-3

    J79

    1-2

    J6

    1-2

    J63

    1-2

    J90

    1-2

    JP6

    1-2

    J65

    1-2

    J91

    1-2

    J9

    1-2

    J72

    1-2

    J93

    1-2

    J11

    2-3

    J73

    1-2

    J97

    1-2

    J12

    1-2

    J75

    2-3

    J98

    1-2

    J14

    1-2

    J76

    1-2

    J99

    1-2

    J57

    2-3

    J77

    1-2

    J100

    1-2

  • Remove and solder zero resistors:

    • Add zero resistors: R747, R749, R760, R763, R767, R1049, R1051.

    • Remove zero resistors: R104, R105, R107, R126, R142, R146, R148, R1089, R1090.

  • For detailed motor connection and motor control user guide, please refer:

    • http://www.nxp.com/sdkmotorcontrol

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. Connect Teknic2311P motor to the FRDM-LVPMSM-FA shield

  2. Connect the FRDM-LVPMSM-FA shield on Motor Control interface of the MIMXRT1180-EVK board.

  3. Connect the EtherCAT Port0 on the MIMXRT1180-EVK board with TwinCAT3

    • The label of the EtherCAT Port0 is J28.

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

  5. Open a serial terminal with the following settings

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  6. Download the program to the target board

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

FRDM-MIMXRT1186
Hardware requirements
  • FRDM-IMXRT1186 A2

  • FRDM-MC-LVPMSM

  • Power supply 24V

  • Teknic2311P Motor

  • RJ45 Network cable

  • Type-C USB cable

  • Personal Computer on which the TwinCat3 has been installed

Board settings
  • Jumper setting:

    Jumper

    Setting

    J12

    2-3

    J13

    2-3

    J17

    2-3

    J18

    2-3

    J27

    2-3

    J29

    2-3

    J30

    2-3

    J33

    2-3

  • For detailed motor connection and motor control user guide, please refer:

    • http://www.nxp.com/sdkmotorcontrol

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. Connect Teknic2311P motor to the FRDM-LVPMSM-FA shield

  2. Connect the FRDM-LVPMSM-FA shield on Motor Control interface of the FRDM-IMXRT1186 board.

  3. Connect the EtherCAT Port0 on the FRDM-IMXRT1186 board with TwinCAT3 The label of the EtherCAT Port0 is J57A.

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

  5. Open a serial terminal with the following settings

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  6. Download the program to the target board

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