Main Content

Electric Vehicle Configured for HIL

This example shows how to model an electric vehicle. You can use the model for Hardware-In-the-Loop (HIL) deployment. Energy-based modeling avoids high-frequency switching and the solvers implement fixed-step simulation.

The test run shows the vehicle accelerating to a steady speed up an incline followed by a period of descent during which electrical power returns to the battery.


PMSM Drive Subsystem

Cooling System Subsystem

Electric and Thermal Model Subsystem

Vehicle Control Subsystem

Simulation Results from Simscape Logging on Desktop

The plot below shows the behavior of an electric vehicle subject to driver inputs and environmental conditions. The vehicle accelerates until the driver enables cruise control. The vehicle maintains speed even as the grade of the road changes. As the driver applies the brakes, the vehicle slows down to zero speed.

The plots below shows the torque produced by the PMSM motor in the electric vehicle and its temperature. During the first half of the simulation the motor accelerates the vehicle to the commanded speed and then continues to apply torque to push the vehicle up a hill. During the second half of the simulation, the motor acts as a generator as shown by the change in sign of motor torque.

Results from Real-Time Simulation

This example has been tested on a Speedgoat Performance real-time target machine with an Intel® 3.5 GHz i7 multi-core CPU. This model can run in real time with a step size of 400 microseconds.