Xinje XDH PLC & DS5C1 Servo over EtherCAT: Setup Guide

  • PLC
  • Xinje
  • EtherCAT
  • Servo
  • Motion control
Xinje XDH PLC connected over EtherCAT to two Xinje DS5C1 servo drives

Pulse/direction control is still very common for servos, but every axis needs its own bundle of wires, the PLC cannot read the motor's real position, and changing a drive parameter means walking to the cabinet with the drive's keypad. With EtherCAT, the PLC talks to every drive over a single daisy-chained network cable, reads the actual position, speed and torque, and changes drive parameters straight from the programming software.

This post records the steps I use to make a Xinje XDH-30A16L-E PLC control several Xinje DS5C1 servo drives over EtherCAT: wiring, scanning the network, setting up the cyclic data (PDO), setting the servo parameters, configuring the axes, and programming with Xinje's motion instructions. It is written for engineers who already know Xinje PLCs and want to move from pulse control to EtherCAT.

Hardware and software used

  • A Xinje XDH series PLC (here an XDH-30A16L-E) as the EtherCAT master.
  • Xinje DS5C1 servo drives (3 axes in this example), each one an EtherCAT slave.
  • Xinje PLC Program Tool. Motion instructions such as A_MOVER need software version 3.7.4 or later and PLC firmware V3.6.1b or later (per the XDH/XLH Motion Control Manual).

1. Wiring

EtherCAT is wired as a daisy chain:

  1. The EtherCAT port on the PLC goes to the IN port of the first drive.
  2. The OUT port of the first drive goes to the IN port of the second drive, and so on to the last drive.
  3. The programming PC plugs into the PLC's normal Ethernet port, not into the EtherCAT line.

The wiring order sets the addresses: the drive closest to the PLC gets StationID 0, the next one StationID 1, and so on. Swap IN and OUT or change the cable order and the axis order no longer matches the program, so write this order on the electrical drawings from the start.

2. Initial setup

2.1. Scanning the EtherCAT network

Create a new project in Xinje PLC Program Tool, connect to the PLC, then open PLC Communication → EthercatMaster → Scan. The software lists the drives it finds in their order on the network, for example StationID:0 XINJE-DS5C1 CoE Drive.

EthercatConfig window after a scan: 3 DS5C1 drives with StationID 0, 1 and 2
EthercatConfig window after a scan: 3 DS5C1 drives with StationID 0, 1 and 2

If fewer drives show up than are installed, check the IN/OUT cables and the power of the missing drive before going further.

2.2. Cyclic process data (PDO)

The Expert process data tab shows what the PLC sends to the drive and what it reads back on every cycle:

  • SM2 (Outputs), using PDO 0x1600 (1st RxPDO): Control Word 6040h, Target Position 607Ah, Target Velocity 60FFh, Target Torque 6071h, Modes of Operation 6060h.
  • SM3 (Inputs), using PDO 0x1A00 (1st TxPDO): Status Word 6041h, actual position 6064h, actual velocity 606Ch, actual torque 6077h, mode of operation display 6061h.
Expert process data tab: Sync Managers and the objects in PDO 0x1600
Expert process data tab: Sync Managers and the objects in PDO 0x1600

To read one more object, for example the drive's digital inputs (60FDh), select the PDO to edit, click Add, pick the object from the list and click Add again. The total size of the objects must not exceed the size of the matching Sync Manager (SM).

Adding an object to a PDO from the drive's object list
Adding an object to a PDO from the drive's object list

2.3. IO Mapping: which PLC registers hold the data

The IO Mapping tab shows which register each PDO object is mapped to. For the drive at StationID 0 in this example:

ObjectNameRegister
6040hControl WordHD10000
607AhTarget PositionHD10002
60FFhTarget VelocityHD10004
6071hTarget TorqueHD10006
6060hModes of OperationHD10008
6041hStatus WordHD10010
6064hActual positionHD10012
606ChActual velocityHD10014
6077hActual torqueHD10016
6061hMode of operation displayHD10018
60FDhDrive digital inputsHD10060
IO Mapping tab: each PDO object and its HD register
IO Mapping tab: each PDO object and its HD register

