Student Lounge

Sharing technical and real-life examples of how students can use MATLAB and Simulink in their everyday projects #studentsuccess

Improve a Car’s Engine Performance

For today’s post Roberto Valenti will provide details about the project implemented by MathWorks’ new Excellence in Innovation Program team. 

In the MATLAB and Simulink Design Projects for Students Everywhere blog we introduced the MathWorks Excellence in Innovation program and how we collaborated with Professor Shayne McConomy from the Mechanical Engineering Department of the Florida Agricultural and Mechanical University – Florida State University (FAMU-FSU) College of Engineering to pilot the program. As a result, a team of students from Professor McConomy’s senior design class selected and worked on an automotive project from the GitHub list. In this blog we provide details on the project and the solution the team has implemented.  

The team, composed of four senior students: Austin LaFever, Patrick H. Marlatt, Frederick Peterson, and Jonathan Wozny, (pictures of the students in Figure 1worked on an automotive project, named MIMO Engine Airpath Control, with the objective to design and implement a torque control to improve a car’s engine performance using a Multi Input Multi Output (MIMO) approach.  

The challenging project gave the students the opportunity to gain knowledge on a car’s powertrain system, modeling and simulation, system identification, and an advanced control approach such as the increasingly popular model predictive control. Moreover, throughout the project they had the chance to apply industry relevant tools for real world applications building the base of their career in the automotive industry!  


Internal combustion engines will continue to be used in the automotive marketplace well into the future. However, engine performance, fuel economy, and emissions must continually be improved to keep them viable relative to more expensive full electric power sources. For example, modern gasoline and diesel engines use direct fuel injection which can result in particulate matter emissions at low engine loads with particles small enough to enter the human bloodstream directly through the lungs, so control of particulates is a major area of focus in diesel and gasoline engine control design today. Transient air-fuel ratio control is critical to the particulate matter problem. The ability to both estimate and control the airflow into the engine is at least half of the Air-Fuel Ratio (AFR) control problem that is critical to obtain good engine performance, fuel economy, and emissions. Since multiple actuators, e.g., throttle, wastegate, cam-phasers, Gas Re-circulation (EGR), affect the airflow into the engine, multi-input/multi-output (MIMO) control of engine airflow is a desirable way to improve engine airflow control and estimation performance that has yet to be implemented fully in the marketplace. 


Internal combustion engines rely on airflow through the engine from the outside environment in order to complete the combustion process and power the engine. Until now, internal combustion engines have relied on a single-input single-output (SISO) proportional-integral (PI) control approach developed decades ago. This approach manipulates the main components that control airflow into the engine using scheduled steady-state positions. During transient response, the output is not coordinated or optimal compared to steady-state operation, resulting in inefficient control of torque and emissions. Although effective steady state control is achievable, effective transient control with this method is not and therefore needs to be improved to keep up with increasingly competitive standards of engine performance and emissions. With the standard technique, throttle and wastegate are not coordinated to provide a boost or intake manifold pressure (MAP) trajectory that would result in good emissions and torque transient response. Our project goal was to design and implement a MIMO controller of the air system to produce coordinated and optimal control of the output values in both transient and steady-state conditions. This control approach will control the boost by controlling the throttle and wastegate. Boost will then be related to torque to create a desired torque response. 

We decided to follow the work described by GM in [1] and implementing a model predictive control (MPC) system for the air flow components, specifically the throttle and wastegate, to control transient and steady state torque and emissions effectively. 


In this project, the engine system has been simulated using the spark-ignition (SI) Engine Dynamometer in the MathWorks Powertrain Blockset™, shown in Figure 2 below. 

Figure 2 Engine Dynamometer Model

To model the system, the System Identification Toolbox in MATLAB was used to develop second order state-space models relating the throttle and wastegate to MAP separately using data acquired from the virtual engine simulation. Because the system is nonlinear, it can be linearized by creating models over a range of operating points (engine speeds and torque commands).

Data collection 

To create the MPC controllers, each controller will need a model at specific operating points to reference while making control calculations. To do this, simulations were run to collect input/output data for a range of engine speeds; the data for engine speed, throttle position, waste gate position, and MAP needed to be collected for each simulation. The data was simulated and collected in Simulink, and then processed in MATLAB. Two sets of data were collected at each operating point/engine speed, one set for system identification and the other for system validation. 


The modeling was performed by overriding the engine speed to hold the engine in steady state at a constant speed. The throttle and wastegate values in the controller were then overridden with a pseudo-random binary sequence (PRBS) sent into the throttle and wastegate values, essentially ’wiggling’ each actuator and then seeing how the intake manifold pressure (MAP) responded. When a PRBS signal was sent into the throttle, the wastegate position was held constant to see only the effect of the throttle and vice versa. In order to improve accuracy, we utilized a system called differential modeling, which detrended the data (’detrend’ command used for input/output data), then reduced the magnitude of the data to improve the system modeling. MPC works best in ‘differential control mode’. Differential modeling gets its name because it creates a model from the differences of the inputs/outputs; essentially the mean values of the inputs/outputs are subtracted from the measured input/output data to see the direct changes in the output made by changes in the input. The process reduced the value of the manifold pressure so that the midpoint of the values was zero.

Modeling Throttle

Figure 3: Throttle PRBS Signal and MAP Response at Engine Speed 5000 rpm

At small throttle angles the boost is sensitive, since a small change in its position would correlate to a large percent difference in air pressure in the manifold. MAP is also much easier to model and control at small throttle angles; as the percent position of the throttle increased, the system became much more difficult to model. To model the relationship between throttle and MAP, the wastegate was held completely open at 100% (no effect) and the throttle was ’wiggled’ at low values. Throttle values that provided suitable models were very low, less than ten percent. Figure 3 shows the data collected for the variables MAP, throttle position, wastegate position, and engine speed at one operating point.

Modeling Wastegate 

Figure 4: Wastegate PRBS Signal MAP Response at Engine Speed 5000 rpm

The modeling of the wastegate was done in a similar manner to the throttle. Wastegate is much more sensitive when closer to closed (more air to spin turbocharger and thus, more air entering the cylinders), for the same reason throttle is sensitive at small angles. To model the wastegate, a PRBS signal was sent to override the wastegate, and the throttle was held completely open at 100%. This was done to ensure only the wastegate would have an impact on the MAP response and create a wastegate-MAP model. Figure 4 shows the data collected for the variables MAP, throttle position, wastegate position, and engine speed. 

System Identification 

A black box modeling approach was used, putting the identification input and output data into MATLAB’s System Identification Toolbox. This was automated with scripts and the use of the n4sid command. To relate each input variable to the intake manifold pressure, only 2nd order models were required to produce accurate models.  

Model Validation  

To validate the states-spaces created with the identification data set, and a second validation set of data was then collected at the same parameters (different PRBS signal). The inputs of the second data set were input into the state-space, creating a ’best guess’ output from our system. This is referred to as the model or fitted output. The system output and the model output were then compared by plotting them against one another. The MATLAB compare function was used to return a number fit by returning a normalized root mean square error (NRMSE) value, shown in Equation 1, that returned fits. The aim was to have fits above 90%. 

 Where y  is the validation data output, yˆ is the system output, and  y− is the mean of y. Below are the fits for the throttle (Figure 5and the wastegate (Figure 6at one operating point.

Figure 5: Fitted Model for Throttle over Measured Boost Data at Engine Speed 5000rpm

Figure 6: Fitted Model for Wastegate over Measured Boost Data at Engine 5000 rpm

Results and Validation 

Figure 7: Throttle Control at Four Different Engine Speeds

Figure 7 shows the engine’s absolute manifold pressure (MAP) output (blue) that results from the throttle values controlled by the MPC, compared to the desired output (orange), which for this example was a sine wave. The state-space models used for these MPCS related throttle to MAP (note that it was not differential MAP). The operating points tested worked around four different engine speeds. From left to right on the plot, they are: 750 RPM, 1000 RPM, 2500 RPM and 5000 RPM. Even with the noise in the output of the 750 RPM section, the error across the system is only 1%, far lower than our goal of 1.75%. As the output follows the desired MAP, there is lag error present, but it is minimal. In between operating points 1000 RPM, 2500 RPM, and 5000 RPM, a spike in MAP can be observed. This is due to the RPM suddenly spiking and creating confusion for the MAP controller response. The MPCs controlling the throttle are not able to respond instantly, causing a very brief error as the throttle is adjusted. The error has little impact on the accuracy of our controller and can effectively be ignored. To implement differential boost control models into an MPC controller for testing, the mean boost value was subtracted from the boost command before entering the MPC, and the nominal actuator values were added to the resulting control commands for differential boost leaving the MPC to return the actual actuator positions required. A similar control approach was used for the wastegate and similar results were obtained.


To ensure this controller can be run on a real-world electronic control unit (ECU), we created a hardware-in-the-loop (HIL) system to run alongside the simulation. Figure 8 shows a picture of our final HIL system.  

The HIL system receives the simulated throttle and wastegate positions created by the MPC, using an Arduino Uno as the data acquisition and motor driver. The Arduino then commands a servo motor to move to the simulated angle, and an encoder measures that angle digitally. The protractor shown on the right of the image above will be used to visually check the throttle/wastegate angle. After the encoder measures the angle, the digital signal is sent back to MATLAB to override the simulated throttle/wastegate valve angle. If the MAP output is as expected, the HIL system has verified the control method can be applied to a real-world ECU. 

Figure 8: Hardware in the Loop system: The system is composed of an Arduino Uno served as motor drive and data acquisition, a servo motor as the planet, and encoder to measure the motor’s rotation angles. 


The final control system was able to accurately switch between MPCs under different operating ranges to control throttle position to produce a desired MAP command. Moreover, the system’s state-space utilizes differential MAP, throttle, and wastegate to return actuator values to achieve the desired MAP command in steady state with errors < 0.5%.  

The implemented controller can control throttle and wastegate individually, but not together to output a single matrix of improved throttle and wastegate positions. While we did not achieve a MIMO system, we established an excellent framework to continue expanding on the MPC control of this system, and are confident our work can be used as stepping stones for the continuation of this research  

A quote from the students: 

“We were intrigued to expand our knowledge of MathWorks tools and learn practical applications of coding software. Our team is very interested in cars and how to optimize their engine performance, specifically as it relates to emissions and this project was very much aligned with our interests and our studies. ​This project had a large learning curve but was a very fun and a super useful learning experience!” 

So, what do you think?  Does this list inspire you?  Are you looking for different types of projects?  Tell us what you think in the comments below. We’d love to hear from you.  


[1] Bemporad, A., Bernardini, D., Long, R., and Verdejo, J., “Model Predictive Control of Turbocharged Gasoline Engines for Mass Production,” SAE Technical Paper 2018- 01-0875, 2018, doi:10.4271/2018-01-0875.



  • print
  • send email


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.