Skip to content

Modbus RTU Serial Communication Test

1 Preparation

Two USB-to-RS485 serial cables, two DuPont wires, XCOM software, MobaXterm software, and MODSIM software.

XCOM software download link: https://download.aubo-robotics.cn/3rd-party/XCOM_V2.3.zip

MobaXterm software documentation: 34 Using MobaXterm to Remotely Manage the Target Device · GitBook (aubo-robotics.cn)

MODSIM software download link: Modscan32+Mosim32_SN_TCP Debugging Tool

2 Operation Steps for Testing Serial Communication

  1. Connect the two 9-pin USB-to-RS485 serial cables together using DuPont wires. The wiring method is pin 1 to pin 1 and pin 2 to pin 2, as shown in the following figure.

image-20240115151114870

  1. Connect the two USB connectors to the computer and the control cabinet respectively.

image-20240115153051959

  1. You can also connect one 9-pin USB-to-RS485 serial cable directly to the control cabinet using DuPont wires: connect pin 1 to RS485+ and pin 2 to RS485-, as shown in the figure.

image-20240115151114870

  1. The 485 silkscreen labels and serial port numbers displayed in the software for each control cabinet model are shown in the table.
Controller 485Interface Board 485ISImproved Control CabinetNew CS/ES3/ES5Mini Control Box
485 IO Silkscreen485_A, 485_BNoneA2, B2NoneNone
Mapped Port NumberttyIfaceBrdNonettyIfaceBrdNoneNone
UI Display[I/O] 485_A, 485_BNone[I/O] A2, B2NoneNone
Native 485485 IO SilkscreenRS485Modbus RTUA1 B1485+ 485-COM2
Port NumberttyS2ttyS2ttyS0ttyS7ttyS2
UI DisplayRS485Modbus RTU[I/O] A1, B1[I/O] 485+, 485-COM2
Extended 485Tool RS485Port NumberttyRobotTool
UI DisplayTool RS485
Tool RS485
USB-RS485Port NumberttyUSB*
- Example: ttyUSBxx
UI DisplayUSB-RS485 (xx)
- xx is the xx in ttyUSBxx
  1. Open MobaXterm and enter the command dmesg|grep usb in the control cabinet terminal to check whether the ttyUSB* port on the control cabinet has recognized the USB serial cable device.
dmesg|grep usb

image-20240115140417979

This indicates that the USB device has been successfully recognized. It is a full-speed USB device with number 3, and the device name is FT232R USB UART.

image-20240115155512843

This indicates that the USB-to-485 serial cable has been connected to the ttyUSB0 port.

  1. On the computer, open Device Manager and check the port number. As shown in the following figure, the port number recognized on the computer is COM3.

image-20240115160200387

  1. Open the control cabinet terminal and set the serial port baud rate, data bits, parity, and stop bits.
stty -F /dev/ttyUSB0 115200 cs8 -parenb -cstopb
  • /dev/ttyUSB0 indicates the path of the ttyUSB0 serial device file
  • 115200 indicates the baud rate value
  • cs8 indicates 8 data bits
  • -parenb indicates no parity bit
  • -cstopb indicates 1 stop bit
  1. Open the control cabinet terminal and query the serial port parameters.
stty -F /dev/ttyUSB0 -a

image-20240115141447412

  1. Open XCOM software on the computer, select the serial port number, set the baud rate, stop bits, data bits, and parity bit, and click Open Serial Port.

image-20240115162215393

  1. In the control cabinet terminal, use echo to send data to the serial port. The XCOM software on the computer will print the received data.
echo "test" > /dev/ttyUSB0

image-20240115162708755

  1. In the control cabinet terminal, use cat to read data from the serial port.
cat /dev/ttyUSB0

Open XCOM software, enter data, and click Send.

image-20240115163508959

The control cabinet terminal will print the received data.

image-20240115163816107

3 Operation Steps for Modbus RTU Communication

  1. Connect the computer and the control cabinet using a USB-to-RS485 adapter cable.

  2. On the teach pendant's Configuration - Fieldbus - Modbus screen, click Add Modbus Unit, select RTU Mode, and create a new Modbus RTU device.

image-20240115165654567

  1. Set the serial port number, baud rate, parity, data bits, and stop bits.

image-20240115165759075

  1. Open MODSIM software and connect the port number.

image-20240115170054840

  1. Set the baud rate, parity, data bits, and stop bits, and click OK.

image-20240115170133069

  1. Create Modbus signals in the teach pendant and MODSIM respectively. In MODSIM software, modify the signal type and address so that they correspond to the Modbus signals on the tablet.

The signal types in MODSIM include the following four types:

  • INPUT STATUS indicates digital input
  • COIL STATUS indicates digital output
  • INPUT REGISTER indicates register input
  • HOLDING REGISTER indicates register output

image-20240115171030779

image-20240115171455658

A green check mark icon indicates successful communication, and a red exclamation mark icon indicates unsuccessful communication.