Design of a fuel cell engine monitoring system based on VB
2026-04-06 06:22:52··#1
Abstract: This paper describes the development of a fuel cell engine on-board monitoring system software using Visual Basic 6.0, including the design of the dynamic main control interface, communication program, control program, and data storage program. The design principles and methods of the entire monitoring screen are described, the communication protocol and the workflow of the host computer monitoring program are detailed, and the implementation of the PID control algorithm in VB is explained to adjust various monitoring parameters such as stack temperature, pressure, and water level. Finally, the operation method of the historical data storage program is introduced. Practice has proven that the system has a user-friendly graphical interface, accurate and reliable data acquisition, simple operation, and is safe and stable. Keywords: VB; fuel cell engine; serial data communication; PID control Introduction To protect the Earth's environment, replacing internal combustion engines with fuel cells is the future trend of automobile development. The main difference between fuel cell vehicles and traditional vehicles lies in the replacement of the traditional internal combustion engine power system with a fuel cell power system. Clearly, the research on its engine system has become crucial for the development of fuel cell electric vehicles. Therefore, during the research and development process, it is necessary to monitor the various systems of the engine in real time, record various relevant experimental data, analyze its operating characteristics, provide a basis for the continuous improvement of engine control strategies, and evaluate the overall vehicle performance. Therefore, the development of fuel cell engine on-board control system has significant practical implications. Visual Basic 6.0 provides rich controls, which can facilitate the convenient and rapid development of the entire software program for fuel cell engine on-board system, achieving the goal of effectively monitoring various parameters on site. Simultaneously, the PID control algorithm in VB can also perform real-time tuning of various monitored parameters such as fuel cell water volume, temperature, and pressure. 1 Software Design of Fuel Cell On-board Monitoring System Visual Basic (VB) is one of the powerful development software series launched by Microsoft. It not only provides excellent interface design capabilities but also has strong functionality in microcomputer serial communication. Its serial communication control MSComm32.OCX comprehensively provides all protocols for data communication using RS-232. We can use different working methods to handle and solve all problems in the communication software design of the fuel cell on-board monitoring system. 1.1 Main Control Interface Design The design of the fuel cell main control interface is one of the key points of the entire host computer software design, directly affecting the monitoring efficiency of the engine system. Therefore, a clear and user-friendly interface design is an important prerequisite for the entire software development. The main control screen of the fuel cell on-board monitoring system developed using VB6.0 as the software platform is shown in Figure 1. This main interface allows for real-time monitoring of the operating status of the system's main equipment. This includes using different colors to indicate equipment start-up and shutdown, displaying key system operating parameters such as voltage, current, and pressure in text boxes, and using the Click event of the CommandButton control to send Boolean variables, thereby controlling the opening and closing of switches and valves. Simultaneously, various controls are added, images are imported, and their different attributes are set, achieving a visually appealing and practical effect. [align=center] Figure 1 Main screen of the fuel cell vehicle monitoring system[/align] 1.2 Communication Program Design The communication of the fuel cell engine vehicle monitoring system includes communication between the host computer and the slave computer. This mainly involves data transmission between the PC and the slave computer hardware via a serial cable, aiming to monitor the information collected from the industrial site in a timely and accurate manner. 1.2.1 Communication Protocol In the implementation of serial communication, the underlying layer provides strong support for communication operations, as well as the operating system and computer hardware. However, to achieve specific user functions, an application-based communication protocol must be defined in the software. During the development of the fuel cell serial data communication program, through long-term debugging and continuous summarization, a complete and reliable communication protocol was finally obtained. This protocol consists of three layers: 1. Physical Layer. This layer defines the electronic and electrical characteristics and the transmission of the raw bit stream on the physical link, providing a raw bit stream transmission channel; Serial communication port: RS-232 serial port; Hardware interface: TTL level output by the DSP is converted into an RS-232 signal by a dedicated integrated circuit; Baud rate: 9600; Character format: 8 data bits, 1 stop bit; Error check: No parity check. 2. Data Link Layer. This layer defines the data frame as the information transmission unit, using error checking and frame acknowledgment techniques to shield noise on the physical path, making the transmission channel a reliable channel; the data link layer provides sufficient information for accurate data communication. Table 1 describes the structure of the device's data packet transmission. Table 1 Data Packet Transmission Structure LENGTH—Total number of data packet bytes; TYPE—Command type. Divided into system type (0X00), specific type (0X11, 0X13, 0X15, 0X16, 0X17, 0X18, 0X1A, 0X1B), and multi-protocol type (0X14); CMD—command ID number. Determines whether the command type is command information or response information; DATA—data byte length determined by CMD; CHKSUM—checksum code. Cyclic redundancy check is a commonly used checksum. 3. Application Layer. Responsible for establishing connection relationships between communication partners, realizing operation synchronization, alarm and data integrity management tasks. The following functions are provided to users and user programs: (1) Select and control multiple lower-level machines to track the sampling site information in real time or at appropriate times, send the data to the database for storage, the database stores data for a certain period of time, and the program has functions such as secondary processing of data, drawing curves and alarms; (2) Set sampling parameters; (3) When the communication line is interrupted or communication fails, send alarm information to the lower-level machine; 1.2.2 Upper-level machine workflow The upper-level machine software of the fuel cell engine vehicle monitoring system is divided into manual program and automatic program. The automatic program is the final version of the communication program design. Once it enters the power-on working state, it can automatically complete the monitoring function of the lower-level machine, including sending and receiving information. ('******** is the comment part) (1) Sending information program segment. Its workflow is shown in Figure 2 below. A simple code example is as follows: Private Sub Cmdstop_Click() '**** ... Its workflow is shown in Figure 3 below, and a simple code example is as follows: Private Sub MSComm1_OnComm() '*** Data reception Dim buf() As Variant Dim buf1(1 To 2) As Byte buf = MSComm1.Input '*** Data is received through the Input property of MSComm buf1(1) = buf(0) buf1(2) = buf(1) Text1.Text = buf1(2) * 256 + buf1(1) End Sub [align=center] Figure 2 Flowchart of upper computer sending information Figure 3 Flowchart of upper computer receiving information[/align] 2 Control program design PID control is an abbreviation for proportional, integral, and derivative control. It has the characteristics of simple principle, convenient use, wide applicability and strong robustness, and has a strong vitality in the field of industrial control. Changing P can improve response speed and reduce static error, but too much P will increase overshoot and settling time. I has a similar effect to P, but to achieve zero static error, integration is necessary. D has the opposite effect to P and I, primarily reducing overshoot and settling time. In simulations and experiments, if the structure and parameters of the controlled object are not fully understood, or an accurate mathematical model is unavailable, and other conventional control methods are difficult to implement, the structure and parameters of the system controller must be determined through experience and on-site debugging. PID control is the most convenient approach in this case. Currently, we do not have a thorough understanding of fuel cell stack models and cannot obtain system parameters through effective testing methods. Therefore, incremental PID control is more suitable. In VB, incremental PID control is implemented by defining a custom function and calling that function. Custom Function: Public Function PID(ByVal P As Single, I As Single, D As Single, PIDset As Single, PIDreturn As Single, DeltaPIDpre_1 As Single, DeltaPIDpre_2 As Single) As Single '********Incremental PID Calculation Custom Function************' '**P—PID proportional coefficient; I—PID integral coefficient; D—PID derivative coefficient' '**PIDset—PID setpoint' '**PIDreturn—PID feedback value' '**DeltaPIDpre_1—PID deviation value' '**DeltaPIDpre_2—PID deviation value' Dim PIDout As Single '**PID output value** Dim DeltaPID As Single '**PID deviation value, an intermediate variable** DeltaPID = PIDset - PIDreturn PIDout = P * (DeltaPID - DeltaPIDpre_1) + I * DeltaPID + D * (DeltaPID - 2 * DeltaPIDpre_1 + DeltaPIDpre_2) DeltaPIDpre_2 = DeltaPIDpre_1 DeltaPIDpre_1 = DeltaPID End Function To perform PID regulation on the input control quantity, simply call the above function. For example, when controlling the input temperature of the fuel cell stack, the above function is called as follows: Private Sub MSComm1_OnComm() '******* Data reception********** Dim Mid As Single Mid = Format(Round((buf1(5) * 256 + buf1(4) - 4095 / 5) * 125 / 4095, 2), "0.0") '***** Input fuel cell stack temperature***** Text1.Text = Mid + PID(outTP, outTI, outTD, outTPIDset, outTPIDreturn, outTDeltaPIDpre_1, outTDeltaPIDpre_2) '**********outTP——Temperature P, outTI——Temperature I, outTD——Temperature D, outTPIDset——Temperature setting, outTPIDreturn——Temperature, outTDeltaPIDpre_1——Temperature pre-value, outTDeltaPIDpre_2——Temperature value End Sub 3 Data storage programming VB language provides a variety of methods to manipulate the database. Using the Ado Data control to access the database is a very common manipulation method. By setting and manipulating its properties, a connection to the database can be achieved. By binding the data-aware control, an interface for accessing the database can be provided for browsing, adding, deleting, modifying and other operations on the database data. The whole process is very simple and convenient to implement and operate. The specific connection steps are as follows: (1) Create an Access database (2) Reference the Ado Data control and the data-aware control DataGrid (3) Set the three important properties of the Ado Data control, ConnectionString, CommandType, and RecordSource, as well as the DataSource property of the DataGrid control. At the end of setting the ConnectionString property of the Ado Data control, a "Test Connection" button will appear. By clicking this button, you can clearly understand whether the database connection is successful or not. It is very simple and convenient. The specific program writing format is as follows: `Database screen name.Adodc1.Recordset.AddNew` `Database screen name.Adodc1.Recordset.Fields("Date") = Date` `Database screen name.Adodc1.Recordset.Fields("Time") = Format(Now, "h:mm:ss")` `Database screen name.Adodc1.Recordset.Fields("Parameter name") = Received parameter data` `Database screen name.Adodc1.Recordset.Update` Special attention needs to be paid to the following in the database design: 1. The names, types, order of appearance, and formats of all parameters defined in the Access database must be completely consistent with the "parameter names" in the code. 2. When setting the ConnectionString property of the ADO Data control, the correct database path must be selected. 4. Conclusion On-site debugging shows that this vehicle-mounted monitoring system can work stably for a long time and has strong anti-interference capabilities, and can conveniently and effectively monitor various experimental data on site. Its database management operations also have great flexibility and control. The author's innovations are: 1. Implementation of PID control algorithm in VB to adjust various monitoring parameters such as stack temperature, pressure, and water level; 2. Application of serial communication technology based on VB in fuel cell vehicle monitoring system. References [1] Ji Changpeng, Bao Jian Research on Automotive Engine Controller Based on CANBUS 2005 [2] Wang Wendong, Chen Shi, Wu Feng The Influence of Temperature, Pressure and Humidity on the Performance of Proton Exchange Membrane Fuel Cell Energy Research and Information Vol.19 No.1 2003 [3] Zhang Yonghong, Hu Dejin Application of Serial Communication Technology Based on Visual Basic in Automation Monitoring System Combined Machine Tools and Automated Processing Technology 2003 No.10 [4] Xia Linmin, Hu Renjie Guarantee of Data Correctness in Serial Communication Electronic Engineer 2000 No.11 [5] Song Juan, Luo Zhiping, Quan Shuhai Fuel Cell Laboratory Configuration King Monitoring System Based on PID Algorithm Microcomputer Information 2006 Vol.22 No.1-1 Page 28