Share this

Serial communication between an industrial control computer and an intelligent flow totalizer based on VB6.0

2026-04-06 06:22:49 · · #1

1. Introduction

This article primarily utilizes the MSComm control and MODBUS protocol of VB6.0 to successfully implement serial communication between an industrial control computer and an intelligent digital flow totalizer with an RS-232 output interface in a flow control system. The D08-8CZM digital display meter is used to display the flow rate in the bottom-blown argon flow control system. The industrial control computer reads the displayed value as a feedback signal, thereby achieving closed-loop flow control.

2. D08-8CZM Intelligent Digital Flow Display Totalizer and Serial Communication

2.1 Hardware Configuration

The D07-12A mass flow sensor measures the mass flow rate of gas using the capillary heat transfer thermocalorimetry principle (no temperature or pressure compensation required). The flow signal measured by the sensor's heating bridge is amplified and then compared with a set voltage. The difference signal is amplified and used to control a regulating valve, creating a closed-loop control to ensure the flow rate through the channel matches the set flow rate. When this flow totalizer is used with an MFC (mass flow meter), simply connect the flow totalizer to the MFC using a cable via a D-type connector. Communication between a host computer and a D08-8CZM flow totalizer is achieved using RS232 communication: pin 2 (TXD) is connected to pin RXD (pin 2 of the industrial computer's serial port); pin 3 (RXD) is connected to pin TXD (pin 3 of the industrial computer's serial port); and pin 5 (SG) is connected to pin SG (pin 5 of the industrial computer's serial port).

2.2 Communication Principles

The industrial control computer (ICC) acts as the host computer, communicating with the slave devices (digital flow totalizers) using a master-slave response method. There is only one host computer (node ​​address 0) in a network, and the host computer distinguishes different slave devices by their station number (the unique address of the digital flow totalizer). The host computer is always in an active state, issuing read and write commands to the digital flow totalizer (communication port) as needed for program execution; the slave devices are in a passive state, receiving and responding to commands from the host computer. When sampling data needs to be read, the host computer sends a read data command to the specified digital flow totalizer via the communication port. The digital flow totalizer responds and prepares the data, encoding it into a response string according to a unified data communication frame format. The host computer can then read the required data from the communication port's receive buffer. When writing data to the digital flow totalizer, the host computer sends a write command and parameter data to the specified digital flow totalizer, which accepts and returns a response. The host computer performs remote monitoring, parameter setting, and diagnostics via RS-232 communication, employing different communication formats to achieve these functions. The MODBUS protocol communication principle diagram is as follows:

Figure 1. MODBUS protocol query-response loop

2.3 Communication Protocol

This communication protocol is used for communication between the D08-8CZM flow totalizer and the host computer. Data is transmitted in hexadecimal format with a baud rate of 9600, 8 data bits, 1 stop bit, and none parity bit. This protocol is compatible with the MODBUS protocol and allows the host computer to display the instantaneous flow rate, cumulative flow rate, full scale, unit, and valve status (including valve control, closure, and cleaning). Furthermore, the host computer can be used to set the instantaneous flow rate and reset the cumulative flow rate of the flow totalizer to zero. Therefore, this protocol utilizes MODBUS commands $03 (Reading 1-9 words), $05 (Force single coil), and $06 (Writing 1 word).

The current status of the flow totalizer can be read from the host computer using command $03. The specific format of its communication protocol is as follows:

host computer

Integrator: 01 03 00 02 00 08 E5 CC

Meaning of each byte:

01: MODBUS address;

03: Function code 03 (Reading 1-9 words);

00 02: Starting address, 00 is the high 8 bits, 02 is the low 8 bits;

00 08: Number of words read;

E5 CC: CRC check value, where E5 is the lower 8 bits of the CRC and CC is the higher 8 bits.

host computer

Integrator: 01 03 10 (1)~(16) CRCL CRCH

Meaning of each byte:

01: MODBUS address;

03: MODBUS command number;

10: Number of bytes uploaded;

(1)~(4): Instantaneous flow rate values;

"00~09" represents the numbers "0~9", and "10~19" represents "0.~9.";

(5)~(10): Cumulative flow rate;

Same as above;

(11)~(14): Full scale;

Same as above;

(15): Unit of flow rate;

00 represents SCCM and SCC, 01 represents SCCM and SL, and 11 represents SLM and SL;

(16): Valve status;

00 indicates closed, 80 indicates valve controlled, and FF indicates cleaning;

CRCL: The lower eight bits of the CRC;

CRCH: The high 8 bits of CRC.

3. Implement serial communication using VB.

3.1 MSComm Control

The MSComm communication control in VB provides all the functions of serial communication. It is simple and convenient to write and debug programs, and the development speed is fast. This control encapsulates the low-level operation program in the communication process. Users only need to set and monitor the properties and events of the control to easily realize asynchronous serial communication.

The MSComm control is used to receive data, and there are two methods: event-driven and timed polling. This example uses the timed polling method to accommodate real-time flow control. When the timer expires, read/write commands are sent to the flow totalizer at the specified address via the serial communication port. After the waiting time expires, the InBufferCount property value is checked to determine if the corresponding number of characters have been received in the input buffer, thus enabling operations such as reading, verifying data validity, storing data, and processing.

3.2 Programming Implementation of Communication Functions

The flowchart is as follows:

Figure 2 Serial communication program flowchart

Serial port initialization:

MSComm1.CommPort = 1

MSComm1.SThreshold = 1

MSComm1.Settings = 9600,N,8,1

MSComm1.InBufferSize = 1024

MSComm1.OutBufferSize = 1024

MSComm1.InputMode = comInputModeBinary

Open the serial port and periodically send data commands:

Private Sub Timer1_Timer()

Dim bytearray(0 To 7)

As Byte bytearray(0) = &H1

bytearray(1) = &H3

bytearray(2) = &H0

bytearray(3) = &H2

bytearray(4) = &H0

bytearray(5) = &H8

bytearray(6) = &HE5

bytearray(7) = &HCC

MSComm1.InputLen = 21

MSComm1.InBufferCount = 0

MSComm1.OutBufferCount = 0

MSComm1.RThreshold = 1

MSComm1.PortOpen = True

If MSComm1.PortOpen = True

Then MSComm1.Output = bytearray

End If End Sub

Accepted data:

Private Sub MSComm1_OnComm()

Do DoEvents Loop Until MSComm1.InBufferCount = 21 Dim dataread()

As Byte

Dim tempdata As Variant

Dim str As String

If MSComm1.CommEvent = comEvReceive

Then tempdata = MSComm1.InputReDim dataread(UBound(tempdata))

As Byte For i = 0 To UBound(tempdata)

dataread(i) = tempdata(i)

End Sub

Similarly, using the above flowchart and communication protocol, all the functions shown in the following diagram can be accomplished:

Figure 3. VB-based D08-8CZM type flow totalizer

4. Conclusion

By utilizing the MSComm control and MODBUS protocol in VB6.0, serial communication between an industrial control computer and an intelligent digital flow totalizer with an RS-232 output interface was implemented. This enabled the real-time acquisition of instantaneous flow rates and was successfully applied to a bottom-blown argon flow closed-loop control system. This communication method is flexible, convenient, simple in structure, and highly reliable, fully meeting the expected requirements and demonstrating good practical value and usability.

Read next

CATDOLL CATDOLL 115CM Purple Silicone Doll

Height: 115 Silicone Weight: 22kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: N/A Vaginal Depth: 3-15cm...

Articles 2026-02-22