5.0

5.0 | 8 ratings Rate this file 118 Downloads (last 30 days) File Size: 20.36 KB File ID: #21908
image thumbnail

Simulink® Real Time Execution

by Guy Rouleau

 

27 Oct 2008 (Updated 22 Jul 2010)

C-MEX S-function that reduces the execution speed of a model close to real time

| Watch this File

File Information
Description

This block should be used only to reduce the speed of a Simulink® model so that it can be observed running in real time. If the simulation is already slower than real time, this block has no effect.

To use it, extract the files to a directory on the MATLAB path. Re-open the Simulink browser and you should see a new library named "Useful Stuff" which contains one block named "Real-Time Subsystem". Place this block in a model to use it.

To use this file under other operating systems, just run "mex sfun_time.c" to generate the MEX-file for your platform

For accurate hard real-time, I recommend looking at xPC Target or Real-Time Windows Target.

Required Products Simulink
MATLAB release MATLAB 7.7 (R2008b)
Other requirements You will need to re-mex the s-function for other platforms.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
03 Jul 2009 Andreas

Fantastic!!! And so easy to use!!!!

22 Jul 2010 Lukas Lansky

Very nice.

18 Jan 2011 Tan Edwin

problem solved and it runs well

24 Mar 2011 Harrison Yiu

hihi,
I am sorry that i can execute this file ,
the error is showned :
Error in S-function 'rtc_example/Soft Real Time': S-Function 'sfun_time' does not exist.

How can i solve this problem ?
I have already linked to directory on the MATLAB path.

Thanks a lot , I am now using R2008a

24 Mar 2011 Guy Rouleau

Harrison, if you are not using a Windows 32-bit system, you need to execute "mex sfun_time.c" to generate the MEX-file. Note that if you never used MEX before, you will need to execute "mex -setup" to choose a compiler.

25 Aug 2011 Chee Syn Ang  
06 Oct 2011 Guillaume MARTIN

Simple, efficient : what I needed !

12 Oct 2011 Benjamin  
07 Jan 2012 sufendi mulia

hi,
i have try to run your file and it's work fine. but the problem is, the simulation run to slow compare to real time after i add your function in my simulink project.
the question is, can i make it run faster so it run same as real time ? and how to make it.

thanks.

10 Jan 2012 Sun  
19 Jan 2012 Mark

I am not seeing the "Useful Stuff" library pop up. Do you expect problems running this on 2010b (XP,32 bit)? Thanks!

Please login to add a comment or rating.
Updates
08 Jan 2009

Updated to allow scaling of time. It is now possible to specify that one second of simulation is X seconds in real life.

26 Feb 2009

To use this file under other operating systems, just run "mex sfun_time.c" to generate the MEX-file for your platform

18 Jun 2009

Minor modif for BSD license

21 Jul 2010

- Fixed a bug causing the model to freeze after 36 minutes on some Unix systems.
- Possible to tune the Time Scaling Factor while the simulation is running.
- Possible to pause and restart the simulation.

22 Jul 2010

Fixed bug causing the model to freeze after 36 minutes on Linux 32-bit systems

Tag Activity for this File
Tag Applied By Date/Time
simulink real time execution Guy Rouleau 27 Oct 2008 16:14:49
simulink Cristina McIntire 08 Jan 2009 13:51:50
real time simulation Gautam Vallabha 30 Sep 2010 17:30:17
real time simulation YASER RAMADAN 28 Jun 2011 18:54:53
real time simulation Pablo Mastroleonardo 29 Nov 2011 17:28:02
simulink real time execution M 11 Jan 2012 04:27:52
real time simulation jespestana Pestana Puerta 08 Feb 2012 13:20:19

Contact us at files@mathworks.com