A Real-Time Simulation of an Internal Combustion Engine

A Real-Time Simulation of an Internal Combustion Engine

8b-032 Copyright © 1996 IFAC 13th Triennial World Congress, San Francisco, USA A REAL-TIME SIMULATION OF AN INTERNAL COMBUSTION ENGINE M. Thomhill,...

799KB Sizes 82 Downloads 95 Views

8b-032

Copyright © 1996 IFAC 13th Triennial World Congress, San Francisco, USA

A REAL-TIME SIMULATION OF AN INTERNAL COMBUSTION ENGINE

M. Thomhill, S. Thomp80n, P. O'Reilly, C. Gong.

Department a/Mechanical and Industrial Engineering, Queen's University a/Belfast.

Abstract: A real-time simulation method for control studies is developed using transputer hardware and ANSI C software. The simulation method incorporates a quasi analogue library of mathematical blocks that can be joined together to create the appropriate model, real-time behaviour is guaranteed by a variable step size integration algorithm. The feasibility of this approach is demonstrated by simulation of an internal combustion engine. A comparison of simulator and experimental data shows the reliability of the simulation method Keywords: IC engine model, Transputer, Simulation, Real-time, Computer science.

l. INTRODUCTION In the past 20 years much work has been performed in the area of modelling engines particularly for improved AFR control (WU et al, 1984, Hendricks et al, 1991). Most of these control papers use simulations of I. C. engines for control tests (Moskwa and Hedrick, 1989, Hrovat and Powers, 1990), however when controllers are actually implemented on engines a poor correlation exists between the simulator and engine results. This is demonstrated for example by Cho and Hedrick (1988) who achieved excellent sliding mode control of AFR on a simulated IC engine, however on an engine (Cho and Oh, 1993) the algorithm does not perform quite so well. Since there may be many reasons why the experimental and simulation results are in disagreement, it would be useful to have an intermediate step closer to the experiment. Ideally all engine management algorithms should be tested experimentally, however capital costs and running costs of an engine test cell, along with the length of time required to test control algorithms make this choice unattractive. This paper presents a method of closing the gap between

simulation of an engine and actual engine operation by simulation in real-time. Many commercial packages exist for creating real-time code from block diagram simulations. (e.g. Matlab/SimulinklReal-Time Workshop). This paper presents an alternative transputer based real-time modelling method which uses a quasi-analogue library of mathematical blocks (Integrators, Summers etc.) which can be connected together in software and hardware to form the desired model. This method allows total control of what mathematical algorithms, what inputs and what outputs are used in the model. A real-time I.C. engine model is presented demonstrating the ease of use and power of this simulation method.

1.1

Parallel Processing

Parallel processing is used less commonly than serial processing, and, in the past, was expensive and complicated to utilise efficiently. It involves a number of processing elements (PEs), with the programming tasks being divided among them. In this way the computational

7772

7773

Although the problem of simulation on transputers could be approached in standard fashion by splitting the task into 5 serial sections and running each on a separate processor, the technique used was based on a novel idea, involving 'the simulation of a hybrid computer using transputers. Processes simulating the action of common analogue elements are included in a library and may be run in parallel on one or more processor. Being based on the idea of CSP, Inmos ANSI C allows processes to be written which input data on channels, operate on it, and output the results on a channel. This is analogous to an actual analogue element which inputs voltages on links, operates on them, and outputs on another link. The flexibility of this quasi-hybrid approach allows other processes to be written to carry out non-linear operations. This was one of the motivations for using the ANSI C toolset, as many neural network and fuzzy logic packages create C code as an output. This C code could then be included vel)' naturally in the overall engine model to represent nonlinear blocks that are difficult to model. Theoretically, any non-linear computation carried out by computer could be used, but in practice certain operations require excessive computation. This is the case with the engine model, where the operation of raising to a power (see throttle body equations) must be replaced by a look-up table for the function if the transputers are to operate efficiently. A variable step size integration algorithm which uses the predictor part of the Adams-Bashforth predictor-corrector algorithm guarantees real-time behaviour. Figure 2 shows diagramatically a first order lag with time constant 't, each block being a separate, quasi-analo~e procedure, The following code shows how a summmg block might be coded in parallel ANSI C. void sum proc(Process *p, Channel *in1, Channel -*in2, Channel *in3, Channel *out) {

float value1=O.Of, value2=O.Of, value3=O.Of, result; /* variables */

Fig. 2:

output result on channel */ }

return; }

Similar blocks were coded for integration, multiplication, multiplexiog, de-multiplexing, nodes and any non-linear functions that were required in the simulator. The procedures are gathered into Five ANSI C files, each requiring roughly equivalent computational effort. These are allocated to a transputer using a configuration file which specifies the target processors for pieces of code and the communications between each processor. The processors are automatically synchronised by the communication between them, Once this has been done, the program can be compiled and run, providing true parallel operation, Initially the simulation was run without external 110 and compared to an existing Simulink version of the model. The results of the two methods were compared, and the results showed an RMS difference between the two of less than 3% for a wide range of operating conditions. This proves the accuracy of the simulation procedure in this case. After full tests on the simulation, the analogue 110 converter was added to complete the system.

Declare

while(TRUE) {

result=O.Of; ChanIn(in1, &value1, sizeof(float); /* Input values on channels */ ChanIn(in2, &value2, sizeof(float)); ChanIn(in3, &value3, sizeof(float)); result=valuel+value2+value3; /* Sum values */ ChanOut(out, &result, sizeof(float)); /*

Analogue circuit for a first order lag implementation with input ein, output eoul. and time constant 't

2. INTERNAL COMBUSTION ENGINE MODEL This section details the model equations. Other models are available in the literature but this particular model was validated in-house. Figure 3 shows the model subsystems. In this instance the available transputer hardware was one of the factors determining model complexity. Also, given the groups continuing work with mean valued engine models, this was the adopted modelling approach. A mean valued, or phenomenological, model is a lumped parameter model which describes the engine's time averaged behaviour. For control studies, a mean value model is

7774

7775

7776

7777