Semi-physical simulation of diesel generator speed control

Publisher:中华古风Latest update time:2010-02-02 Source: 现代电子技术 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1 Introduction

The electronic speed governor is one of the key components of a diesel engine. When the actual diesel engine and its load performance change and do not match the governor design parameters, the diesel generator set will not work properly. At this time, the governor control parameters need to be modified. In addition, the electronic speed governor needs to be tested for performance before leaving the factory and after maintenance to set appropriate control parameters to meet its regulation performance. It is neither safe nor economical to directly perform parameter setting, performance testing, and performance recovery of the electronic speed governor on the diesel engine. Semi-physical simulation is an indispensable link before the governor is actually tested. The engineering idea is to establish a dynamic simulation model of the diesel generator set in the full working range, connect it to the electronic speed governor through the input and output interface circuit to form a closed-loop control system, and complete the relevant tests of the performance test of the electronic speed governor.

Simulink is good at building a simulation model of a diesel generator set. Since the semi-physical simulation system needs to connect to specific hardware devices, the simulation program needs to customize the human-machine interface to implement parameter settings and other functions. This part of the function is difficult to achieve for Simulink, and this is exactly the strength of Visual C++ (VC). The VC visual C++ programming environment has powerful hardware control functions and flexible and rich human-machine interface design functions. However, it is very difficult to directly use VC to build a simulation model of a diesel generator set.

To address this problem, this paper provides a method to smoothly transition from Simulink simulation model to Visual C++ integrated development environment. The specific implementation is to build a simulation model of diesel generator set in Simulink, then convert the Simulink simulation model into portable embedded C++ code through Matlab Real-Time Workshop (RTW), and finally integrate it with Visual C++ project file to form a completely independent real-time semi-physical simulation system.

2 Construction of diesel generator model and semi-physical simulation system structure

There are generally two ways to model diesel engines, one is mathematical mechanism modeling, and the other is experimental identification modeling. Mathematical mechanism modeling mainly starts from the original characteristics and structural parameters of each component of the diesel engine, and establishes a mechanism model based on the dynamic and thermodynamic relationship equations. The modeling workload is large, the calculation is complex, and it brings certain difficulties to the solution of the model. Experimental identification modeling is to establish a mathematical model of the diesel engine based on the test data of the diesel engine test bench using different mathematical fitting methods. For the study of electronic speed governor parameter setting and matching test, here we are concerned with the relationship between the external performance parameters of the diesel engine, and the thermal process inside the diesel engine can be ignored. As long as the diesel generator set simulation model can simulate the diesel engine and its load characteristics more realistically, the test results can more realistically reflect the actual matching performance of the electronic speed governor.

Therefore, the experimental identification modeling method is selected and the BP neural network is used to establish the diesel generator set model. As shown in Figure 1. The input and output signals of the semi-physical simulation system for speed control of the MTU396 diesel generator set are mainly of three types:

(1) Pulse width modulation (PWM) signal, i.e. the actuator rack drive signal;

(2) Frequency signal, i.e. the simulated diesel speed pulse signal;

(3) Switching signal, that is, various control signals for the electronic speed regulator, such as start, stop, speed increase and deceleration control, etc.

This system uses Advantech's PCI-1780 counter card, which provides 8 16-bit counter channels, 8 digital outputs and 8 digital inputs, which can meet the above requirements. See Figure 2.

3 Implementation of Semi-Physical Simulation System

3.1 Using RTW to generate portable C++ model code

RTW is an important supplementary function module of Matlab graphical modeling and simulation environment Simulink. In short, it is a code automatic generation environment based on Simulink. It can directly generate optimized and portable code from Simulink models to accelerate the simulation system development process and reduce R&D costs.

RTW can set certain parameters or signals in the Simulink model as global variables. When the executable code automatically generated by the model runs in the target system, it can easily interact with the Simulink model to achieve online parameter adjustment and signal communication. Using this function of RTW, the parameters or signals that need to be adjusted and monitored in the model can be set as global variables. These variables constitute the bridge for interaction between modules in the VC simulation program described later.

RTW supports multiple targets, so there are multiple options for RTW to automatically generate C++ model code. For VC, there are three targets to choose from: General Real-Time (GRT) target, General Real-Time Malloc (GRTM) target, and embedded target. The General Real-Time (GRT) target uses the real-time code format, and its memory allocation is statically declared at compile time. The General Real-Time Malloc (GRTM) target uses the real-time Malloc code format, which is very similar to the real-time code format. The main difference is that the real-time malloc code format declares memory dynamically. The embedded target can generate C++ code in the embedded code format, which is optimized in terms of running speed, memory usage, and simplification. The embedded code uses static memory allocation. This article chooses the embedded target to automatically generate embedded code.

The code automatically generated by RTW is divided into two parts: one is the model code; the other is the code run-time interface. These codes are divided into many source code files. In order to manage this huge project, RTW also automatically generates a make file for it. Use VC to open the make file and compile it, then copy all the source files referenced in this project from the Matlab installation directory and combine them with the model code to form the simulation model code.

