dual_cores_ecat_servo_motor#
Overview#
This example is a implementation of EtherCAT servo motor system which is compliance with CiA402 profile. It consists of two parts: EtherCAT communication and Motor control. These two parts are running on different CPU cores.
EtherCAT communication is in charge of the communication with EtheCAt MainDevice and shares the data with Motor control programme via shared memory. Motor control controls up to two PMSM motors with Endat2.2 encoder.
Running the demo#
Note that the EtherCAT communication 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\dual_cores_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\dual_cores_servo_motor<core>\SSC’ Copy the whole “Src” folder in the new folder to “
\boards<board>\ecat_examples\dual_cores_servo_motor<core>\SSC’
Apply the patch
Change working directory to “\boards<board>\ecat_examples\dual_cores_servo_motor<core>\SSC”. Linux:
Download dos2unix command
apt-get install dos2unixTransfer SSC source code format
dos2unix Src/*Apply patch
patch -d ./ -p1 -i ./0001-SSC-Servo-dual-cores-servo-motor-control-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 0001-SSC-Servo-dual-cores-servo-motor-control-support.patchApply patch
patch.exe -d ./ -p1 -i ./0001-SSC-Servo-dual-cores-servo-motor-control-support.patch
After compilation and image download, the serial console for CM33_core1 will output:
Start the SSC dual_cores_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#
imx943evk
Hardware requirements
IMX943EVK
FRDM-LVPMSM-FA RevB boards
Servo Motors
T5PUXS4-H09: integrated ECN 1325 ENDAT2.2 Encoder
T5PUXS4-H18: integrated ECN 1325 ENDAT3 Encoder
HMD06-011-048-60-OPB1MW230: integrated BiSS Encoder
One Motor demo:
T5PUXS4-H09
T5PUXS4-H18
HMD06-011-048-60-OPB1MW230
Two Motors demo:
Two T5PUXS4-H09
One T5PUXS4-H09 and one T5PUXS4-H18
One T5PUXS4-H09 and one HMD06-011-048-60-OPB1MW230
One T5PUXS4-H18 and one HMD06-011-048-60-OPB1MW230
RJ45 Network cable
24V 5A DC power supply
Personal Computer on which the TwinCat3 has been installed
Board settings
FRDM-LVPMSM-FA board with T5PUXS4-H09 motor:
SW90[1:4]: OFF-ON-ON-ON
SW30[1:4]: OFF-OFF-ON-OFF
J300(1-2)
Encoder connection:
Pin name (FRDM-LVPMSM-FA)
Pin location (FRDM-LVPMSM-FA)
Sensor signal name
Pin location (T5PUXS4-H09)
ENC_CLK_P
J70-2
CLOCK
5
ENC_CLK_N
J70-7
CLOCK-
6
ENC_DATA_IO_P
J70-4
DATA
3
ENC_DATA_IO_N
J70-9
DATA-
4
VENC
J70-1
Vcc(+5v)
1
GND
J70-6
GND
2
Motor connection:
J140: pin3 <–> Cable A: 1=U
J140: pin2 <–> Cable A: 3=W
J140: pin1 <–> Cable A: 4=V
FRDM-LVPMSM-FA board with T5PUXS4-H18 motor:
SW90[1:4]: OFF-ON-ON-ON
SW30[1:4]: OFF-OFF-OFF-ON
J72(1-3)
J72(2-4)
J73(1-2)
J300(1-2)
Encoder connection:
Pin name (FRDM-LVPMSM-FA)
Pin location (FRDM-LVPMSM-FA)
Sensor signal name
Pin location (T5PUXS4-H18)
ENC_DATA_IO_VENC_P
J70-5
P_SD+
1
ENC_DATA_IO_VENC_N
J70-10
P_SD-
2
Motor connection:
J140: pin3 <–> Cable A: 1=U
J140: pin2 <–> Cable A: 3=W
J140: pin1 <–> Cable A: 4=V
FRDM-LVPMSM-FA board with HMD06-011-048-60-OPB1MW230:
SW90[1:4]: ON-OFF-OFF-ON
SW30[1:4]: OFF-ON-OFF-OFF
J72(1-3)
J72(2-4)
J73(1-2)
J300(1-2)
Encoder connection:
Pin name (FRDM-LVPMSM-FA)
Pin location (FRDM-LVPMSM-FA)
Sensor signal name
Pin location (HMD06-011-048-60-OPB1MW230)
ENC_CLK_P
J70-2
MASTER_CLOCK_INPUT_P
9
ENC_CLK_N
J70-7
MASTER_CLOCK_INPUT_N
11
ENC_DATA_IN_P
J70-3
SLAVE_DATA_P
7
ENC_DATA_IN_N
J70-8
SLAVE_DATA_N
8
VENC
J70-1
VDC
5
GND
J70-6
GND
6
Motor connection:
J140: pin3 <–> Cable A: 1=U
J140: pin2 <–> Cable A: 3=W
J140: pin1 <–> Cable A: 4=V
i.MX943-EVK board:
SW4: based on used BOOT_MODE
SW7[1:4] : ON:ON:ON:ON
SW8: ALL to OFF
Serial Port Setting:
Replace “BOARD_DEBUG_UART_INSTANCE 8” with “BOARD_DEBUG_UART_INSTANCE 1” on “board.h”
i.MX943 EVK has 4 serial port: port0, port1, port2, port3, using serial port1 as m70 core output, port2 as m33s core output
Prepare the Demo
Connect the FRDM-LVPMSM-FA shield with the motor to the M1 connector on the front of i.MX943-EVK board.
For two motors demo, connect the second FRDM-LVPMSM-FA shield on M2 connector on the back of i.MX943-EVK board.
Select the encoder used for motor using the macro definitions M1_ENCODER and M2_ENCODER in the mc_periph_init.h file:
For M1
“#define M1_ENCODER ENCODER_ENDAT2P2_2” for Endat2.2 encoder
“#define M1_ENCODER ENCODER_ENDAT3” for Endat3 encoder.
“#define M1_ENCODER ENCODER_BISS” for BISS encoder.
For M2
“#define M2_ENCODER ENCODER_ENDAT2P2_1” for Endat2.2 encoder
“#define M2_ENCODER ENCODER_ENDAT3” for Endat3 encoder.
“#define M2_ENCODER ENCODER_BISS” for BISS encoder.
The default value of these two macros: #define M1_ENCODER ENCODER_BISS #define M2_ENCODER ENCODER_ENDAT3
Note: The i.MX943‑EVK board supports only one EnDat 3 motor or one BiSS motor.
Plug the USB cable from the USB host to the FTDI_DEBUG USB connector J15 on the i.MX943-EVK board.
Open a serial terminal with the following settings
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Plug the 12-V DC power supply to the P1 connector on the i.MX943-EVK board.
Plug the 24-V DC power supply to the J10 connector on the FRDM-LVPMSM-FA board(s).
Connect EtherCAT0 labeled as J24B with TwinCAT3 using RJ45 Network cable.
frdmimxrt1186
Hardware requirements
FRDM-IMXRT1186
FRDM-LVPMSM-FA RevB
FRDM-EXP-LVPMSM RevB
TGT3-0065-60-48 Motor
RJ45 Network cable
24V DC power supply
TwinCat3
Board settings
FRDM-LVPMSM-FA board:
SW90[1:4]: OFF-ON-ON-ON
SW30[1:4]: OFF-ON-OFF-OFF
J300(2-3)
Encoder connection:
Pin name (FRDM-LVPMSM-FA)
Pin location (FRDM-LVPMSM-FA)
Sensor signal name
ENC_CLK_P
J70-2
CLOCK_P
ENC_CLK_N
J70-7
CLOCK_N
ENC_DATA_IO_P
J70-4
DATA_P
ENC_DATA_IO_N
J70-9
DATA_N
VENC
J70-1
UP - Power supply voltage
GND
J70-6
GND
Motor connection:
J140: pin3 <–> Cable A: 1=U
J140: pin2 <–> Cable A: 3=W
J140: pin1 <–> Cable A: 4=V
FRDM-IMXRT1186 board:
Jumper setting:
J29 (2-3) J42 (1-2) J49 (2-3) J30 (2-3) J33 (2-3) J27 (2-3) J12 (2-3) J13 (2-3) J18 (2-3) J17 (2-3)
Add zero resistors:
R2, R3, R243, R448, R34, R40, R83(1-3)
Remove resistors:
R407
FRDM-EXP-LVPMSM board:
Add zero resistors:
SJ12, SJ53, SJ52, SJ38, SJ29, SJ28, SJ27, SJ37, SJ16, SJ14, SJ9 , SJ4 , SJ17, SJ18, SJ2 , SJ1 ,
SJ19, SJ20, SJ44, SJ42, SJ39, SJ36, SJ10, SJ17, SJ45, SJ47, SJ5 , SJ6 , SJ8 , SJ11, SJ13, SJ15Remove resistors:
SJ21, SJ23, SJ25, SJ31, SJ26, SJ32, SJ49
Prepare the Demo
Connect the FRDM-EXP-LVPMSM board to the FRDM-IMXRT1186 board
Connect the FRDM-LVPMSM-FA with the motor to the Motor1 interface of FRDM-EXP-LVPMSM
If demostart two motors, connect the second FRDM-LVPMSM-FA with the motor to the Motor2 interface of FRDM-EXP-LVPMSM board.
Plug the USB cable from the USB host to the FTDI_DEBUG USB connector J23 on the FRDM-IMXRT1186 board.
Open a serial terminal with the following settings
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Plug the 24-V DC power supply to the J10 connector on the FRDM-LVPMSM-FA board(s).
Connect EtherCAT0 labeled as J57A with TwinCAT3 using RJ45 Network cable.
evkmimxrt1180
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
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