Realtime in Simulink Coder

3 views (last 30 days)
Lee Magnusson
Lee Magnusson on 12 Apr 2017
Commented: Lee Magnusson on 17 Apr 2017
I am confused as to how to obtain realtime (wall clock time) simulation from Simulink Coder. I'm using the grt configuration. The documentation suggests that grt will either emulate realtime or it can be connected to a hard real time clock. I don't see where that is an option, and all I can get the executable to do is run as fast as possible. I'm connecting to it through external mode.

Answers (1)

Hari Desanur
Hari Desanur on 17 Apr 2017
You can consider the following options to slow down the simulation -
1. If you have a licence to the Aerospace Blockset then the Simulation Pace block can be used to set the simulation speed of the model. This block will attempt to match the desired simulation pace to the specified simulation rate, it will NOT make the simulation run in real-time.
2. If you do not have a licence to the Aerospace Blockset then it is possible to slow down a simulation to a rate close to real-time using hand written code.
An example of a C MEX S-function used to slow down a model close to real-time can be found on the MATLAB Central File Exchange at the following address:
Note that the above options allow the system to run approximately in real-time, but not exactly. It should only be used to reduce the speed of a Simulink model so that a user can interact with it and observe the results in real-time.
3. For applications like Rapid Prototyping and HIL Simulation where accurate hard real-time is required, you should consider using Simulink Real Time or Simulink Desktop Real Time products.
  1 Comment
Lee Magnusson
Lee Magnusson on 17 Apr 2017
Thanks for the help there. I think those are all options. I do like that simulink coder generates real code that I may compile on other systems.
I'm still wondering though in the help for simulink coder It lists this comment:
The default GRT and ERT rt_main files emulate execution of hard
real time, and when explicitly connected to a real-time clock
execute in hard real time.
On this help page: simulink coder help
What exactly does that mean? Where can I learn more about it.

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!