Skip to main content
Development of EVs with Real-Time Testing search search close

Real-time testing accelerates innovation of automotive electrification, from electric powertrains and power management systems to high-voltage DC battery chargers. Furthermore, thorough HIL testing is crucial to de-risk integration testing of electric propulsion and battery management systems.

You will learn how Speedgoat real-time solutions enable electrical and automotive engineers to develop, test, and validate their innovations with hardware prototypes. We'll provide examples that range from controlling and tuning an electric motor drive to verifying the operation of a torque vectoring algorithm against a virtual powertrain.

With multi-core CPUs, Simulink-programmable FPGAs, communication protocols, and a wide range of input/output interfaces, Speedgoat real-time solutions can deploy Simulink-based models in real-time to run in the MHz range, interface with automotive ECUs, and provide power interfaces from a few watts to megawatts. 


Specific topics that will be covered include: 

  • Perform rapid prototyping to test and tune new powertrain controls and power management strategies designed with Simulink 
  • Create real-time digital twins of electric vehicles
  • Run power electronics and electric motors on real-time CPUs or FPGAs
  • Connect real-time models to ECUs with Speedgoat IO protocols or to electrical components with power amplifiers
  • Perform HIL testing of power management systems and battery chargers

Video Transcript

Hello everyone and welcome to this webinar on how to Accelerate Development of Electric Vehicles with Real-Time Testing

My name is Manuel Fedou, and I am an application engineer for electrification at Speedgoat.

As an introduction, let’s summarize how your development process can benefit from real-time simulation and testing?

You typically want to get from an early design idea to deployment in production.

As a simple example, let’s say you design a cruise controller for your new electric powertrain.

If you develop the controller in Simulink, you can quickly iterate and test your designs against a simulated plant, all performed in desktop simulation, but to prove your design against real dynamics,  you should also test it with a real vehicle. And you can do so with real-time testing for RCP, short for rapid controller prototyping.


From your Simulink model, you generate a real-time application, and deploy it to a Speedgoat target machine, which directly connects with vehicle sensors and actuators through the vehicle network, analog and digital interfaces.

Once you have tuned and verified your controls, you could use Embedded Coder to generate the embedded code for your ECU from the same controller model.


Instead of proceeding immediately with physical testing using real vehicles, you frontload ECU validation with hardware-in-the-loop testing, and trick the ECU into believing is controlling a real car, when it is actually connected to a real real-time digital twin of it


  And today we will look at these workflows for different applications related to electrical vehicles.


Let’s see how to apply these real-time testing workflows to our topic of today, Electric vehicle powertrain controls.


We can list many Use Case Areas for Real-Time Testing of EV components.

First, power electronics and motor controls, required by electric drives, power converters, and battery chargers.

Second, energy management for battery packs and fuel cells.

Third, we can list many Powertrain Application & Domain Controllers like supervisory controls and diagnostics, torque coordination, regenerative braking, and cross domain communication.


We are going to look at Market Drivers for Real-Time Testing for these different use cases.

For Power Electronics and Motor Control, use of wide bandgap semiconductors is leading to higher switching frequencies and higher control bandwidth

 Engineer must face the increasing complexity of control systems and time-to-market pressure

 And testing the digital controller directly connected to the motor or inverter is inefficient and can damage the equipment


With Real-Time Testing, you can design and test advanced controllers with a few clicks and leverage sub microsecond sample-times and switching frequencies in the MHz range.

 You can perform HIL testing of power converter controllers faster and more safely, all while ensuring all functional, safety, and certification requirements. 

 And you can Use electric motor emulation to safely test power inverters and EV power converters for extreme and fault conditions.


 On the other end, Battery modules require fault detection, cell balancing and State-of-Charge estimation algorithms.

 BMS or fuel cell control firmware and front-ends must be tested thoroughly, including charge and discharge cycles that can take days.


 You can perform HIL testing of electric designs and automate testing of drive cycles under normal and extreme driving conditions.

 You can verify, validate, and test battery management system (BMS) controllers and hardware components using battery cell emulators.

 And you can Safely test BMS under extreme and fault conditions without risking battery damage and explosion.


Concerning Powertrain Application & Domain Controllers.

 Designing innovative electrical powertrain requires advanced control design.

 Chassis control algorithms such as anti-lock braking, torque vectoring, and electronic stability control are critical safety features.

 The most challenging physical conditions for these algorithms to operate in, such as driving on icy surfaces or with poorly loaded trailers, are also the most difficult to test.


 Use real time testing to perform trade-off studies of your architecture and size key components such as the battery pack and traction motor using digital twins

 Perform automated tuning and automated testing of controls and hardware components to ensure that functional, safety and certification requirements are met.

 And Test safety features in most challenging physical conditions with HIL.


