Main Content

Explore the Hybrid Electric Vehicle P2 Reference Application

The hybrid electric vehicle (HEV) P2 reference application represents a full HEV model with an internal combustion engine, transmission, battery, motor, and associated powertrain control algorithms. Use the reference application for hardware-in-the-loop (HIL) testing, tradeoff analysis, and control parameter optimization of a HEV P2 hybrid. To create and open a working copy of the reference application project, enter

By default, the HEV P2 reference application is configured with:

  • Lithium-ion battery pack

  • Mapped electric motor

  • Mapped spark-ignition (SI) engine

This diagram shows the powertrain configuration.

This table describes the blocks and subsystems in the reference application, indicating which subsystems contain variants. To implement the model variants, the reference application uses variant subsystems.

Reference Application ElementDescriptionVariants

Analyze Power and Energy

Double-click Analyze Power and Energy to open a live script. Run the script to evaluate and report power and energy consumption at the component- and system-level. For more information about the live script, see Analyze Power and Energy.


Drive Cycle Source block — FTP75 (2474 seconds)

Generates a standard or user-specified drive cycle velocity versus time profile. Block output is the selected or specified vehicle longitudinal speed.

Environment subsystem

Creates environment variables, including road grade, wind velocity, and atmospheric temperature and pressure.

Longitudinal Driver subsystem

Uses the Longitudinal Driver or Open Loop variant to generate normalized acceleration and braking commands.

  • Longitudinal Driver variant implements a driver model that uses vehicle target and reference velocities.

  • Open Loop variant allows you to configure the acceleration, deceleration, gear, and clutch commands with constant or signal-based inputs.

Controllers subsystem

Implements a powertrain control module (PCM) containing a P2 hybrid control module (HCM), an engine control module (ECM), and a transmission control module (TCM).

Passenger Car subsystem

Implements a hybrid passenger car that contains drivetrain, electric plant, and engine subsystems.

Visualization subsystem

Displays vehicle-level performance, battery state of charge (SOC), fuel economy, and emission results that are useful for powertrain matching and component selection analysis.


Evaluate and Report Power and Energy

Double-click Analyze Power and Energy to open a live script. Run the script to evaluate and report power and energy consumption at the component- and system-level. For more information about the live script, see Analyze Power and Energy.

The script provides:

  • An overall energy summary that you can export to an Excel® spreadsheet.

  • Engine plant, electric plant, and drivetrain plant efficiencies, including an engine histogram of time spent at the different engine plant efficiencies.

  • Data logging so that you can use the Simulation Data Inspector to analyze the powertrain efficiency and energy transfer signals.

For more information about the live script, see Analyze Power and Energy.

Drive Cycle Source

The Drive Cycle Source block generates a target vehicle velocity for a selected or specified drive cycle. The reference application has these options.


Output sample time

Continuous (default)

Continuous operator commands


Discrete operator commands

Longitudinal Driver

The Longitudinal Driver subsystem generates normalized acceleration and braking commands. The reference application has these variants.

Block Variants


Longitudinal Driver (default)



PI control with tracking windup and feed-forward gains that are a function of vehicle velocity.


Optimal single-point preview (look ahead) control.


Proportional-integral (PI) control with tracking windup and feed-forward gains.

Low-pass filter (LPF)


Use an LPF on target velocity error for smoother driving.


Do not use a filter on velocity error.



Stateflow® chart models reverse, neutral, and drive gear shift scheduling.


Input gear, vehicle state, and velocity feedback generates acceleration and braking commands to track forward and reverse vehicle motion.


No transmission.


Stateflow chart models reverse, neutral, park, and N-speed gear shift scheduling.

Open Loop

Open-loop control subsystem. In the subsystem, you can configure the acceleration, deceleration, gear, and clutch commands with constant or signal-based inputs.

