Share this

Software Development for Remote Communication of Multifunctional Power Meters Based on MODBUS Fieldbus Technology

2026-04-06 05:09:47 · · #1

I. Introduction In traditional power systems, various instruments (such as electricity meters, ammeters, voltmeters, etc.) are often installed in high and low voltage distribution cabinets to monitor the power system. In large factories, there are often many instruments, requiring a dedicated person to periodically inspect all instrument points within the factory area with paper and pen, record all the data, and bring it back to the office for data analysis and processing.
With the development of computer science and technology, computers are increasingly widely used in the field of power monitoring. Replacing mechanical power meters with multifunctional intelligent power meters is an inevitable trend in industrial automation. Multifunctional meters not only offer multiple uses, but also typically allow for programming and data acquisition through their communication interfaces. Therefore, using multifunctional power meters can significantly reduce labor and greatly improve efficiency. However, monitoring multifunctional power meters is relatively limited in functionality, and the configuration software available is expensive. This paper uses the MSComm control to control the serial port, enabling remote reading of power data from the multifunctional power meters of Changjiang Sfield Power Meter Company, thus achieving the software design. The MSComm control is an extension control provided by Microsoft to support VB programs accessing serial ports. This control "hides" most of the underlying serial communication process and many cumbersome processing steps, while supporting query methods and event-driven communication mechanisms. Therefore, implementing microcomputer serial port data communication with it is quite simple, requiring minimal program code for easy serial port access and data communication.
II. Analysis of MODBUS Communication Protocol:
Since the CD194E series multi-functional power meters of Jiangyin Changjiang Sfield Electric Instrument Co., Ltd. use a remote RS-485 digital interface (differential, half-duplex) and the MODBUS-RTU communication protocol to realize functions such as instrument programming and data acquisition, the MODBUS protocol will be introduced first:
The MODBUS protocol is a master-slave point-to-point communication protocol that allows data communication between one master and multiple slave devices. In the CD194E series multi-functional power meter communication system, the master is a microcomputer (PC, industrial computer, PLC), and the slaves are CD194E series meters. This communication system allows for the connection of up to 128 meters and a communication distance of 1200 meters. The communication method uses a master-request, slave-response approach. That is, the master issues a command request, the slave responds by receiving data and analyzing it, and if the data meets the communication protocol, the slave responds with data. Each frame of data in the master-slave communication contains the following information (hexadecimal):
Slave address, command word, information word, checksum. Slave address (1 byte): Slave device number. The master uses the slave address to identify the slave device for communication.
Command word (1 byte): Sets the communication content between the master and the slave.
Information word (N bytes): includes various data addresses, data lengths, and data information used in two-machine communication.
Checksum (2 bytes): Used to detect data communication errors, using CRC16 cyclic redundancy check.
Communication parameter settings: The instrument address (1-247), communication speed (4800 or 9600), and data format (1 start bit, 8 data bits, 1 stop bit, with selectable no parity, odd parity, and even parity) can be set via the programming keyboard on the instrument.
The network connection is shown in Figure 1:

Here, the author uses the I-7520 RS-232/485 conversion module from ICP D.C. (Taiwan). Commands sent by the main control computer are transmitted via the RS-232 serial communication port. This signal is converted to standard voltage and type by the RS-232/485 conversion module (module number I-7520) before being propagated over the 485 network. Upon receiving its own command, the multi-function power meter analyzes and controls the operation, finally sending the result to the 485 network. This signal is then converted again by the I-7520 and received by the computer's RS-232 serial communication port. The entire transmission and reception process is serial.
III. Software Design and Development

Note: The power data transmitted from the CD194E series multi-function power meter is stored in Byte1 to Byte4.
3. Communication steps:
(1) Add a communication control, namely the MSComm control. (2) Set the communication port number, namely the CommPort property; in this article, we use Com1.
(3) Set communication parameters. This refers to the Settings property. In this document, it is set to 9600,n,8,1. This means the communication speed is 9600, the data format is 1 start bit, 8 data bits, 1 stop bit, and no parity bit. Note that this must be consistent with the settings of the multi-function power meter; otherwise, communication will fail.
(4) Set other parameters. Add other attribute settings if necessary.
(5) Open the communication port. That is, set the PortOpen property to True.
(6) Send or read a string every 500 milliseconds. That is, send command 4 (read N bytes) to read the power parameters, using the Input and Output properties.
(7) After using the MSComm control, close the communication port.
4. Human-computer interface:

