Building Vehicle Controller HIL Real-Time Simulation from Scratch with TSMaster

Building Vehicle Controller HIL Real-Time Simulation from Scratch with TSMaster

Real-time simulation occupies an important position in the development and testing of automotive components. Usually, to realize real-time simulation and hardware-in-the-loop testing, it is inevitable to deal with NI, Veristand, Dspace and other big-name software or hardware products, which are costly and have certain entry barriers, and are not conducive to large scale promotion. The emergence of TSMaster has broken such a situation.


Overview

First of all, explain the real-time simulation in real-time simulation, it does not require how fast the simulation speed should be, but the deterministic requirements for the moment of return results of the simulation calculation tasks. For example, a task in the ECU has an execution period of 5 ms, and the basic requirement for real-time is that the task must be executed within the current 5 ms, and cannot be postponed to the next 5 ms cycle, which is only the most basic requirement. Because of the limited computing resources of the ECU processor, there are numerous tasks with different cycles that need to be completed within the specified time, which is why it is necessary to use a real-time system to perform the simulation tasks, and the real-time system completely simulates the operating environment of the ECU controller.

First of all, explain the real-time simulation in real-time simulation, it does not require how fast the simulation speed should be, but the deterministic requirements for the moment of return results of the simulation calculation tasks. For example, a task in the ECU has an execution period of 5 ms, and the basic requirement for real-time is that the task must be executed within the current 5 ms, and cannot be postponed to the next 5 ms cycle, which is only the most basic requirement. Because of the limited computing resources of the ECU processor, there are numerous tasks with different cycles that need to be completed within the specified time, which is why it is necessary to use a real-time system to perform the simulation tasks, and the real-time system completely simulates the operating environment of the ECU controller.

Building Vehicle Controller HIL Real-Time Simulation from Scratch with TSMaster


II. ECU embedded code and TSMaster applet integration

We will build a real-time simulation environment for ABS algorithms based on TSMaster from scratch step by step. The ABS algorithm will be automatically generated as embedded code through Simulink, and it will be run as an applet in TSMaster's real-time environment. We first save the model as a separate file and then need to modify the path so that the code generation is placed in this new path. We then need to make some changes to the model to allow it to generate the embedded code. First we need to remove the oscilloscope and other useless controls, then we need to remove the CarSim s function and convert the s function interface to in and out.

Building Vehicle Controller HIL Real-Time Simulation from Scratch with TSMaster

In order to generate the embedded code correctly, we also need to do some modifications on the code generation, open the configuration, first is the stop time, set to inf, then is salvar, again using the fixed step length, step we use the industry common 5 milliseconds. Next comes the code generation link, Target file is naturally ert, we also need to go to the interface, where the continuous time hook, because the wheel cylinder pressure model is used in the middle of the transfer function, is a continuous state, then press Ctrl + B to generate the code, and soon the code is generated. Then in this code, we need to copy and paste ABS.c.h and some other header files into the middle of TSMaster's applet folder to participate in the compilation process.

Building Vehicle Controller HIL Real-Time Simulation from Scratch with TSMaster


III. Real-time simulation of vehicle model out of RT

Whether our ABS algorithm is in the TSMaster applet or in the real ECU hardware, its operation necessarily requires the input of signals such as wheel speed provided by the external environment, and its output must be applied to the external environment, in this case the vehicle and other controllers. Obviously, we need a vehicle model to participate in the simulation process, and in general, this vehicle model is the RT version of CarSim.

Building Vehicle Controller HIL Real-Time Simulation from Scratch with TSMaster

Based on our earlier discussion of the real-time nature of HIL simulation, we can also use a non-RT version of CarSim and simply call CarSim-related API functions in real-time to move the entire vehicle model to a personal computer. The CarSim Controller, which is equivalent to the RT version of CarSim, can simulate the vehicle model on a PC with high accuracy.

Based on the TSMaster software platform, we can easily intervene in any variable of the ECU algorithm. It is important to note that CarSim Controller is only one of the millions of ways to make a dynamics software CarSim real-time. Based on this principle, other dynamics software such as Carmaker can also be controlled in real time.

Fourth, the specific implementation of ECU HIL simulation

We have described above the ABS algorithm simulation and the vehicle model run, their function is not simply to draw curves and collect operation data, but has a deeper purpose, which is to link with the external world, exposing the input and output data completely to the real world, to achieve the real purpose of HIL - hardware In the loop. The process of interacting with the external world can be very simple, just need to design a special dbc file for this purpose, load it into TSMaster, and map the contents of the system variables to the bus.

en_USEnglish
×
×

产品入口: 产品添加到购物车

Download location

Please click the download button below to start experiencing the powerful TSMaster features. Thank you for your support!

Beta version updated weekly, full version updated monthly
Installation environment
  • 1
    Windows 7 SP1 or higher, supports Win10, and WIn11.

    Operating System

  • 2
    8GB

    random access memory (RAM)

  • 3
    At least 550MB of free space

    disk space

  • 4
    Dual-core (2-core) or higher

    CPU

Please ensure that your computer meets at least these requirements in order to install and run the TSMaster software successfully. If your computer does not meet these requirements, it may cause performance problems or not run the software properly. You may want to consider upgrading your hardware if you need smoother running features.