In this webinar, we will look at power electronics and motor controls.

 For example, we will see how to perform rapid prototyping to deploy Simulink controls against real power electronics and motors.

we will look at battery management systems, and see how to test a piece of BMS controller a cell emulator.

And finally, we will look at full vehicle real time simulation, from electrical powertrain to multi domain digital twins of full vehicles.

For example, we will deploy algorithms such as torque vectoring on real-time equipment, couple with real-time simulation of electric powertrains via automotive protocols such as CAN and couple the simulation with a 3d engine.

But first, Why do we need Real-Time Testing for Automotive Electrification?



 Real-time testing enables you to accelerate Time-to-Market.

You can adopt a control prototyping solution, enabling rapid innovation independent from the production hardware.

With this, test and prove new ideas, integrate new components as you change requirements.

It takes you one-click to build the real-time application, and run-on target.


  Second, with real-time testing, you can detect Design Flaws at the Earliest Possible Stage.

Analyze and compare desktop and real-time simulations to detect design flaws.

Prove concepts, inject faults, and test environmental conditions.

Take advantage of signal monitoring, data logging and parameter tuning capabilities.


  Third. You can perform Automated and Extensive Testing.

Simulate physical plants to enable testing when the actual hardware is not available

Perform and automate tests in a safe environment, without risks of damaging equipment or injuring operators.


Our real-time simulation and testing platform simplifies your workflow and lets you design and test better controllers and plant models faster.

You can innovate and you are not constrained by embedded testing environments or with the hassles of integrating solutions.


Benefit from a plug-and-play real-time solution that shields you from interoperability issues.

Experience the unity of simulation and testing with real-time target hardware, all directly from MATLAB and Simulink.

The seamlessly integrated solution is composed of two main components.

 The first one, is Simulink Real-Time, the solution for real-time test and simulation from within MATLAB and Simulink.


It comes with several host capabilities that allow you to easily create, control and monitor your real-time applications,


and it serves as your real-time operating system.


The second component is powerful and scalable Speedgoat real-time target computer hardware, equipped with I/O.


The real-time application created from your Simulink model runs on it together with the Simulink real-time operating system.


 Let’s suppose you are working on a novel cruise control function for the next generation full-electric vehicle.

You and your team have been designing, specifying, and sizing new software and hardware components based on a full vehicle simulation. The vehicle model is comprised of both Simulink components for the vehicle controls, as well multidomain physical Simscape components for high fidelity simulation of the vehicle plant including battery, electric motor, and thermal cooling systems.


Regarding the cruise control function, for instance, you have may been using this model to rapidly tune controller performance and assess design.

In a next step, you may want to validate and verify the new cruise controller functions for execution on embedded controllers.

Let’s go through the few steps to enable real-time execution:

You start configuring a target machine in the Simulink Real-Time App. Under the hood, code generation is optimized for Simulink Real-Time engine and a fixed step solver is set.

You can rapidly connect to our Speedgoat target computer, and click on Run on Target Button.

This will automatically build a real-time application from your model, download and run it on the Speedgoat target computer. The Simulink instrumentation and logging capabilities remain available for you to experiment in real-time.

To test the new embedded controllers, you also need your model to be able to interface with your embedded controller through real-time capable I/O and specific protocols.

Implementing the controller interfaces is also very simple: With the Speedgoat I/O Blockset Simulink integration, you can for instance implement communication through CAN protocol with simple drag and drop of blocks.


You can see here that I am using system variants to manage different interfaces for the cruise control. This is a good practice in case you like to keep a single model for different development stages and easily switch back and forward between offline and real-time execution simulation.



There are five learning we can draw from this example:


You don’t have to leave Simulink.


No need to familiarize yourself with extra tools.


Just connect to hardware with a few clicks and experiment in real-time.


Switching back and forth is easy.

And configuring I/O, namely the connections to your hardware, is quite smooth.

After learning about the real-time workflow, let’s now go through Speedgoat‘s products and services offerings to understand better what a real-time system is comprised of.


Each system is configured to your individual requirements about performance and I/O.


Changing requirements is not a problem, as you can reconfigure I/O. You can choose from a vast range of I/O connectivity options and exchange them at a later date.


All real-time target machines are expressly designed to work with Simulink and Simulink Real-Time,


not only for the current and supported releases, we also make the promise to support future releases.


