Why is Simulink Generic Real-Time Target not realtime?

14 visualizzazioni (ultimi 30 giorni)
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?

Risposte (1)

Sebastian K
Sebastian K il 23 Nov 2016
Modificato: Sebastian K il 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.
  1 Commento
Stephen Balint
Stephen Balint il 28 Nov 2019
So, what's the most appropriate way of running a model in real time, that is to say at 100 Hz for a step size of 0.01 seconds using a GRT target, as the Simulink Real Time is not an approriate target for me. I can obviously use the Real-Tiem sync block when running in Simulink but this requires an rtwin or rtwinert target. Am I left with building my own script/function to replicate the Real-Time Sync block when using a GRT target?

Accedi per commentare.

Categorie

Scopri di più su Simulation in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by