To idle the engine at the beginning of a drive cycle and simulate catalyst light-off before moving the vehicle with a pedal command, use the Longitudinal Driver variant. The Longitudinal Driver subsystem includes an ignition switch signal profile, IgSw. The engine controller uses the ignition switch signal to start both the engine and a catalyst light-off timer.

The catalyst light-off timer overrides the engine stop-start (ESS) stop function control while the catalyst light-off timer is counting up. During the simulation, after the IgSw down-edge time reaches the catalyst light-off time CatLightOffTime, normal ESS operation resumes. If there is no torque command before the simulation reaches the EngStopTime, the ESS shuts down the engine.

To control ESS and catalyst light-off:

  • In the Longitudinal Driver Model subsystem, set the ignition switch profile IgSw to 'on'.

  • In the engine controller model workspace, set these calibration parameters:

    • EngStopStartEnable — Enables ESS. To disable ESS, set the value to false.

    • CatLightOffTime — Engine idle time from engine start to catalyst light-off.

    • EngStopTime — ESS engine run time after driver model torque request cut-off.


The Controller subsystem has a PCM containing an ECM, HCM, and TCM. The controller has these variants.

ECMSiEngineController (default)

Implements the SI Controller


Implements the CI Controller



Implements the transmission controller


Optimal Control (default)

Energy Management System

Implements the Equivalent Consumption Minimization Strategy

Rule-Based ControlP2 Supervisory Control

Implements a dynamic supervisory controller that determines the engine torque, motor torque, starter, clutch, and brake pressure commands.

Regen Braking Control

Implements a parallel or series regenerative braking controller during rule-based control.

Rule-Based Control

The HCM implements a dynamic supervisory controller that determines the engine torque, motor torque, starter, clutch, and brake pressure commands. Specifically, the HCM:

  • Converts the driver accelerator pedal signal to a torque request. The algorithm uses the optimal engine torque and maximum motor torque curves to calculate the total powertrain torque.

  • Converts the driver brake pedal signal to a brake pressure request. The algorithm multiplies the brake pedal signal by a maximum brake pressure.

  • Implements a regenerative braking algorithm for the traction motor to recover the maximum amount of kinetic energy from the vehicle.

  • Implements a virtual battery management system. The algorithm outputs the dynamic discharge and charge power limits as functions of battery SOC.

The HCM determines the vehicle operating mode through a set of rules and decision logic implemented in Stateflow. The operating modes are functions of motor speed and requested torque. The algorithm uses the calculated power request, accelerator pedal, battery SOC, and vehicle speed rules to transition between electric vehicle (EV) and parallel HEV modes.



Traction motor provides the torque request.

Parallel HEV

The engine and the motor split the power request. Based on the target battery SOC and available kinetic energy, the HEV mode determines a charge sustain power level. The parallel HEV mode adds the charge sustain power to the engine power command. To provide the desired charge sustain power, the traction motor acts as a generator if charging is needed, and as a motor if discharging is needed. If the power request is greater than the engine power, the traction motor provides the remainder of the power request.


While the vehicle is at rest, the engine and generator can provide optional charging if battery SOC is below a minimum SOC value.

The HCM controls the motor, and engine through a set of rules and decision logic implemented in Stateflow.



  • Decision logic determines the engine operation modes (off, start, on).

  • To start the engine in engine start (stationary) mode, the motor closes clutch 1 and puts the transmission in neutral. If the high-voltage battery SOC is low, the mode uses the low-voltage starter motor.

  • To start the engine in engine start (driving) mode, the mode uses the low-voltage starter motor with clutch 1 open. To connect the driveline, the engine controller matches the engine and motor speeds and closes clutch 1.

  • In engine on (stationary) mode, lookup tables determine the engine torque and engine speed that optimizes the brake-specific fuel consumption (BSFC) for a given engine power request. The ECM uses the optimal engine torque command. The motor control uses the optimal engine speed command.

  • In engine on (parallel HEV) mode, a lookup table determines the engine torque for a given engine power. However, because the drivetrain couples the engine and wheel speeds, engine on mode might not operate at speeds that minimize BSFC.