Our hardware quality, our long-term warranty and maintenance services ensure long-term operability of your real time-testing hardware.



Delivery of each real-time system includes the real-time target machine, I/O modules configured to your needs,

together with accessories such as terminal boards and cables,


and the Speedgoat I/O Blockset. The blockset library allows for connectivity to the hardware.


And no matter whether you are prototyping control strategies or testing controllers against your digital twins,

connectivity shouldn't be a hurdle for you.

We are supporting key protocols from automotive and other industries., such as CAN and Flexray, serial protocols, PWM generation and capture, and battery cell emulation.

More than 200 I/O modules are available and ensure that your workflows remain un-interrupted.


IO configuration is simple.


I/O and hardware of any kind is represented by Simulink blocks.

Placing them in your model and configuring I/O or protocols is done within Simulink.


A very important category of I/O for high performance interfaces is FPGAs. For instance, FPGAs are vastly used for power electronics and motor control applications to generate PWM signals or emulate sensors such as encoders.

Speedgoat offers two types of FPGAs: Configurable ones and Simulink-programmable ones


Configurable FPGAs allow you to use high frequency I/O and lots of protocols without FPGA programming knowledge. [Breathe]


There are many code modules represented by Simulink driver blocks.


And you can configure your FGPA on the fly and directly from Simulink.  Speedgoat provides different configuration files so that you can get the best performance out of the IO module for dedicated applications.


FPGAs can also be used to schedule execution of subsystems, the entire real-time application, and as said before individual I/O modules, or even to synchronize multiple target computers.


Configurable FPGAs allow you to use high frequency I/O and lots of protocols without FPGA programming knowledge. [Breathe]


There are many code modules represented by Simulink driver blocks.


And you can configure your FGPA on the fly and directly from Simulink. Speedgoat provides different configuration files so that you can get the best performance out of the IO module for dedicated applications.


FPGAs can also be used to schedule execution of subsystems, the entire real-time application, and as said before individual I/O modules, or even to synchronize multiple target computers.


Programmable FPGAs allow you to outsource both, parts of your algorithm and signal I/O to the FPGA using the HDL Coder workflow from within Simulink.

Speedgoat provides you with ready-to-program I/O and protocol driver blocks. So, it doesn’t necessarily become more complicated,

because you can leverage and start rapidly using hardware proven example models.

Ultimately, you have more flexibility for your advanced use-cases.

Several FPGA IO modules allow using both workflows


So, it’s possible to start simple with the configurable workflow and evolve to the programmable one as you go.



Programmable FPGAs allow you to outsource both parts of your algorithm and signal I/O to the FPGA using the HDL Coder workflow from within Simulink.

Speedgoat provides you with ready-to-program I/O and protocol driver blocks. So it doesn’t necessarily become more complicated,

because you can leverage and start rapidly using hardware proven example models.

Ultimately, you have more flexibility for your advanced real-time simulation and testing use-cases.

Several FPGA IO modules allow using both workflows


So, it’s possible to start simple with the configurable workflow and evolve to the programmable one as you go.


Regardless of the workflow, Speedgoat FPGAs work like any other I/O module and can be reconfigured.



Let’s continue our journey in automotive electrification with power electronics and motor control. Electric and hybrid vehicles require electric motors of course, but also plenty of power electronics converters

3-phase Inverters

DC/DC Converters

AC/DC converters


In recent years, power electronics and motor control have been evolving fast, partly driven by the automotive electrification megatrend.

 At a component level, the use of wide bandgap semiconductors are leading to more compact and efficient power converters. 

 At the same time, this increases the bandwidth and switching frequencies of controllers from a range of tens of kilohertz to all the way to several megahertz. 

 Another driving factor comes from control algorithms. Complex controls algorithms like Kalman filters, or model predictive control may work very well in simulation but testing them with your hardware may lead to delays as you typically must deal with fixed-point implementations, data word size or limited processing capacity.

 Therefore, there is a drive towards larger processing capacity and flexible control platforms.



We have introduced Real-time controls testing with Simulink and Speedgoat


Let’s see how real time testing can help to manage these Typical Challenges


  To Develop next generation of power converters and electric motors,

 You can use Rapid Control Prototyping to Validate requirements before designing the embedded hardware, and to Log data and tune parameters using MATLAB and Simulink.

  Then to ensure safe testing conditions

  Use Hardware-in-the-Loop Testing to test in safe conditions and automate testing easily

 And in both cases, when dealing with High switching frequencies and closed-loop bandwidths in MHz range

 You can make use of Lowest latency FPGAs, as already described in this webinar