When you use Xinje's motion instructions (section 4), the PLC handles the Control Word and Status Word for you. During commissioning and troubleshooting, though, reading these registers directly is very useful. The bits follow CiA 402:

  • Control Word (6040h): bit 0 switch on, bit 1 enable voltage, bit 2 quick stop, bit 3 enable operation, bit 7 fault reset, bit 8 halt.
  • Status Word (6041h): bit 0 ready to switch on, bit 1 switched on, bit 2 operation enabled, bit 3 fault, bit 4 voltage enabled, bit 5 quick stop, bit 6 switch on disabled, bit 7 warning, bit 10 target reached.
  • Digital inputs (60FDh): bit 0 negative limit switch, bit 1 positive limit switch, bit 2 home sensor.

2.4. Setting servo parameters through CoE-Online

The COE-Online tab reads and writes the drive parameters over the EtherCAT line (the P0-xx, P5-xx… parameters start at object 2000h), with no need for the drive keypad or a separate cable.

COE-Online tab: the object list and drive parameters
COE-Online tab: the object list and drive parameters

The parameters I always check when bringing an axis into service:

ParameterMeaningNotes
P0-05Motor direction0: forward, 1: reverse
P0-28Stop method at a limit switch0, 2: decelerate to stop; 1: coast to stop; 3: stop with an alarm
P0-79Absolute encoder use0: absolute encoder with battery; 1 (default): used as an incremental encoder; 2: absolute, ignoring multi-turn overflow
P5-22Positive limit switch inputDefault 1, i.e. pin SI1
P5-23Negative limit switch inputDefault 2, i.e. pin SI2
P5-27Home sensor inputDefault 3, i.e. pin SI3
P5-47/ALM alarm output
P5-68Emergency stop (EMG) input

How to set the pin assignment parameters (P5-xx): the last digit is the SI pin number, the digit before it selects a normally open or normally closed contact. For example 0x0001 is pin SI1 normally open, and 0x0011 (17 decimal) is pin SI1 normally closed. Limit switches are best wired normally closed, so a broken wire also stops the axis.

3. Axis configuration

Open Motion control → Axis configuration and enter the number of axes (3 in this example). The software creates the axes BMC_Axis000(0), BMC_Axis001(1) and BMC_Axis002(2). The number in brackets is the axis number used in the instructions, and it is the FuncMappingNum in the EthercatConfig window.

For each axis, on the Basic configuration tab:

  • Shaft type: Real axis, Command channel: EtherCAT.
  • From the station no.: the StationID of the drive that runs this axis.
  • Leave Automatic mapping on, so the software links the Control Word, Target Position, Status Word… to the PDO set up in section 2.
Axis configuration: axis 0 controlled over EtherCAT with automatic PDO mapping
Axis configuration: axis 0 controlled over EtherCAT with automatic PDO mapping

Units (Unit conversion). Choose mechanical units (mm or degrees) so the program is easy to read. For example, with a 20 mm lead ball screw and a 131072 pulses/rev encoder: choose mm, Number of pulses per turn = 131072, The amount of movement per turn = 20. With a gearbox, turn on Enable reducer and enter the ratio on both sides. From then on every position and speed in the instructions is in mm and mm/s.

Unit conversion: 131072 pulses per turn, 20 mm per turn
Unit conversion: 131072 pulses per turn, 20 mm per turn

Homing (HOME). The example below homes on the negative limit switch plus the encoder's Z pulse: the axis moves in the negative direction at 15 mm/s (acceleration 500 mm/s²), reverses when it hits the negative limit switch, then stops on the first Z pulse at an approach speed of 5 mm/s. Using the Z pulse gives much better repeatability than a sensor alone.

HOME Back to the original: homing on the negative limit switch and the Z pulse
HOME Back to the original: homing on the negative limit switch and the Z pulse

4. Programming: motion instructions and status registers

Enabling the servo: A_PWR

A_PWR  D0  M1  K0
  • D0 (S0): the instruction's status register.
  • M1 (S1): status bit.
  • K0 (S2): axis number (the number in brackets in Axis configuration).