A rule-based power management algorithm calculates a motor torque that does not exceed the dynamic power limits.

Passenger Car

To implement a passenger car, the Passenger Car subsystem contains drivetrain, electric plant, and engine subsystems. To create your own engine variants for the reference application, use the CI and SI engine project templates. The reference application has these variants.


Drivetrain SubsystemVariantDescription

Differential and Compliance

All Wheel Drive

Configure drivetrain for all wheel, front wheel, or rear wheel drive. For the all wheel drive variant, you can configure the type of coupling torque.

Front Wheel Drive (default)
Rear Wheel Drive

Torque Converter Automatic Transmission

Ideal Fixed Gear Transmission

Configure locked and unlocked transmission efficiency with either a 1D or 4D (default) lookup table.

Torque Converter

Configure for external, internal (default), or no lockup.


Vehicle Body 1 DOF Longitudinal

Configured for 1 degrees of freedom

Wheels and Brakes

Longitudinal Wheel - Front 1

For the wheels, you can configure the type of:

  • Brake

  • Force calculation

  • Resistance calculation

  • Vertical motion

For performance and clarity, to determine the longitudinal force of each wheel, the variants implement the Longitudinal Wheel block. To determine the total longitudinal force of all wheels acting on the axle, the variants use a scale factor to multiply the force of one wheel by the number of wheels on the axle. By using this approach to calculate the total force, the variants assume equal tire slip and loading at the front and rear axles, which is common for longitudinal powertrain studies. If this is not the case, for example when friction or loads differ on the left and right sides of the axles, use unique Longitudinal Wheel blocks to calculate independent forces. However, using unique blocks to model each wheel increases model complexity and computational cost.

Longitudinal Wheel - Rear 1

Simscape Drivetrain.  Another way to customize the drivetrain is to select a Simscape™ variant. This variant incorporates physical connections to provide a flexible way to assemble components.

Use the button in the top level of the reference application to toggle between Simscape and Powertrain Blockset variants of the drivetrain subsystem.

The reference application sets the appropriate solvers to optimize performance for each engine and drivetrain combination. Select the engine variant first, then select the drivetrain using the toggle button. If you select the drivetrain before changing the engine, you may encounter a solver error.

Electric Plant

Electric Plant SubsystemVariantDescription



Configured with Lithium Ion battery and DC-DC converter

Low Voltage Starting System


Configured with a low voltage starting system


MotMapped (default)

Mapped Motor with implicit controller


Interior permanent magnet synchronous motor (PMSM) with controller


Engine SubsystemVariantDescription


Dynamic SI Core Engine with turbocharger

SiMappedEngine (default)

Mapped SI Engine with implicit turbocharger


Dynamic naturally aspirated SI Core Engine


MathWorks® used the SI Core Engine and SI Controller to calibrate the hybrid control module (HCM). If you use the CI Core Engine and CI Controller variants, the simulation may error because the HCM does not use calibrated results.


MathWorks would like to acknowledge the contribution of Dr. Simona Onori to the ECMS optimal control algorithm implemented in this reference application. Dr. Onori is a Professor of Energy Resources Engineering at Stanford University. Her research interests include electrochemical modeling, estimation and optimization of energy storage devices for automotive and grid-level applications, hybrid and electric vehicles modeling and control, PDE modeling, and model-order reduction and estimation of emission mitigation systems. She is a senior member of IEEE®.


[1] Balazs, A., Morra, E., and Pischinger, S., Optimization of Electrified Powertrains for City Cars. SAE Technical Paper 2011-01-2451. Warrendale, PA: SAE International Journal of Alternative Powertrains, 2012.

[2] Onori, S., Serrao, L., and Rizzoni, G., Hybrid Electric Vehicles Energy Management Systems. New York: Springer, 2016.

See Also

| | | | | | | |

Related Examples

More About