There are several benefits when adopting rapid control prototyping.


 Your final product will probably require an embedded board, with a microcontroller or FPGA.

You will have to select the right chip, depending on the size of the code, the switching frequency, and the required I/O channels.

These are many requirements to validate, with rapid control prototyping, you introduce a hardware platform that is independent from the final embedded device.

 As a consequence, you can find design errors very early in the development phase.

Some mistakes can be found also with desktop simulation, but we know that testing on hardware can introduce new variables.

You can change requirements as you are validating and finding mistakes,

 For example, you can integrate new components. such as new I/O channels with having to redesign the embedded hardware.

You can tune parameters and log data using MATLAB and Simulink.

You can add communication interfaces by simply using driver blocks, and you keep the focus on the control algorithm.

Eventually, You don’t have to think about accessing onboard memory and I/O registers.



Let’s have a look at a demo for a demo for electric motor control. We use a Baseline real-time target machine with a Simulink-programmable FPGA, a 3-phase inverter and a brushless DC motor.


With this demo using models with Speedgoat target machine including an fpga and the Speedgoat electric motor kit, you can quickly get started with field-oriented control, parameter estimation and rapid control prototyping.

Let’s check out how you can control a real-time application directly from within Simulink.

Connecting to the target and starting the application just takes a few clicks.

When the application is running in external mode, we can change parameters, and the changes will take effect immediately.

For example, let’s switch the control inputs to manual user control.

With Dashboard controls inside Simulink, we can now set the motor speed and view the logged data.




FOC Autotuner from Motor Control Blockset automates estimation process of the control loop gain for motor control development.

It works in real-time with Speedgoat real-time systems

It Estimates FOC gains to meet control requirements by Injecting disturbances to control inputs for parameter estimation


You can run the FOC Autotuner with speedgoat hardware, we see that the speed tracking is slow with underdamping. By inserting perturbations, FOC autotuner automatically calculates the control loop gains. After a start with a slow speed tracking, the velocity tracking significantly improves once the new gains are calculated.

Now let’s see how to thoroughly test the controller. For example, you may want to test all fault scenarios for an electric motor, but you want to do this safely. And maybe you do not even have the electric motor available to test your controller.

For this, you can setup hardware in the loop (or HIL) simulation with Speedgoat.

A Hardware in the loop setup contains the controller under test, here a microcontroller and a HIL real-time simulator that runs a real-time simulation of the plan together with IO modules.

At this stage, HIL testing can be used to test your controller.

 HIL can replace prototypes or production hardware with a real-time system

 HIL enables to automate testing more easily with tools such as Simulink Test

 It is safer to test with real time simulations than with most power electronics hardware which can break down

 It enables to start many design/test tasks earlier because you can test controllers even if the hardware is not available

Let’s look at a Motor HIL Demo setup

On one side, we deploy the controls and the PWM generation on a baseline target machine. This is our device under test.

On the other side, the Speedgoat HIL simulator runs a real time simulation of the motor and inverter models and generates analog signals emulating current measurements and encoder signals.

The next step is to deploy the algorithms on an embedded controller. This was discussed in detail in the webinar of this series on motor control.

For this, we need a real-time simulation of the electric motor. Such model requires a 3phase inverter, and a motor.

Depending on your application you can use different level of modelling fidelity for your motor

For a Basic E-drive Proof of Concept Use an Average Inverter and Lumped Parameter Motor

For Field Weakening Control you could use an average Inverter and a Flux Based Motor

And to test Torque Ripple Compensation, a Switching Inverter and a Spatial Harmonics Based Motor


These curves basically show you how these 3 levels of fidelity model differ from each other.


So, we’ve got lumped parameter model, saturation model, saturation plus Spatial harmonics model.

From either dyno testing or FEA we should be able to obtain the flux. Or we call “the flux table”.


In order to feed the flux table to the saturation model, we must invert that to a current table.


As you can see the lower 2 table current id and iq table.

Here is the animation of flux variation at different rotor positions.


The left plot comes from ANSYS Maxwell which shows how flux density changes as the rotor position changes, and the right plot is a MATLAB plot of the flux surface at different rotor positions.


You’ll notice that the flux surface constantly shifts when the rotor rotates.  That variation introduces spatial harmonic components in the flux linkages, currents, and torque.


So, in this type of high-fidelity model, we’re trying to capture the rotor-position-dependent component.

To simulate our electric drive, we also need to model the inverter

For this, we can choose different level of modelling fidelity.

