# Communication, Modbus, And Troubleshooting

Use this P4 reference for Xinje PLC/HMI communication questions, Modbus RTU/ASCII/TCP setup, XDPPro connection, HMI-to-PLC communication, status diagnosis, and troubleshooting.

Source anchors:

- XDPPro software manual PDF pages 21-22: TouchWin-style project creation requires HMI model, PLC port, download port, and communication parameters.
- XDPPro software manual PDF pages 33-46: PLC connection through serial/Ethernet and IP/network notes.
- XDPPro software manual PDF pages 110-112: `PLC 通讯 -> Modbus TCP` graphic configuration, model/firmware support, slave nodes, instruction rows, trigger modes.
- XD/XL basic instruction manual chapter 6 and PDF pages around 250+: Modbus RTU/ASCII, Modbus address, communication instructions.
- `soft-elements-and-special-relays.md`: serial communication status relays such as `SM140~SM193` and communication result registers such as `SD140~SD199`.

## First Questions

Clarify:

| Item | Examples |
|---|---|
| Link type | PC-to-PLC, HMI-to-PLC, PLC-to-device, PLC-to-PLC. |
| Physical layer | USB, RS232, RS485, Ethernet. |
| Protocol | Xinje protocol, Modbus RTU, Modbus ASCII, Modbus TCP, XNET, Ethernet/IP, CANopen, EtherCAT. |
| Role | Master/client or slave/server. |
| Parameters | Station ID, IP, port, baud rate, data bits, stop bits, parity, timeout, retry count. |
| Data map | Coil/register address, function code, word width, signed/unsigned, float, byte/word order. |
| Version | PLC model, firmware, XDPPro version, HMI model/TouchWin version. |

## PC To PLC In XDPPro

Common paths:

- USB/serial/Ethernet connection setup in XDPPro.
- `选项 -> 通讯方式设置` for communication mode.
- `选项 -> TCP/IP 设备设置` for Ethernet devices.
- `选项 -> 软件串口设置` for serial settings.
- Status bar shows model, communication mode, and PLC running status.

Troubleshooting:

1. Confirm correct cable/driver/interface.
2. Confirm only one application is using the serial port.
3. For Ethernet, confirm PC and PLC are in the same subnet and only the intended NIC is active.
4. Confirm PLC ID/IP/station.
5. Try upload/monitor after basic connection succeeds.

## HMI To PLC In TouchWin

In TouchWin project creation:

1. Select the correct HMI model.
2. Set `PLC 口` to the correct PLC/device type and communication parameters.
3. Set `下载口` to unused or to the correct communication device if it will communicate with lower devices.
4. Use the correct station number in each HMI component.
5. For online simulation, confirm PC-to-device hardware supports it; USB download alone may not support lower-device monitoring.

Common symptoms:

| Symptom | Checks |
|---|---|
| HMI shows "正在通讯" | Protocol, station, serial port, cable, COM occupancy, PLC port setting. |
| Values display wrong | Address notation, word width, signed/unsigned, float, scaling, byte order. |
| HMI button does not work | Button object address, station, PLC double-coil conflict, HMI permission/enable control. |
| Download port cannot communicate | Confirm download port is configured for communication mode, not only program download. |

## Modbus RTU/ASCII

Required parameters:

| Parameter | Notes |
|---|---|
| Station | Must match slave ID. |
| Baud rate | Match all devices on the bus. |
| Data bits / stop bits / parity | Must match exactly. |
| Wiring | RS485 A/B polarity, shield/grounding, termination for long/high-speed networks. |
| Function code | Coil/register read/write must match target map. |
| Register map | Confirm 0-based vs 1-based addressing and device-specific offsets. |

PLC-side concepts:

- Communication instructions include coil read/write and register read/write groups.
- XD/XL Modbus RTU handling queues multiple communication requests differently than old XC-style examples; still avoid uncontrolled repeated triggers.
- Use edge/condition triggers for write commands to avoid flooding a device.

Diagnosis:

1. Use a serial tool first when integrating a third-party device.
2. Verify a single read of one known register.
3. Add writes only after reads are stable.
4. Monitor communication busy/done/error bits and result registers.
5. Increase timeout/retry only after parameter and wiring checks.

## Modbus TCP Graphic Configuration In XDPPro

XDPPro path:

```text
工程 -> PLC 通讯 -> Modbus TCP
```

The software manual describes model/firmware support and a graphic table with:

- master connection information,
- slave node add/delete/copy/properties,
- instruction add/insert/delete/move/import/export,
- trigger mode: cyclic ms or conditional trigger,
- slave station number,
- function code,
- mapping/cache address,
- timeout/retry,
- connection flag/result storage.

Use this when the PLC model/firmware supports graphical Modbus TCP. Otherwise route to the Ethernet communication manual or use instruction/socket method as appropriate.

## Status Relays And Result Registers

From the current soft-element reference:

| Range | Use |
|---|---|
| `SM140~SM193` | Serial-port communication status flags. |
| `SD140~SD199` | Communication result registers. |

Example pattern:

- Serial port 0: `SM140` Modbus executing, `SM141` X-NET executing, `SM142` free-format sending, `SM143` free-format receive complete.
- `SD140` is the Modbus read/write result for serial port 0 in the referenced XD/XL manual.

Always verify the exact port group and model table before writing production diagnostics.

## Troubleshooting Checklist

1. Identify master/slave and protocol.
2. Confirm physical wiring and interface.
3. Confirm station/IP/port and serial parameters.
4. Confirm register/coil address map and function code.
5. Confirm data type and byte/word order.
6. Test one read, then one write.
7. Monitor status bits/result registers.
8. Check timeout/retry and polling interval.
9. Check HMI/PLC project settings use the same station and protocol.
10. Record final parameters in the project documentation.

## Safety Notes

- Communication writes can move outputs indirectly; treat write commands as live machine actions.
- Do not test write-multiple-registers against motion, heating, pressure, or recipe ranges without a safe machine state.
- Keep manual controls and emergency stops independent of the communication link.