When the input condition is ON, the axis is enabled and becomes ready. Keep the condition ON while the machine runs; turning it OFF disables the servo. Use only one A_PWR per axis: calling it twice causes a duplicate coil.

Moving to a position: A_MOVER (relative) and A_MOVEA (absolute)

A_MOVER  D0  D50  M1  K0
  • D0 (S0): the input parameter block, each value a 64-bit float (FP64, 4 registers): position D0, velocity D4, acceleration D8, deceleration D12, jerk D16; D22 is the buffer mode.
  • D50 (S1): the instruction's status register.
  • M1 (S2): status bits (M1 to M5); M1 turns on when the move is done.
  • K0 (S3): axis number.

The instruction starts when the condition goes from OFF to ON (rising edge). A_MOVER moves a distance from the current position, and the sign of the position sets the direction. A_MOVEA is declared the same way, but the position is an absolute coordinate from home. With buffer mode = 1, a new instruction is queued and starts as soon as the current one finishes, so a sequence of moves runs smoothly.

Other common instructions: A_RST (reset axis errors), A_STOP (stop), A_HOME (homing with the drive's HM mode), A_ZRN (homing controlled by the PLC), A_VELMOVE (velocity move). The full syntax is in Xinje's XDH/XLH Motion Control Manual.

Axis status registers

Each axis has its own block of status coils and registers (N is the axis number, default start address 20000):

AddressMeaning
M20000 + 50·NAxis enabled
M20001 + 50·NAxis in error
M20002 + 50·NAxis moving
M20003 + 50·NIn position
M20004 + 50·NAt home
M20008 + 50·NMotion instruction done
D20000 + 200·NAxis state: 0 disabled, 1 enabled and standing still, 2 moving, 5 homing, 7 error…
D20001 + 200·NError code
D20044 + 200·NActual position (FP64, in the chosen unit)
D20048 + 200·NActual velocity (FP64)

For example, axis 0's actual position is in D20044 and its actual velocity in D20048. Both can go straight to the HMI.

5. Tip: one register block per axis

Every motion instruction takes a parameter block, a status register and a few bits, so on a multi-axis machine addresses clash easily. I build an address table in Excel before writing the program:

  • Each axis gets its own address block: axis 1 uses D1000–D1999 and M1000–M1999, axis 2 uses D2000–D2999 and M2000–M2999, and so on.
  • Inside each block, every instruction (A_PWR, A_RST, A_STOP, A_ZRN, A_MOVEA, A_MOVER, A_VELMOVE…) has a row with 4 columns: the command bit from the HMI, the input parameter block, the status register and the status bits.
  • All axes use the same numbering inside their block, so copying axis 1's program to axis 2 only means adding 1000 to the addresses.

The table also becomes part of the handover documents: a maintenance engineer can see at a glance which HMI button calls which instruction on which axis.

Conclusion

The key points when moving to EtherCAT with Xinje: wire IN/OUT in the right order, check the PDO and IO Mapping, set the limit switch and home inputs through CoE-Online, and set mechanical units before writing the program. Do these steps right and the program itself comes down to A_PWR, homing, then A_MOVEA / A_MOVER.

In real projects I have run servos both ways: the Automated PCB Return Conveyor uses a Delta ASD-B3 servo driven by pulse signals from a Siemens S7-1200 PLC, while the Automated Pallet Conveyor Line uses a Delta AS228T PLC driving 8 servos over CANopen. More are on the Projects page.

Need a machine with a Xinje PLC or EtherCAT servos programmed or commissioned, or want to move an existing machine from pulse control to EtherCAT? See my PLC programming and motion control services or contact me.

Need help with a similar project?

Have a machine, line or automation project in mind? Message me on any channel below with a short description and I'll get back to you.

To get a quote faster, include:

WeChat

WeChat QR code to add Duc Tran as a friend

WeChat name: Mr. Duke · +84 948 795 739

Open WeChat and tap Scan. On a phone, save the image, then scan it from your photo album.

Save QR code

← All posts