We can choose an averaged model for the inverter which is great for Basic E-drive Proof of Concept

To validate switching events, and analyze harmonics, we need a switched or Subcycle averaged model of the inverter.

As the switching frequencies in automotive reach a few tens of kilohertz, simulating switching, and harmonics require a sample time around 1 Mhz, which can be obtained by using FPGAs to run the plant model in real-time.


For this. you can convert Simulink models to HDL code.

In the case of Simscape Electrical models, they can be converter to switched linear models using the Simscape to HDL workflow advisor. Then, you can generate HDL code and implement the plant model on a programmable FPGA.



By Simulating power electronics on FPGA, you can reach simulation time steps below one microsecond and PWM switching signals as low as 4ns. This enables you to test your switching algorithm and compute the efficiency of your power converter.

Once your power converter is implemented on the FPGA, you can start real-time simulation in one click and observe switching dynamics for switching frequencies up to hundreds of kHz on an oscilloscope or directly in Simulink using data streaming capabilities.

Let’s go back to our Motor HIL demo.

We can start the HIL simulation and inspect the analog currents generated by the FPGA on an oscilloscope.

We can tune the speed reference in real time and see that this impacts the frequency of the currents plotted on the oscilloscope.

A further HIL Testing setup for electric power converters is Power HIL.

Unlike Controller HIL where the device under test is a piece of embedded hardware Power HIL enables you to test the actually Electrical Power Equipment.

typical setup for Power HIL could look like that.

It contains a power amplifier in between.

a device under test like the 3-phase inverter or an onboard charger, on a high-voltage DC fast charger.

and the HIL simulator running a simulation of the rest of the system, such as the vehicle onboard power systems or the electric grid.

Amplifier and Speedgoat real-time target machine are connected through a high-bandwidth fiber optic connection.

With Power HIL, you can test your electrical components like integrated on the power grid, inside an electrical vehicle.


For example, an important power converter for vehicle electrification is the high-voltage DC fast charger.

How do you develop it with different charging standards, vehicles and grid conditions.



In this case we have a 3-phase grid on one side of the converter and different DC charging voltages and standards on the vehicle side.



How to test for weak grids, or faults case? With Power HIL you can use grid emulation to test various grid types



And also emulate different types of battery packs

While the availability of automotive and grid protocols could help testing  with different charging standards and battery states on the other end.

And you can Test interactions with other components with Multi-physics simulations.


We have covered power electronics and motor through RCP, HIL and Power HIL.


Let’s continue our journey in automotive electrification with the energy source of an electric car. We will focus on battery management system and how to test these systems


Real-time testing is also a powerful tool supporting development of battery management systems, or energy managements solutions such as fuel cells.

Typical challenges include:

 The development of Battery Management Systems (or BMS) algorithms and fuel cell controls and interfacing with different control protocols like CAN or EtherCAT.  

 Rapid control prototyping can be used to address such challenges with off the shelf I/O connectivity and communication protocols.


Other typical challenges include testing of controls and interfaces to power components like battery cells. Thorough testing of control firmware under realistic conditions is not trivial.


 You can use Battery cell emulators to Emulate hundreds of cells in series, perform Fault insertion for each cell and Thermal tests via temperature sensors

End-to-end testing of battery management system is required to make sure that the system behaves as expected.


However, testing a complete charge and discharge cycle for a typical electric vehicle battery pack takes hours.


Reproducing design issues and fault conditions can be difficult and involves safety considerations.


And does it make sense make sense to do this step of testing for every software revision or design iteration?


You can use HIL testing to tackle those challenges


To increase the confidence in your design iteration, test your BMS controller …

… against a simulated battery pack.

Let’s take a quick look at a test model which allows us to simulate battery cells and generate fault scenarios.

 We have a BMS under test and connect it to an emulated battery pack using the battery emulation IO module.

 To simulate a fault, we added a switch which allows us to short two cells in simulation, without physical consequences.

 Additionally, we use a slider to set the charge or discharge currentTo perform diagnostics on cell level, we measure the voltage between two cell terminals.

The measured cell voltage values are sent to the IO module, which converts the numerical values into voltage outputs, each relating to an individual battery cell.

 The BMS controller performs diagnostics on cell voltages and detects overvoltage or undervoltage faults and short circuits between two terminals.

  When we inject a short circuit fault, we can immediately notice the red warning light.

  Let's look at the results for the whole experiment in the simulation data inspector. We can notice small changes in cell voltages due to the change in current. And one of the cell voltages dropped significantly as we triggered the fault.

