This application demonstrates how to implement EtherCAT+ PMSM motor control on the iMX.RT1180. The reference design includes two projects, the master project and the slave project.The Master project is responsible for completing the processing of the EtherCAT master stack, and the Slave project is responsible for completing the processing of the EtherCAT slave stack and servo motor control.Based on this reference design, two demos were made for demonstration: Demo1: 1 master with four slave nodes, each node controls two motors. Two motors from different slave nodes are grouped together, and the synchronization performance of EtherCAT is demonstrated through laser penetration and shielding. Demo2: 1 master with two slave nodes, each node controls two motors.Motor 1 on different slave boards is responsible for controlling the left and right movement of the motor 2 platform. The two motors 2 on different boards will move synchronously when they are close to each other, and will move separately when they are separated.
- MCUXpresso IDE:11.8.1
- SDK for EVK-MIMXRT1180: 2.16.0
- Download the code from Git repository: TBD.
- Personal Computer
- NET Cable and 24V adaptor.
- XSERVO-MTR-DRV Board and MIMXRT1180-EVK
- J-Link Debugger (v7.88e)
-
Open MCUXpresso IDE, in the Quick Start Panel, choose Import from Application Code Hub
-
Enter the demo name in the search bar.
-
Click Copy GitHub link, MCUXpresso IDE will automatically retrieve project attributes, then click Next>.
-
Select main branch and then click Next>, Select the MCUXpresso project, click Finish button to complete import.
-
Click Build to start compiling the project.
-
5V supply via J2 (JP1 pin1 and pin2 are connected using a jumper).
-
Connect J-Link Debugger to J37 of the MIMXRT-1180-EVK RevC board.
-
Import 'motion_control_master_soem' project to MCUXpresso IDE.
-
Choose the SDP mode.(SW5->off-off-off-on).
-
Build motion_control_master_soem project(Debug build) and download the project to the board(JP5 need be connected with jumper). Note: This project CAN NOT be built directly. CMSIS related files are missing in the project, users need to manually copy the files from (..\ motion_control_servo_rt1180_cm33\CMSIS..) to (..\evkmimxrt1180_soem_servo_motor_bm_cm33\CMSIS..).
-
Choose the Flashboot mode.(SW5->off-on-off-off).
-
Reset borad.D31 will be light up all the time.
-
Connect the ETH4 to the Slave network port using the network cable.
-
5V supply via J16/17.
-
Connect J-Link Debugger to J15 of the XSERVO-MTR-PSG RevA board.
-
Import 'motion_control_servo_rt1180_cm33' and 'motion_control_servo_rt1180_cm7' project to MCUXpresso IDE.
-
Choose the SDP mode.(SW2->off-off-off-on).
-
Build 'motion_control_servo_rt1180_cm7' project first(Release build).
-
Build 'motion_control_servo_rt1180_cm33'project(Release build).Download the project to the board. Note: This project CAN NOT be built directly. Please see the below.Details can be found in chapters 4 to 6.3 of the document in the path '\rd-motion-control-imxrt1180\motion_control_servo_rt1180_cm33\docs'.
1. Generate the SSC source code
- Download Slave Stack Code Tool(SSC Tool) from BECKHOFF official website and install it
- Open Slave Stack Code Tool
- Click 'File' -> 'New' -> 'Import' to import the Congfig file
Select servo_motor.xml under path '.\boards\evkmimxrt1180\ecat_examples\servo_motor\<core>\SSC'.
- Click 'Project' -> 'Create new Slave Files'
'Source Folder'(default): '.\boards\evkmimxrt1180\ecat_examples\servo_motor\<core>\SSC\Src'.
Click 'Start'.
2. Copy SSC souce code to '\rd-motion-control-imxrt1180\motion_control_servo_rt1180_cm33\ecat\SSC\Src', and change to '.\rd-motion-control-imxrt1180\motion_control_servo_rt1180_cm33\ecat\SSC' path to apply the patch.
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 -d ./Src
3. Download the program to the Master board
4. Update ESI file to EEPROM
- Copy ESI file 'ECAT-SERVO-MOTOR.xml' generated by SSC TOOL to <TwinCAT_installation_folder>/<Version>/Config/io/EtherCAT/
- Restart TwinCAT3 IDE
- Scan device and Update EEPROM
-
Choose the Flashboot mode.(SW2->off-on-off-off).
-
Reset borad.LED1 will light up every 1s.
-
Connect the power and encoder port of the motor1&2.
-
Connect the network cable, J3 is the input of slave and J7 is the output of slave.
- Network cable connection between master and slave.
- 8 motors and 4 slave boards mounted to brackets.
-
Two 24V power supplies power the four boards. One power supply powers boards 1 and 2 /1 and 3, the other powers boards 3 and 4 /2 and 4
-
Make sure the motors are all in the correct position before powering up (is the laser able to pass through the round hole).
-
24V power up for slave board.
-
5V power up for master board.
- Network cable connection between master and slave.
-
Install the four motors onto the slide and tighten the couplings.
-
Docking the M2 gears on both boards together as shown above.
-
24V power up for slave board.
-
5V power up for master board.
Connect a USB cable between the host PC and the OpenSDA USB port on the Master board.Open a serial terminal with the following settings - 115200 baud rate - 8 data bits - No parity - One stop bit - No flow control The log below shows the output of this demo in the terminal window:
Init success!
Init 3 success!
Start SOEM SERVO MOTOR EXAMPLE!
NETC EP frame loopback example start.
Starting motion task
ec_init on netc0 succeeded.
ec_config_init 0
1 slaves found and configured.
ec_config_map_group IOmap:20001214 group:0
>Slave 1, configadr 1001, state 2
CoE Osize:192 Isize:192
ISIZE:192 192 OSIZE:192
SM programming
SM2 Type:3 StartAddr:1100 Flags: 10064
SM3 Type:4 StartAddr:1400 Flags: 10020
OUTPUT MAPPING
FMMU 0
SM2
slave 1 Outputs 20001214 startbit 0
=Slave 1, INPUT MAPPING
FMMU 1
SM3
Inputs 2000122C startbit 0
IOmapSize 48
Slaves mapped, state to SAFE_OP.
segments : 1 : 48 0 0 0
Request operational state for all slaves
Calculated workcounter 3
Request operational state for all slaves
Calculated workcounter 3
Operational state reached for all slaves.
Provide URLs for help here.
Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.
Warning: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum
Version | Description / Update | Date |
---|---|---|
1.0 | Initial release on Application Code Hub | September 9th 2024 |