5. Program code:
API function declaration
Private Declare Function GetTickCount Lib "kernel32" () As Long
Click the "End Program" button
Private Sub CmdEnd_Click()
End
End Sub
Click the "Read Power" button
Private Sub CmdRead_Click()
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled, then
CmdRead.Caption = "Stop reading"
Else
CmdRead.Caption = "Reading electrical power"
End If
End Sub
'Program Initialization'
Private Sub Form_Load()
MSComm1.InputMode = comInputModeBinary
MSComm1.PortOpen = True
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim C4%, C5%, C6%, C7%
Dim Tick&
Dim Data As Double
Dim Buf() As Byte
Dim ByteOut(7) As Byte
MSComm1.InputLen = 0
Buf = MSComm1.Input
'Redefine data input buffer, send command 4'

MSComm1.InputLen = 1
ByteOut(0) = &H1
ByteOut(1) = &H4
ByteOut(2) = &H0
ByteOut(3) = &H5C
ByteOut(4) = &H0
ByteOut(5) = &H4
ByteOut(6) = &H31
ByteOut(7) = &HDB
MSComm1.Output = ByteOut(0) & ByteOut(1) & ByteOut(2) & ByteOut(3) & ByteOut(4) & ByteOut(5) &
ByteOut(6) & ByteOut(7)
'Waiting for data from the multifunction power meter to arrive at the serial port'
Tick ​​= GetTickCount()
Do
If (GetTickCount() - Tick) / 1000# > 10 Then
MsgBox "Timeout too long, please check the multifunction power meter and transmission status!", vbCritical + vbOKOnly, "System Information"
Exit Sub
End If
DoEvents
Loop Until MSComm1.InBuFFerCount >= 9
Read data from the input buffer
Buf = MSComm1.Input
If Buf(0) <> 1, then
MsgBox "Address error!", vbCritical + vbOKOnly, "System Information"
Exit Sub
End If
Buf = MSComm1.Input
If Buf(0) <> 4 Then
MsgBox "Length error!", vbCritical + vbOKOnly, "System Information"
Exit Sub
End If
Buf = MSComm1.Input
C4 = Buf(0)
Buf = MSComm1.Input
C5 = Buf(0)
Buf = MSComm1.Input
C6 = Buf(0)
Buf = MSComm1.Input
C7 = Buf(0)
Buf = MSComm1.Input
Buf = MSComm1.Input
Data = Power(C4, C5, C6, C7)
TxtPower.Text = CStr(Data)
End Sub
Custom power conversion function
Private Function Power (C4%, C5%, C6%, C7%)
Dim PowerExp As String, Mantissa As String
Dim ReadValue#
Dim ValueSign&
If ((C4 And &H80) / 2 ︿ 7) = True Then
ValueSign = -1
Else
ValueSign = 1
End If
PowerExp = CStr ((C4 And &H7F) * 2 + (C5 And &H80) / 2 ︿ 7)
Mantissa = CStr ((&H80 or C5) * 2 ︿ 16 + C6 * 2 ︿ 8 + C7)
ReadValue = ValueSign * 2 ︿ (Val (PowerExp) - 126) * Val (Mantissa) / (256 * 65536)
Power = ReadValue
End Function
IV. Conclusion This example is based on multiple experiments conducted by the author in the laboratory, which achieved the intended application effect. It has now been put into practical application in a factory in Jiangxi Province.
The greatest advantage of this control system is:
1. From a hardware perspective, a single conversion module can achieve remote monitoring and centralized management of the entire plant's power supply. This greatly improves efficiency and is very economical.
2. From a software perspective, serial port control technology is used directly, eliminating the need to write additional drivers. Developing application software using VB is very convenient and requires minimal programming effort.
References
1. Li Zhaoqing and Han Tao. Serial Port Technology, National Defense Industry Press, 2004.
2. Fan Yizhi. Visual Basic and RS-232 Serial Communication Control, Tsinghua University Press, 2002.
3. Fan Yizhi. Visual Basic and Distributed Monitoring Systems—RS232/485 Serial Communication, Tsinghua University Press, 2002.
4. User Manual of Jiangyin Changjiang Sfield Electric Instrument Co., Ltd.
5. Instruction manual for the 232/485 conversion module from ICP D.C. (Taiwan).

Read next

CATDOLL 126CM Laura

Height: 126cm Weight: 23kg Shoulder Width: 32cm Bust/Waist/Hip: 61/58/66cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22