Using this data, we can optimize the conditions based on which a fault is detected, to ensure safe battery management.


The battery cell emulator from Speedgoat is designed to accelerate BMS testing.   You can source or sink up to 5 amps for each cell; with a maximum output voltage of 6 volts and have up to 192 cells in series.

Therefore, when emulating lithium-ion technology, you can emulate a battery pack up of around 800 Vdc at full charge.

You can also include fault insertion and temperature simulation at cell level.

You can use Simulink and Simscape Electrical to model the battery cells and deploy to a Speedgoat real-time system. Each emulated battery cell will have the electrical behaviour given by your model dynamics and its interactions with the BMS hardware under test.


For each battery cell, you can also have optional modules to emulate temperature sensors for each cell and to test fault conditions like broken wire and short circuit.

Let us conclude with two success stories on power management.


First, Leclanche Energy Storage Solutions is developing the next generation of lithium-ion battery packs for autonomous vehicles. Being unable to properly test and verify new BMS algorithms before operation with real battery packs, Leclanche started using Speedgoat battery cell emulators for hardware in the loop testing of their BMS algorithms. As it is typically required, such tests required also using fault insertion and a communication protocol like CAN. They were able to thoroughly validate their BMS and state estimation algorithms using Speedgoat real-time solutions; thus, reducing test time by around 50% , increasing coverage and finding bugs at an early stage.

The second success story is from Nuvera, a company developing fuel cell technology for commercial vehicles. Their technology uses both fuel cells and lithium-ion batteries, and they use Simulink and Speedgoat hardware for quick iterations in their designs without having to put a real engine at risk. When installed in forklifts, their fuel cell engines should reduce 128 metric tons of CO2 annually

With these user stories, we can conclude this chapter on Battery management systems and Battery Cell Emulation and move to testing electric vehicle powertrains


Let’s look at typical challenges and benefits of Real-Time Testing for Electric Powertrains


 To Optimize efficiency and performance of electric powertrain controls

And Tune algorithms such as regenerative braking or torque vectoring

 Use Rapid Control Prototyping. You can test and develop new concepts in the field without embedded devices and leverage automotive protocols such as CAN or flexray to connect to prototypes


 Then to Test powertrain controller in Safe testing conditionsand Automate testing of ECUs,

  use HIL testing.

Run real-time models of electric powertrain architectures, including electric motors, power converters, energy storage, and mechanical transmissions.

Automotive protocols are very useful to connect to the ECU under test.


 And if you want Test full electrical vehicle architectures to manage the electrical and thermal characteristics and test multiple ECUs simultaneously.

 Run HIL for full vehicle simulation.

To illustrate this use case, we will look at a demo of a Torque Vectoring Application, where motors apply different (sometimes opposing) torque to left / right wheels.

This requires longitudinal and lateral vehicle dynamics models.

For the powertrain system model, we need mapped motors, 14 degrees of freedom body and wheels model, EV Control module and we are going to simulate an increasing steer maneuver.


   Powertrain blockset gives you quick access to conventional and electrified powertrain models.

The built-in libraries provide easy-to-use Simulink blocks, including batteries,  electric drives and electric motor controllers.

Many well documented and ready-to-use reference examples get you started quickly.

These are Simulink-based fast-running models that you can fully customize and instrument and that are ready for HIL deployment and closed loop simulation with your controls

The same model can be used to support you with different tasks like

Tuning motor and brake controls

Designing capabilities such as torque vectoring control

Or developing and testing battery management systems


This is the hardware setup we are going to use for this demonstration


The Control and the powertrain and vehicle model are represented by two Simulink models


That we will deploy respectively on a baseline target machine for the controller and a performance target machine for the powertrain and vehicle model

The communication protocol is CAN.

First, we deploy the torque vectoring control algorithm to a Speedgoat baseline target machine.

 For that, we need to extend the control model with IO driver blocks.

We configure include the torque vectoring control algorithm inside this model which will be deployed to the real-time machine running the controller.

Then we setup the driver blocks for CAN communication.

On one side we setup the CAN READ blocks to read data packets coming from the CAN network. On the other side we configure the CAN Write block to write the control commands to the CAN network.

And we deploy this model to the baseline target machine


To setup our HIL simulation, the powertrain and vehicle dynamics model is deployed to a Speedgoat performance target machine.

To design Torque Vectoring Control, we need a detailed powertrain and vehicle dynamics model. This is based on the powertrain blockset.

We can reuse the powertrain and vehicle dynamics model – minus Torque Vectoring controller

