[Answer] How to Use a Serial Port Debugging Assistant (Debugging Serial Communication)?
![[Answer] How to Use a Serial Port Debugging Assistant (Debugging Serial Communication)?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2F-20c8ed90.png&w=3840&q=75)
[Answer] How to Use a Serial Port Debugging Assistant (Debugging Serial Communication)?
[Answer] How to Use a Serial Port Debugging Assistant (Debugging Serial Communication)?
Serial communication is a very important method of communication in industrial automation systems. Since its introduction, serial communication methods based mainly on RS232 and RS485 have always occupied a key position in industrial automation communication systems. For automation engineers, working with serial ports for programming and debugging is essential. Below is an introduction to some commonly used tools, methods, and steps in serial port debugging.
1. Virtual Serial Port Tool: VSPD (Virtual Serial Port Driver)
A serial port is a hardware-based physical device, generally used for communication and data exchange between a computer and a field controller, between controllers, or between controllers and instruments. However, industrial equipment is usually installed on-site, so debugging often requires going to the field. To verify whether a program works correctly, you can use a virtual serial port tool for simulation and testing before actual debugging. VSPD is one of the most useful virtual serial port tools available for Windows.
To install VSPD, right-click VSPD.exe, choose Run as administrator, select the default language English (there is currently no Chinese version), and choose the installation path. Be sure to remember the installation path, as it will be needed later.
After installation, copy the vspdctl.dll file from the installation directory and paste it into the previous installation folder, replacing the target file to complete the installation.
VSPD can create connected virtual serial port pairs. The two ports are used to simulate two connected serial devices—for example, one port simulates a master station and the other simulates a slave station. In VSPD, confirm the virtual port names and select Add pair to add the paired ports.
After they are added, the virtual ports can be seen in VSPD under Virtual ports, while physical serial ports are listed under Physical ports. You can also see the virtual ports in the Windows Device Manager. Before uninstalling VSPD, be sure to delete the virtual serial ports using Delete ports.
2. Modbus Protocol Debugging Tools
Modbus RTU is one of the most widely used protocols over serial communication. There are many Modbus debugging tools on the market. This article recommends Modscan32 and Modsim32. Among them, Modscan32 acts as the Modbus master (simulating host computer software), while Modsim32 is used to simulate the Modbus slave, that is, to simulate Modbus devices in the industrial field.
2.1 Using Modsim32
When opening ModSim32 for the first time, you need to create a new virtual device.
Modsim32 supports creating multiple simulated devices at the same time. After creating them, enter the slave address (Device id), the starting register address (Address), and the number of registers (Length). After configuration, click Connect to connect to the serial port. In this example, COM3 and COM4 are used as a pair of virtual ports, and the virtual device created in ModSim32 is connected to COM4, with the baud rate and other serial parameters entered accordingly. Of course, ModSim32 also supports simulating Modbus devices through physical serial ports.
In this example, two virtual devices with device IDs 1 and 2 are created, and both are connected to the virtual port COM4. ModSim32 supports setting register values in four ways: fixed value, random value, incrementing, and decrementing. Double-click a register to set its value. To assign a fixed value, simply modify the Value field and click Update. For more advanced simulation, click Auto Simulation, choose Random, Increment, or Decrement, and configure the maximum and minimum values.
After the simulation is complete, choose Disconnect to close the serial connection. Modsim configurations can be saved to a file, so if the simulation setup is complex, you do not need to reconfigure everything one by one every time you open Modsim32.
2.2 Using ModScan32
Using Modscan32 is very similar to using Modsim32. Create a new simulation file, configure the slave device ID and register range to be accessed, then connect and configure the serial parameters. In this example, Modscan32 needs to communicate with the Modsim32 setup from the previous section, so it should connect to the other port in the VSPD virtual serial pair created earlier (COM3), while ensuring that the serial parameters of both ports match.
After the connection is established, Modscan32 can communicate with the Modbus devices created in Modsim32.
If you want to modify a coil or register address, simply double-click the corresponding address and set it. After making changes in Modscan, you can see the updated parameter values in Modsim. Before exiting Modscan32, you need to disconnect first.
One important note: in Modsim32, each file can simulate only one register range at a time. For example, if you want to simulate both 01 coils and 03 holding registers of the same Modbus device at the same time, you need to create and configure two separate devices. Only then can Modscan32 access them properly.
3. Other Serial Port Debugging Tools
There are many serial debugging applications available. This article introduces several commonly used tools.
3.1 ComMonitor Serial Debugging Software
Right-click and run the software as administrator. In this example, two instances of the software are opened at the same time, with COM3 and COM4 opened separately and configured with the same serial parameters. Data sent from one port can be seen in the receive area of the other port.
Compared with similar tools, this serial debugging software is relatively full-featured. It supports sending and receiving data in both hexadecimal and string formats. If no data appears in the receive area, first check whether the send and receive areas are set to hexadecimal or string format; the formats of the three send areas need to be configured separately.
Serial protocols often require CRC checking. This software includes CRC calculation, allowing you to click the check function before sending data and select the appropriate verification algorithm. The software also supports timed cyclic sending, which can meet most daily debugging needs.
3.2 SSCOM Serial Port Assistant
SSCOM is a more streamlined serial debugging tool. In this article, two instances are also opened and connected to COM3 and COM4 for send/receive testing. Similarly, you need to pay attention to whether the sent and received data format is string or hexadecimal.
3.3 Open-Source Tool: Serial Studio
Unlike the previous tools, Serial Studio is an open-source serial debugging application developed in C++. It supports multiple operating systems, and it supports not only serial ports, but also Ethernet and MQTT protocols. Serial Studio needs to be installed before use.
When using the serial port function, select the port and configure the serial parameters, then click the connect button in the upper-right corner. Similarly, you can send or receive serial data. Since the Chinese localization of Serial Studio is not very good, it may be more convenient to set the language to English in the settings interface.
Follow the WeChat public account: 维思自动化. Send 串口通讯 to get the software tools mentioned in this article.
![[Thought] Many viruses you’ve probably never heard of also contain DNA, such as iridoviruses](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2Fdna-39161584.png&w=3840&q=75)
![[Answer] What did you do on the night you checked your Gaokao score?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2F-e4a8ec38.png&w=3840&q=75)
![[Answer] How Can You Score 130+ on the Gaokao Math Exam?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2F130-157dba52.png&w=3840&q=75)