Main Content

Model Engine Timing Using Triggered Subsystems

This example shows how to model a four-cylinder spark ignition internal combustion engine from the throttle to the crankshaft output using triggered subsystems. In this example, the sldemo_engine model is based on [1].

The sldemo_engine model uses the Triggered Subsystem blocks in the Valve Timing and Combustion subsystems. In this example, the tasks of all four cylinders are implemented with one set of blocks instead of four sets of blocks, one set per cylinder.

Open the model.

open_system('sldemo_engine')
Warning: Unrecognized function or variable 'CloneDetectionUI.internal.CloneDetectionPerspective.register'.

In an inline four-cylinder four-stroke engine, 180 degrees of crankshaft rotation separates the ignition of each successive cylinder. This separation means that each cylinder fires on every other crank revolution. In this model, the intake, compression, combustion, and exhaust strokes occur simultaneously (at any given time, one cylinder is in each phase). To account for compression, the combustion of each intake charge is delayed by 180 degrees of crank rotation from the end of the intake stroke.

In this model, an Integrator block accumulates the cylinder mass air flow in the Intake Manifold block located inside the Throttle and Manifold subsystem. The Valve Timing subsystem generates pulses that correspond to specific rotational positions to manage the crank angle, air-fuel mass and triggers execution of Compression subsystem. The Compression subsystem uses a Unit Delay block to insert 180 degree (one event period) of delay between the intake and combustion of each air-fuel charge.

Consider a complete four-stroke cycle for one cylinder. The following describes the functionality of each stroke.

  • Intake stroke - During this stroke, the intake manifold opens and takes in the air-fuel mixture. The piston moves from the top dead center (TDC) to the bottom dead center (BDC) and the crank shaft completes 180 degrees rotation. In this model, the Intake Manifold subsystem inside the Throttle and Manifold subsystem integrates the mass flow rate from the manifold.

  • Compression stroke - During this stroke, the intake manifold closes and the air-fuel charge is compressed by 180 degrees rotation of the crank shaft. The piston moves from BDC to TDC. Due to compression, the temperature of the air-fuel mixture increases which assists the combustion process.

  • Combustion stroke - The spark plug ignites the air-fuel mixture. Combustion of the mixture inside the cylinder generates pressure that forces the piston to move from TDC to BDC. During this stroke, the crank shaft rotates by 180 degrees and generates torque.

  • Exhaust stroke - During the exhaust stroke, the piston moves from BDC to TDC by 180 degrees rotation of the crank shaft. When the piston head reaches TDC, the exhaust manifold opens and let the exhaust out of the cylinder. In this model, the Integrator block inside the Throttle and Manifold subsystem is reset and prepared for the next cycle of four strokes (720 degrees) of this cylinder.

Valve Timing

The Valve Timing subsystem controls valve timing (opening and closing), triggers ignition, and resets the crank shaft angle based on the angular position of the engine crank shaft. The Valve Timing subsystem contains two Triggered subsystem blocks: Reset Crank Angle on Rising Edge and Reset Piston Air Mass on Falling Edge.

Reset Piston Air Mass on Falling Edge is triggered when the crankshaft moves from TDC to BDC, and transfers the air-fuel mixture from the intake manifold to the cylinders via discrete valve events. The transfer process takes place concurrently with the continuous-time processes of intake flow, torque generation, and acceleration.

Reset Crank Angle on Rising Edge is triggered once the crankshaft angle exceeds 180 degrees, and resets the angle to 0 degrees.

Valve Timing subsystem controls valve timing and resets crank angle

Compression

The Compression subsystem represents the engine dynamics during the compression stroke. This subsystem is triggered when it receives a positive trigger value at the Trigger port of the block. The Unit Delay block samples the integrator state. This value, the accumulated mass charge, is available at the output of the Compression subsystem for use during combustion.

Subsystem block that is triggered based on a positive ignition trigger

Throttle and Manifold

The throttle body of the engine is modeled by the Throttle and Manifold subsystem.

Throttle and Manifold subystem models the throttle body of the engine

Throttle