3.2 Integration of model code and VC program

The process of integrating the model code with the VC program is relatively simple. Add all the source files involved in the simulation operation module in Section 3.1 to the VC program project. There are two points to note: After the source files of the simulation module are added to the VC program project, the precompiled header file option is applied by default. This setting must be manually canceled, otherwise the compilation will fail; in order to call the interface function of the simulation code in the VC program, a global declaration is required.

3.3 Further development and integration of simulation system in VC

Semi-physical simulation software generally consists of a human-machine interface module, a data acquisition module, a simulation operation module, and a data processing module. The principle of the semi-physical simulation system for speed control of an MTU396 diesel generator set is shown in Figure 3. The following is a brief introduction to the implementation process of each module.

(1) Implementation of human-machine interface module

The human-machine interface module constitutes the main thread of the VC program, which mainly completes the functions of real-time display of variables, online adjustment of parameters, control parameter setting and program operation control, and other modules are scheduled by it. The real-time variables involved in this system include diesel engine speed, gear displacement, diesel engine load, etc. The author has designed graphics elements such as tachometer, bar graph, trend curve, adjustment slider, function button, etc., and fully utilized the encapsulation and inheritance characteristics of object-oriented methods to realize the entire graphics library, thereby improving the modifiability, reusability and scalability of the software system.

(2) Implementation of data acquisition module

The data acquisition module exchanges data with the electronic speed governor through the PCI-1780 device card. The fuel supply signal of the electronic speed governor is transmitted to the simulation program in the form of pulse width modulation (PWM) by the PCI-1780 device card. The simulation program feeds back the speed of the diesel engine to the electronic speed governor in the form of a frequency signal through the PCI-1780 device card through simulation calculation. The data acquisition module is implemented by the device driver API function provided by the manufacturer.

(3) Implementation of simulation calculation module

The simulation operation module also needs to add simulation synchronization control based on the RTW conversion rhyme simulation model code to meet the real-time requirements of the simulation. The key to real-time performance is the accuracy of I/O data timing. As we all know, Windows is not a real-time operating system but a multi-tasking operating system. It is difficult to implement hardware interrupts in simulation programs compiled using VC. Using software timing is a more feasible method because today's computers are very fast and can meet the real-time requirements of general hardware in-loop simulation.

There are basically two ways to achieve precise timing in VC: ① Use multimedia timer. It uses a separate thread to call a special callback function with a high priority. The minimum timing interval is 1ms, which can meet the timing requirements of general real-time tasks. ② Use high-performance counter. In Windows 2000, high-resolution counters (high-resolution performance counters) are implemented by hardware, and high-precision timing intervals can be obtained by using it. Since the output frequency of the electronic speed regulator in this application is 80 Hz, this paper chooses multimedia timer to realize simulation control, and the timing interval is selected as 2 ms. That is, the multimedia timer calls the model code interface function rt_On-eStep (model single-step operation) in its callback function every 2 ms to ensure the advancement of the entire simulation and meet the real-time requirements of the system. The simulation operation module completes the real-time calculation of the model and is the core of the entire system.

(4) Implementation of data processing module

The data processing module completes the real-time recording and timed saving functions of the simulation data. In order to meet the real-time performance of data recording, the simulation program adopts multi-threading technology, and the data timed saving function is executed in an independent data saving thread. The synchronization between the data processing thread and the main thread is driven by event signals. Based on the C++ Standard Template Library (STL), the CPointsCollection class is created on the basis of the deque container to complete the real-time recording and timed saving of data. The strategy adopted is: CPointsCollection first opens two buffers in the memory. After the first buffer is full of data, the data begins to be stored in the second buffer, and then the main thread simultaneously notifies the data saving thread to save the data in the first buffer to the text file on the hard disk using the VC serialization function; after the second buffer is full of data, the data begins to be stored in the first buffer, and the main thread simultaneously notifies the data saving thread to save the data in the second buffer to the text file on the hard disk, so that the real-time performance of data recording is ensured in this way. In order to verify the effectiveness of the semi-physical simulation system developed by this method, the system is physically connected to the R082 electronic speed regulator for machine matching test. The simulation results show that the simulation system corresponds to the theoretical analysis results. Due to space limitations, the running interface during no-load start operation is given. As shown in Figure 4.

4 Conclusion

Combined with scientific research examples, this paper introduces in detail a method for rapid development of semi-physical simulation systems based on RTW and Visual C++. This method fully utilizes the advantages of Simulink and Visual C++. First, the simulation model of the system is established using the Simulink visual modeling method. Then, the Simulink simulation model is converted into a portable embedded C++ code through RTW. Finally, the flexible customizability and powerful interface function of Visual C++ are used to realize a completely independent real-time semi-physical simulation system. The simulation program can be easily debugged in the Visual C++ environment. Compared with traditional design methods, this method has the characteristics of low cost and high efficiency.

Reference address:Semi-physical simulation of diesel generator speed control

Previous article:Design of stepper motor control system based on TMC428
Next article:Motion control of a novel five-degree-of-freedom parallel robot based on BLDC

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号