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:
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.
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’
Apply the patch
Change working directory to “\boards<board>\ecat_examples\servo_motor<core>\SSC”. Linux:
Download dos2unix command
apt-get install dos2unixTransfer SSC source code format
dos2unix Src/*Apply patch
patch -d ./ -p1 -i ./CiA402-combine-the-SSC-slave-with-ec_pmsm-support.patch
Windows:
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/ .Transfer the patch format
$(Dos2Unix/Unix2Dos-DIR)/bin/unix2dos.exe CiA402-combine-the-SSC-slave-with-ec_pmsm-support.patchApply 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
i.MX RT1180 supports EEPROM LPI2C emulator, please skip this chapter if you used EEPROM hardware.
Hardware Setting
Connection:
J51: pin4 <–> J44: pin20
J51: pin6 <–> J44: pin18
Remove EEPROM:
U48
Add EEPROM_I2C_EMULATOR macro
Add EEPROM_I2C_EMULATOR macro to enable eeprom i2c emulator funtion
Now you can refer “Prepare the Demo” to setup ecat_examples
Prepare the Demo
Connect Teknic2311P motor to the FRDM-LVPMSM-FA shield
Connect the FRDM-LVPMSM-FA shield on Motor Control interface of the MIMXRT1180-EVK board.
Connect the EtherCAT Port0 on the MIMXRT1180-EVK board with TwinCAT3
The label of the EtherCAT Port0 is J28.
Connect a USB cable between the host PC and the OpenSDA USB port on the target board
Open a serial terminal with the following settings
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board
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
FRDM-IMXRT1186 supports EEPROM LPI2C emulator, please skip this chapter if you used EEPROM hardware.
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
Add EEPROM_I2C_EMULATOR macro
Add EEPROM_I2C_EMULATOR macro to enable eeprom i2c emulator funtion
Now you can refer “Prepare the Demo” to setup ecat_examples
Prepare the Demo
Connect Teknic2311P motor to the FRDM-LVPMSM-FA shield
Connect the FRDM-LVPMSM-FA shield on Motor Control interface of the FRDM-IMXRT1186 board.
Connect the EtherCAT Port0 on the FRDM-IMXRT1186 board with TwinCAT3 The label of the EtherCAT Port0 is J57A.
Connect a USB cable between the host PC and the OpenSDA USB port on the target board
Open a serial terminal with the following settings
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo