The Solidot XB6S series serial communication module XB6S-C01SP supports three communication interfaces: RS485, RS422 and RS232, and multiple communication modes: Modbus RTU master/slave, Modbus ASCII master/slave and Freeport. Compared with the conventional Modbus configuration, if the number of configured node parameters is less than what is actually used, or if you replace the module with another brand and do not want to make extensive program changes, you need to use programming for message communication. The following section explains how to use the program to edit Modbus messages in Freeport mode.

↑Solidot serial communication moduleXB6S-C01SP
1. Relationship between Freeport and Modbus
In essence, both belong to serial communication and perform message communication over a serial cable (RS485/RS422/RS232). Modbus imposes format restrictions on messages, including a frame structure = address + function code + data + checksum, whereas Freeport itself has no restrictions at all, i.e. the transmission format is defined by the program and there are no message format requirements. Therefore, to a certain extent, as long as the Freeport program conforms to the Modbus message format, Modbus communication with the device can be carried out.
2. Configuration parameters
The serial port parameters only need to match those of the connected device. Set the communication mode to Free port Request mode (which includes the request process and the waiting delay), and enable control/status mode with the error behavior set to hold.
According to the manual, the module's Freeport can be configured as follows: node 1 parameter 1 is configured with request mode control word 16#20 (10#32), node 2 parameter 1 input is configured as 16 bytes - 16#D04 (10#3332), node 3 parameter 1 output is configured as 16 bytes - 16#E04 (10#3589), and CRC16 checksum 16#F02 (3842) is appended to the end of the output. This step lays the groundwork for the message occupancy and adds message verification.

3. Process data
Once the parameters have been set, you can now fill in the process data.
Message example: 01 03 00 00 00 02 C4 0B
Response: 01 03 04 AB CD 12 34 46 9F
Here, the module is expected to use function code 03 to edit a message to read the internal data of 00 02 holding registers starting from slave address 01, offset 00 00. This time, Modbus slave is used to simulate the Modbus slave.

Downstream data:

Output data 1: control message enable;
Output data 2: total byte length of the output message (the 8 here includes the entered message and the automatically appended CRC check);
Output data 3, 4: alarm clear action (when the error behavior in the configuration parameters is set to hold, the default value 0 is sufficient here);
Output data 5: first data byte of the transmitted message.
Upstream data:

Input data 1: status word of the response message;
Input data 2: whether the response message contains an error;
Input data 3: length of the received message (can be compared against a standard Modbus message to verify whether the response is normal);
Input data 4, 5: Receive error Count (if the data length does not match exactly, this type of count alarm is generated);
Input data 6, 7: Receive data Count (increments by 1 each time data is returned, allowing verification of whether the message is new);
Input data 8: first data byte of the received message.
By truncating the data Area, we can see that ab, cd, 12, 34 are the current data in the Register, thus completing Modbus communication over Freeport.
Note: the specific parameter definitions are shown in the figure
6.3.3 Freeport_Request process data | |||
Upstream data (32 bytes) | |||
byte number | Functions | Meaning | Address range |
1 | status word | Bit0: Idle state | 1 byte |
Bit1: Busy state, i.e., data is being transmitted. | |||
Bit2: Complete state, i.e., data transmission is complete. | |||
2 | alarm code | Bit0: Receive data length error | 1 byte |
Bit1: Check error | |||
Bit2: Timeout error | |||
3 | Receive Data Length | .. 255 | 1 byte |
.. 5 | Receive Error Count | .. 65535 | 2 bytes |
.. 7 | Receive Data Count | .. 65535 | 2 bytes |
8 | Input Data | Serial Communication module input data | the last 25 bytes |
9 | Input Data | ||
|
| ||
32 | Input Data | ||
Downstream data (32 bytes) | |||
byte number | Functions | Meaning | Address range |
1 | control word | Bit0: Enable | 1 byte |
Bit1: Clear status word | |||
Bit2: Clear Receive data | |||
2 | Transmit Data Length | .. 255 | 1 byte |
3 | Count clear | Bit0: Receive error Count clear | 1 byte |
Bit1: Receive data Count clear | |||
Bit2: Receive data length clear | |||
4 | Error code clear | Bit0: Length error clear | 1 byte |
Bit1: CRC error clear | |||
Bit2: Timeout error clear | |||
5 | Output Data | Serial Communication module output data | Last 28 bytes |
6 | Output Data | ||
… | ... | ||
32 | Output Data | ||
The above describes how to edit Modbus messages in the program for the serial communication module XB6S-C01SP in Freeport mode. Thank you for watching!