The Throttle subsystem uses throttle plate angle (θ), manifold pressure (Pm), and atmospheric pressure (Pamb) as inputs. The air-fuel mixture intake rate(m˙ai) at the intake manifold can be expressed as the product of two functions:

  • Empirical function of the throttle plate angle

  • Function of the atmospheric and manifold pressures

In cases of lower manifold pressure (greater vacuum), the flow rate through the throttle body is sonic and is only a function of the throttle angle. This model accounts for this low pressure behavior with a switching condition in the following compressibility equations.

Equation 1

m˙ai=f(θ)g(Pm)=mass flow rate into manifold (g/s)

f(θ)=2.821-0.05231θ+0.10299θ2-0.00063θ3

g(Pm)=1; if PmPamb/2

g(Pm)=2PambPmPamb-Pm2; if Pamb/2PmPamb

g(Pm)=-2PmPmPamb-Pamb2; if PambPm2Pamb

g(Pm)=-1; if Pm2Pamb

m˙aimass flow rate into manifold (g/s); 

θthrottle angle (deg);

Pmmanifold pressure (bar); 

Pambambient (atmospheric) pressure (bar);

The individual equations, mentioned above, are incorporated using Fcn blocks. A Switch block determines whether the flow is sonic by comparing the pressure ratio to its switch threshold. In the sonic regime, the flow rate is a function of the throttle position only. The direction of flow is from the higher to lower pressure, as determined by the Sign block. The MinMax block ensures that the pressure ratio is always unity or less.

Throttle Subsystem

Intake Manifold

The Throttle and Manifold subsystem contains the Intake Manifold subsystem. This subsystem uses the throttle flow input and engine speed (N) as inputs. The intake manifold is modeled as a differential equation for the manifold pressure (P˙m). The difference in the incoming and outgoing mass flow rates represents the net rate of change of air mass with respect to time. This quantity, according to the ideal gas law, is proportional to the time derivative of the manifold pressure.

However, unlike the model in [1], this model does not incorporate exhaust gas recirculation (EGR).

Equation 2

P˙m=RTVm(m˙ai-m˙ao)

Rspecific gas constant; 

Ttemperature (K); 

Vmmanifold volume (m3); 

m˙aomass flow rate of air out of the manifold (g/s); 

P˙mrate of change of manifold pressure (bar/s);

The mass flow rate of air-fuel mixture that the model pumps into the cylinders from the manifold is described in the following empirical equation. This mass rate (m˙ao) is a function of the manifold pressure (P˙m) and the engine speed (N).

Equation 3

m˙ao=-0.366+0.08979NPm-0.0337NPm2+0.0001N2Pm

Nengine angular speed (rad/s); 

Pmmanifold pressure (bar); 

To determine the total air-fuel mixture charge pumped into the cylinders, the simulation integrates the mass flow rate from the intake manifold and samples it at the end of each intake stroke event. This sampling determines the total air mass that is present in each cylinder after the intake stroke and before compression.

The Intake Manifold subsystem is used to model the throttle dynamics expressed in Equation 2. The differential equation from Equation 2 models the intake manifold pressure. A Simulink Function block computes the mass flow rate into the cylinder, a function of manifold pressure and engine speed, expressed in Equation 3.

Intake Manifold Subsystem

Combustion

Torque is generated during the combustion stroke. The Combustion subsystem models the combustion process and torque generation using four variables, expressed in Equation 4. The model uses a Mux block to combine these variables into a vector that provides input to the Fcn block that incorporates the Torqueeng equation.

Equation 4

N˙engine angular acceleration (rad/s2); 

mamass of air in cylinder for combustion (g); 

(AF)air to fuel ratio; 

σspark advance (degrees before top - dead - center); 

Torqueengtorque produced by the engine (Nm); 

Torqueeng=-181.3+379.36ma+21.91(AF)-0.85(AF)2+0.26σ-0.0028σ2+

+0.027N-0.000107N2+0.00048Nσ+2.55σma-0.05σ2ma

Combustion subsystem that models the combustion and torue generation process

Engine Dynamics

