Design of a Modem Distributed Remote Monitoring System Based on VC
2026-04-06 09:06:24··#1
Abstract: To address the problem of difficult operation of photovoltaic power plants in remote areas, this paper designs a system for remote monitoring using VC-developed modem communication . The system is designed with a distributed structure, enabling real-time monitoring of multiple power plants. Practice has proven that the system is economical, stable, and easy to operate. Keywords: VC; Modem; Remote monitoring; Single-chip microcomputer; Serial communication; Photovoltaic plant 1 Introduction Currently, solar photovoltaic power generation technology is becoming increasingly mature. It is one of the most sustainable renewable energy technologies. By 2004, the application of solar photovoltaic power generation had spread to all aspects of our lives, such as transportation, communication, public facilities (such as lighting), and household electricity. Especially in remote areas, solar photovoltaic power generation has shown its advantages. However, due to the characteristics of the power supply system being scattered and having long transmission distances, coupled with the harsh natural environment in remote areas, the daily maintenance of the system will consume a lot of manpower and resources as solar power becomes more widespread in these areas [1]. In response to this problem, this paper designs a distributed remote monitoring system for photovoltaic power stations based on VC and Modem. 2 System Composition and Working Principle For most distributed control systems, the lower-level machine is usually a single-chip microcomputer system. In order to realize the centralized monitoring, control and management of the PC, the information of the lower-level machine needs to be transmitted to the central management PC. There are many forms of information exchange between the PC and the single-chip microcomputer. Using a MODEM to realize remote data transmission through telephone lines is a flexible, convenient and economical solution. Therefore, this paper adopts this method. The system consists of a PC and multiple Modems to realize remote monitoring of multiple photovoltaic power station single-chip microcomputer controllers through a program-controlled switching network. The system block diagram is shown in Figure 1. The computer in the monitoring center and each microcontroller controller at the remote end are connected to the modem via RS-232 serial port and then connected to the program-controlled exchange network. The acquisition and processing of on-site data of the photovoltaic power station are accomplished by the cost-effective and easy-to-use 89C51 microcontroller [2], including A/D analog-to-digital conversion circuit, I/O interface circuit, RS232 communication circuit, LCD display circuit, keyboard setting circuit, watchdog circuit, etc. The PC in the monitoring center is designed with a user-friendly interface. When it is necessary to monitor the operation status of the photovoltaic power station, the PC first sends a dialing command to the modem through the serial port, dials the telephone number of the corresponding power station, and establishes a handshake connection with the microcontroller controller. After the connection is successful, the two can exchange data through the telephone line, including the acquisition of power station operating parameters, such as battery voltage, battery temperature, charging current, ambient temperature, wind speed, light intensity, etc., as well as control instructions for the power station microcontroller controller. The PC can display and print the received power station operating data in real time and perform further processing. [align=center] Figure 1 System block diagram[/align] 3 Modem communication Modem communication is a communication method that uses the existing telephone network to realize long-distance communication between computers. The telephone network is designed for transmitting analog signals, while the information processed by computers and microcontrollers is digital signals. Therefore, when computers and microcontrollers want to transmit data through the telephone network, the transmitting end first modulates the digital signal to convert it into an analog signal. At the receiving end, there is also a demodulation device to restore the analog signal to a digital signal. The modem is the device that performs this function. Like other communication standards, modem communication also has its own set of rules and standards. The AT commands formulated by Hayes are equivalent to the de facto industry standard[3]. Almost all modems support Hayes' AT commands. The AT commands used in remote control are mainly as follows: (1) ATDTn The modem uses audio dialing, where n is the telephone number. (2) ATS0=r The modem automatically answers the call. After receiving the r ringtone, the modem automatically picks up the phone and attempts to connect. (3) +++ The modem switches from online status to online command status. (4) ATHn Modem hang-up/off-hook command, 0: hang-up; 1: off-hook. In order to monitor the execution of the command and the line status of the telephone, the Modem will return a result code after receiving the AT command. The result code can be in the form of character or numerical type. When the Modem is working, except for the short time occupied by dialing, it is always in one of the following states: offline command state, online command state, and online data state. When the Modem starts up, it is first in the command state, and then enters the online state after the connection is established. In the command state, the Modem accepts commands in the form of AT commands, such as instructing the Modem to dial or automatically answer when the telephone rings. In the online state, the Modem communicates with the remote system. The switching of these states of the Modem at this time is shown in Figure 2 [4]. [align=center]Figure 2 Modem State Transition Diagram[/align] In the design of this system, we use the Jinlang Company's Popular II standard external 56K modem. Like most external modems, it provides a standard RS-232 interface, so the modem connected to the PC can be directly connected via the serial port. However, the microcontroller's serial port is TTL level, so level conversion is required when connecting it to the modem. Here, we use the MAX232 chip, and the connection diagram is shown in Figure 3. Although the 89C51 has serial input and output ports, it does not have standard interface handshake signal lines such as RTS, CTS, and DTR. Considering that the communication volume between the microcontroller and the host computer is not large, a simple "three-wire system" is used for connection, that is, only TXD, RXD, and ground GND are connected. Other signals are ignored when sending AT commands during modem initialization. [align=center] Figure 3 Modem and Microcontroller Communication Interface Circuit[/align] 4 Serial Communication Based on VC Among the many development tools, VC has become the preferred development language for developing remote communication control due to its powerful serial communication and data processing functions. Currently, there are several common methods for completing serial communication in the Windows environment: (1) Using Windows API communication functions. (2) Using VC's standard communication functions _inp, _inpw, _inpd, _outpw, _outpd, etc., to directly operate the serial port. (3) Using existing ActiveX controls, i.e., the MSComm control. (4) Using a third-party communication class, i.e., the CSerial class. The first method is more widely used, but it is more complex, requires a higher degree of specialization, and is difficult to use; the second method requires understanding the hardware circuit structure and principles. In this system, we adopt the third method. The MSComm control is an ActiveX control provided by Microsoft that can realize serial communication. It has complete serial port data receiving and sending functions and has many properties. It shields the low-level operation in the communication process. You only need to set and monitor the properties and events of the control to complete the initialization of the serial port and the sending and receiving of data. The MSComm control provides two methods for handling communication problems: one is the event-driven method and the other is the polling method [3]. Among them, the event-driven method has timely response and high reliability, and is suitable for more complex serial communication. This system design adopts this method. 5 Software Design 5.1 Initialization Program Design The initialization program mainly completes the initialization of the serial port and the modem. First, a variable is defined for the MSComm control: CMSComm m_ctrlComm. The corresponding program is as follows: BOOL CModemDlg::OnInitDialog() { …… if (m_ctrlComm.GetPortOpen()) m_ctrlComm.SetPortOpen(FALSE); m_ctrlComm.SetCommPort(1); // Select com1 if (!m_ctrlComm.GetPortOpen()) m_ctrlComm.SetPortOpen(TRUE); // Open the serial port else AfxMessageBox("Serial port 1 is occupied, please select another serial port"); m_ctrlComm.SetSettings("9600,n,8,1"); m_ctrlComm.SetInputMode(1); m_ctrlComm.SetRThreshold(1); m_ctrlComm.SetInputLen(); m_ctrlComm.GetInput(); CString strTemp; strTemp="ATZ0\r\n";//Modem software reset m_ctrlComm.SetOutput(COleVariant(strTemp)); strTemp="ATS0=1\r\n"; //Modem automatically waits for connection m_ctrlComm.SetOutput(COleVariant(strTemp)); strTemp="AT&D0&S0&R1\r\n"; //Simplify Modem control method m_ctrlComm.SetOutput(COleVariant(strTemp)); …… } 5.2 Dial-up Program Design void CModemDlg::OnDial() { CString strTemp; //Send command to Modem strTemp = "ATDT" + m_strPhoneNumber + "\r"+"\n"; // m_strPhoneNumber is the phone number. m_ctrlComm.SetOutput(COleVariant(strTemp)); } 5.3 Data Sending Program Design void CModemDlg::SendData(CString m_strSend) { char TxData[100]; int Count=m_strSend.GetLength(); for(int i=0; i TxData[i]=m_strSend.GetAt(i); CByteArray array; array.RemoveAll(); array.SetSize(Count); for(i=0; i array.SetAt(i,TxData[i]); m_ctrlComm.SetOutput(ColeVariant(array)); } 5.4 Data Receiving Program Design void CModemDlg::OnComm() { VARIANT variant_inp; COleSafeArray safearray_inp; LONG len,k; BYTE rxdata[2048]; // Set BYTE array CString strtemp; CString strshuzu[100]; if (m_ctrlComm.GetCommEvent() == 2) // Event value 2 indicates that there is a character in the receive buffer {variant_inp = m_ctrlComm.GetInput(); // Read buffer safearray_inp = variant_inp; // Convert VARIANT type variable to ColeSafeArray type variable len = safearray_inp.GetOneDimSize(); // Get the effective data length for (k = 0; k safearray_inp.GetElement(&k, rxdata + k); // Convert to BYTE type array for (k = 0; k {BYTE bt = *(char*)(rxdata + k); // Character type strtemp.Format("%02X ", bt); strshuzu[k] = strtemp; } ...//The received data is processed accordingly, such as real-time display of data, addition to the database, etc.} 6 Conclusion The experiment shows that the system has low design cost, stable and reliable operation, and can achieve the expected purpose of remote monitoring. It is of great significance to the further promotion and application of solar photovoltaic power generation technology in remote areas. The innovation of the author of this paper: In view of the characteristics of photovoltaic power stations, a scheme for remote monitoring using VC to control the modem is proposed. References: [1] Liu Fucai, Gao Xiuwei, et al. Design of single-chip intelligent controller for remote monitoring system of photovoltaic power station[J]. Computer Measurement and Control 2003, 11 (41): 270-272 [2] Zhang Yigang, Peng Xiyuan, et al. New MCS-51 single-chip microcomputer application design[M]. Harbin: Harbin Institute of Technology Press, 2003 [3] Li Xianyong. Visual C++ serial communication technology and engineering practice[M]. Beijing: People's Posts and Telecommunications Press, 2004 [4] Qiao Yi, Wang Chao, Tao Weiqing. Implementation of Modem Communication Based on MSCOMM Control. Microcomputer Information (Measurement and Control Automation), 2004, 20(7): 102-103