We can configure the model for HIL simulation, where the controller is external, using this user interface.

 We interfaced the HIL simulator to the controller using CAN. The torque vectoring algorithm runs on the device under test with each the Speedgoat baseline target as previously explained


Now let's build the model for real time execution and run it on the HIL simulator

On the dashboard you notice that the speed increases, which is one way to get feedback on the real time simulation


We can also open Simulink Data Inspector and look at some signals in real time. 


One interesting curve is the torque vectoring control signal coming from the controller in the bottom right


One other way to look at the simulation results is to visualize the maneuver and vehicle behavior using a 3D Engine- Unreal coupled to the real time simulation.

The green one, which is the car using torque vectoring, is more performant that the blue car when steering, which means that the torque vectoring did the job.

Let’s mention this user story from GreenTeam Uni Stuttgart. They used Speedgoat and Simulink Real-Time™ to accelerate the development of their fully electric racing car.

They used a Baseline real-time machine as an on-board ECU to accelerate control system development from Simulink to hardware.

Sensors and actuators were interfaced using real-time UDP. New control algorithms could be auto generated and deployed to the target machine at the click of a button

This enabled the team to stay focused on the control algorithms and powertrain innovations instead of ECU development, which saved months of development

To extend your digital twin model with more detailed electric and other physical components, you can do physical modelling with Simscape.

It allows you to arrange fundamental components into a schematic which integrates with your Simulink model and fully supports code generation.

With physical modelling, you get the highest-fidelity simulations for things like batteries, , fuel cells, thermal cooling systems and more.

And again, you don’t have to start from scratch.


For complete automotive models, the Simscape Vehicle Templates provide a great starting point.


 This ready-to-use reference example enables you to easily explore model architectures for conventional, hybrid, battery electric, and fuel cell vehicles with Simscape-based subsystems.


The user interface allows you to easily switch between different vehicle configurations,


And find the right model fidelity for your tasks.


Perhaps you are working on system thermal design, and you would like to analyze the thermal behavior with an activate colling system.


All Simscape vehicle template configurations are compatible with real-time execution using Speedgoat hardware and Simulink Real-Time™.


With the help of Simulink Real-Time you can perform real-time runs of full vehicle models in seconds, and start evaluating and comparing new system designs, and you can extend with I/O driver blocks to perform hardware-in-the-loop,


You can directly use these models as high-fidelity virtual vehicles, to test early prototypes or embedded controllers.


Now, the more high-fidelity components you integrate, the more computational power you need to run your model.

To achieve your sample time requirements, you might need to run your model distributed across multiple systems.


Speedgoat target machines can be interconnected via PTP to easily synchronize system clocks.

You can leverage shared memory to enables ultra-low latency data exchange, and you can use interrupt signals to trigger synchronous execution.

The flexible solution allows you to scale the systems to your needs at any time.


Let’s mentation an example from a team of researchers at the technical university of Munich, developing fully autonomous, all-electric racecars.

A Speedgoat Mobile machine serves as the vehicle electronic control unit, doing Sensor Fusion, highly performant motion control and monitoring of the vehicle components.

The cars are powered by four electric motors, requiring precise control to manage the combined force of over 500 horse powers.

But test time on the racetrack is extremely limited, and the team needed to verify their algorithms often.


They decided to model a complete virtual vehicle digital twin, which runs in real-time on a second speedgoat target machine.

The data exchange between the two machines uses the same CAN interface as on the real car.

This means the ECU doesn’t see any difference between the real vehicle and the digital twin.


Furthermore, the team created a virtual representation of the racetrack from sensor data.

Co-Simulation of Simulink Real-Time with the Unreal Engine for visualization enabled fully virtual testing of the complete software stack for sensor fusion and motion control in real-time.


We have talked about HIL simulation for power electronics, battery systems, or for full vehicles

Let’s see how could such a HIL setup look for your application?

Depending on your requirements, setups can range from a single target machine to complete HIL racks.

Let’s look at an example


Depending on the size of your group, and how you organize development of embedded SW,

the HIL system setup and controller HIL testing can be done by the same or different teams.


Let’s assume our embedded system group is segmented into three:

the HIL systems engineers, focusing on assembling and setting up new HIL test systems,

the embedded software validation team, in charge of running embedded SW test campaigns,

and the embedded software development team, tasked to develop and revise the embedded SW.


So, the question is how are we enabling these teams to succeed in their specific task?


The systems engineers have previously built a HIL test system based on the Speedgoat Performance machine.

They are now challenged to specify a new, much more complex HIL test system, which is required to integrate high-power actuators, and electronic loads and sources.