The Engine Dynamics subsystem computes the engine speed (N) and crank angle using the load torque Tload and the generated torque Teng. Tload is computed using step functions in the Drag Torque subsystem. Engine speed is computed using the equation JN˙=Torqueeng-Torqueload, where J is the engine rotational moment of inertia (kgm2).

Engine Dynamics subsystem computes crank angle and engine speed

Simulate the Model and Visualize the Results

Simulate the model and visualize the results using plot function.

sim('sldemo_engine'); 

The default input values are used for simulation:

Throttle=8.97 (deg) if t<5

Throttle=11.93 (deg) if t5

Load=25 (Nm) if t2 or t8

Load=20 (Nm) if 2<t8

Simulink® returns the simulated engine speed, the throttle commands that drive the simulation, and the load torque that disturbs it.

The model logs this data to the base workspace in a structure, sldemo_engine_output.

PlotHandle = plot(sldemo_engine_output.get('LoadTorque').Values.Time, ...
               sldemo_engine_output.get('LoadTorque').Values.Data, 'r', ...
               sldemo_engine_output.get('ThrottleAngle').Values.Time, ...
               sldemo_engine_output.get('ThrottleAngle').Values.Data, 'b'  );
title('Open-Loop Simulation Inputs: Load Torque and Throttle Angle vs Time');
xlabel('Time (sec)'); ylabel('Engine Speed (rad/sec)');
set(gca,'Color','w','XGrid','On','XColor',[0 0 0],...
                    'YGrid','On','YColor',[0 0 0]);
axis([0 10 5 30]);
h= legend('Load Torque (Nm)','Throttle Angle (deg)','Location','northeast');
set(h,'TextColor','k','Color','none'); 

Figure contains an axes object. The axes object with title Open-Loop Simulation Inputs: Load Torque and Throttle Angle vs Time, xlabel Time (sec), ylabel Engine Speed (rad/sec) contains 2 objects of type line. These objects represent Load Torque (Nm), Throttle Angle (deg).

PlotHandle = plot(sldemo_engine_output.get('EngineSpeed').Values.Time, ...
                  sldemo_engine_output.get('EngineSpeed').Values.Data,'b'  );
title('Open-Loop Simulation Results: Engine Speed Control');
xlabel('Time (sec)'); ylabel('Engine Speed (rad/sec)');
set(gca,'Color','w','XGrid','On','XColor',[0 0 0],...
                    'YGrid','On','YColor',[0 0 0]);
axis([0 10 1500 3500]);
h = legend('Engine Speed (rpm)','Location','northeast');
set(h,'TextColor','k','Color','none');

Figure contains an axes object. The axes object with title Open-Loop Simulation Results: Engine Speed Control, xlabel Time (sec), ylabel Engine Speed (rad/sec) contains an object of type line. This object represents Engine Speed (rpm).

See Also

| | | | | | |

Related Topics

References

[1] Crossley, P. R., and J. A. Cook. “A Nonlinear Engine Model for Drivetrain System Development.” International Conference on Control 1991. Control ’91 1991, pp. 921–25 vol.2. IEEE Xplore, DOI.org (Crossref), https://ieeexplore.ieee.org/abstract/document/98573.

[2] The Simulink Model. Developed by Ken Butts, Ford Motor Company. Modified by Paul Barnard, Ted Liefeld and Stan Quinn, MathWorks®, 1994 — 7."

[3] Moskwa, John J., and J. Karl Hedrick. “Automotive Engine Modeling for Real Time Control Application.” 1987 American Control Conference, 1987, pp. 341–46. IEEE Xplore, DOIː 10.23919/ACC.1987.4789343.

[4] Powell, B. K., and J. A. Cook. “Nonlinear Low Frequency Phenomenological Engine Modeling and Analysis.” 1987 American control conference, 1987, pp. 332–40. IEEE Xplore, DOIː 10.23919/ACC.1987.4789342.

[5] Weeks, Robert W., and John J. Moskwa. “Automotive Engine Modeling for Real-Time Control Using MATLAB/SIMULINK.” SAE transactions, vol. 104, 1995, pp. 295–309. JSTOR, https://www.jstor.org/stable/44473229.