Why is Simulink Generic Real-Time Target not realtime?
48 views (last 30 days)
Maybe I misunderstood the term 'Real-Time'. But when I create a simulink model under windows, set the target to 'Generic Real-Time Target' (grt.tlc) and build and run the created .exe it runs as fast as possible. For a realtime target I would expect the simulation to complete in realtime. So a 10 second simulation would then take 10 seconds to run as well. Am I doing something wrong, or does 'real-time' mean something different here?
Sebastian Kammer on 23 Nov 2016
Edited: Sebastian Kammer on 23 Nov 2016
The Generic Real-Time Target generates code that can be used on real-time target hardware. When this code is deployed on a hardware with a real-time operating system (RTOS), the target will be configured such that the simulation is executed at a rate that corresponds to the model's sampling time.
For instance if you specify the step size of your model to be 0.01 s, that would correspond to a sampling rate of 100 Hz. If you then use this model for real-time simulation on a target hardware (e.g., using Simulink Real-Time), the RTOS of this device will execute this model at a rate of 100 Hz, and hence the simulation will run at "real world" speed.
However if you run the executable on your desktop PC, it will simply execute at the clock rate of the PC, which is decided by the operating system and your processor (and is usually in the orders of GHz).
Now you might wonder what the point of generating executables on your PC is. A perfect example would be the Accelerator mode in Simulink. When you run a simulation in Accelerator mode, it generates an executable for the model using Simulink Coder technology. Instead of simulating the model using the Simulink interpretive engine, this executable will be called anytime the model is simulated. This enables significantly faster simulation time at the cost of certain features such as debugging. Refer to the documentation page Choosing a Simulation Mode for more information about the different modes to execute a Simulink model.