Implementing such an HIL system is time-consuming and requires specific expertise.

With that in mind, the team decided to rely on Speedgoat‘s know-how to provide them with a modular, rack-mounted HIL solution customized to their needs.


The final solution looked as follows:



Two rack-mounted performance real-time machines, enabling distributed and synchronized simulation across multiple chassis.


This setup fully integrates all power electronics components,


the required signal routing and conditioning modules,


as well as break out panels and the cabling harness.

For the systems engineers, this is a true plug-and-play solution

With hardware hurdles off the table, the team was able to focus on the design of the digital twin and even introduced some innovations.

For instance, model parameters are now automatically fine-tuned to fit measured data.


Connectivity with the controller was also done very quickly with simple drag and drop of Speedgoat driver blocks.


Using Simulink real-time, the model ran on the Speedgoat machine with a simple click, and the team could verify correctness of all interfaces right from Simulink


The HIL system was instrumented with MATLAB’s built-in App Designer. User interface controls directly connect with the real-time application allowing HIL system operation to be Simulink-independent



In parallel the software validation team has been creating scripts to batch and optimize test workflows


Part of the team has also been using Simulink Test, which has shown to be a great asset.


For instance, most of the desktop simulation tests were reused in the real-time runs.


Real-time test campaigns were triggered with a few clicks,


and the assertion of results was fast and easy using inbuilt visualization tools.


Besides, detailed test reports could be generated automatically. This greatly simplified communication with the Software development team and helped further expediting SW revision work.




We have covered various HIL testing use cases in this webinar. Another key workflow in HIL testing is restbus simulation.


It essentially means that parts of one or multiple vehicle buses are simulated to facilitate verification and validation of the ECU under test.

Speedgoat offers a complete solution for this workflow, based on our IO723 I/O module for Automotive Bus simulation.


This is a configurable I/O module that can support up to 6 different buses including:


CAN, CANFD , FleyRay, LIN, SENT and Automotive Ethernet.


It provides you the capability of performing complex, multi-bus simulation and gateways with time stamping and synchronization capabilities

You might want to rework only specific components of an already existing ECU?


Or perhaps you are in the middle of a test and integration campaign, and you need to rapidly modify parts of the embedded design, while avoiding the lengthy embedded software iteration process.

In this case, you can utilize Speedgoat for bypass rapid prototyping.

Unlike in fullpass prototyping, where you would virtualize your full controller, using the Speedgoat target as a prototype controller, with bypassing you only run specific parts of the software on target hardware, for instance.


a modified design that you created in Simulink.

Deterministic real-time behavior between bypassed and embedded components is achieved by establishing.


a bypass service with hooks and data links using the Universal XCP protocol.

This enables:


the ECU to send input data to the Speedgoat bypass unit, through a data acquisition link,


- and the other way signals are sent to the ECU through a signal injection link.


In early design stages, Bypassing allows you to rapidly prototype and test new function designs, without being limited by the embedded hardware.


So, you can implement development stages with higher confidence and guarantee that your design choices will fit the embedded environment.


During integration, Bypassing allows you to rapidly introduce and test late design changes while minimizing the effort of software revisions. In summary, bypassing helps de-risking and speeding-up development stages.


The XCP protocol is also commonly used in the automotive industry for ECU measurement and calibration.


 With Speedgoat prototyping solutions you can perform measurement and calibration of early controls directly with your real-time target machine.

You can do this either directly from within Simulink as shown already, or by using third-party tool of your preference such as CANape® by Vector and INCA by ETAS®.

Now we arrive at the end of this webinar



Let’s quickly recap the key takeaways.

Rapid control prototyping accelerates innovation and ensures faster time to market.

Hardware-in-the-Loop testing is essential to ensure reliability and safety of electric vehicles.

Speedgoat solutions cover real-time testing for full electric vehicle, power electronics and motor controls, battery management systems.

Simulink Real-Time and Speedgoat provides the most integrated workflow to deploy Simulink systems to real-time.


Thanks for staying with us until the end of this webinar.

If you found certain contents appealing, please check out our webpage













The Author

Manuel Fedou

Manuel Fedou
Application Engineer Electrification

Related Content

Let us help you to find the right solution for your project


Request a Configuration Proposal

Get a proposal for a real-time target
machine configured to your needs.

Request a proposal

Request a Free Workflow Demo

Curious how to accelerate control design
innovation with a modular controller hardware setup?

Request a free demo

Have Questions?

Talk to our experts about your project
and application requirements.

Contact us
Follow Speedgoat LinkedIn