No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Real-Time Blockset 7.1 for Simulink

4.8 | 18 ratings Rate this file 38 Downloads (last 30 days) File Size: 40.4 KB File ID: #3175 Version: 1.0
image thumbnail

Real-Time Blockset 7.1 for Simulink


Leonardo Daga (view profile)


23 Mar 2003 (Updated )

A block that allows Simulink model be executed in real-time using a simple method.

| Watch this File

File Information

This new Simulink block allows the execution of Simulink models in real time. The blockset is actually composed by only one block, that has been realized using an S-function written in C++ language.

This blockset is based on the simple concept that, to make the Simulink run with a real-time temporisation, the cycle time (the time that Simulink needs to calculate a simulation step, that is function of the hardware and the OS in which Simulink is running) should be lower then the desired simulation step. If this assumption is not valid, no real-time simulation is possible, whichever is the applied scheduling method.

Obviously, this statement is not completely valid, for example if we suppose to work with a real-time OS, in which the scheduling can be fully controlled. Anyway, the Windows OS is not in this case, because it's a multitasking environment with a partial controllable scheduling approach. The only controllable feature of Windows is the possibility of assigning a greater priority to the running process. In this blockset, a block allows the selection of the preferred priority to assign to Simulink.

This blockset simply hold the execution of the Simulink simulation attached to the time flow, in the sense that, if the cycle time is lower then the simulation step, this block wait for the time needed to fill the simulation step, leaving the remaining CPU time to all the Windows Process that need it. This concept is very simple but effective.

Respect to the other products, the RT blockset doesn't use a separate OS or runs a RT kernel to provide an RT simulation. Another feature that may let you prefer this blockset is the lack of limitation that this block impose to the use of Win32 instruction in your C/C++ S-functions. This blockset may virtually cooperate with any Win32 or DirectX instruction. Personally, I tested the RTW version of this block (that will be soon available) even on WinNT Embedded, with interesting results.

The OS where this solution was first developed is Windows NT 4.0, then this blockset is based on the Win32 library timing functions and process control functions. The actual released blockset has been realized only for the Windows platform and has been tested on a Win2000 and WinME OS with different speed processors.
This blockset can be compiled also with Real Time Workshop, offering a greater protection respect to all other process than a Simulink model that runs inside Windows NT can guarantee.

To see more about this blockset and download the previous version for Matlab 5.3, 6.0 and 6.5, visit the following web page:, click on the "RT Blockset" link on the right of the page.
This page contains also much more informations about the use of the RT block.
The library is already on a tested stage, but debugging information from new users will be appreciated.

In the image, the behavior of the simulation during a delaying OS operation.

Required Products Simulink
MATLAB release MATLAB 7.1.0 (R14SP3)
Other requirements Real Time Workshop is needed only for users that need to increase timing performances in the simulation. Required a Windows OS.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (21)
06 Aug 2015 Alessandro

Forgot Linux users?

16 Dec 2014 Gerd Kaiser

24 Nov 2014 Kareem Abdelgawad

I have Windows 7 x64 and Matlab 2013b. Can someone please help me how to make it run with my system?

11 Oct 2013 Carlos M. Velez S.

It is a very simple solution to implement quicly real-time in Simulink Models. Of course, it is more professional and reliable to use Simulink Coder.

06 Dec 2012 Arun Badigannavar

anybody can tell me how to install or use this block,,,and will it make any alteration to the MATLAB/Operating system

Comment only
16 Aug 2011 lktuematsu

im also having problem with the R2008a!! can anyone help me?

Comment only
10 Feb 2011 Tristan

17 May 2009 Billy Nguyen

Can anyone run this blockset in R2008a?

Comment only
15 Jan 2009 Sergey Shapovalov

The Best!!! Thanks for source and libs. They are needful to compile blockset for new releases of MATLAB with non-DLL executables (R2008b, for instance). For lazy users can provide my personal MEXw32-build
For R2008b in RTBlock a mask parameter 'priority' should be changed manually to another name. Still Real-Time Blockset is a great solution!!!

24 Apr 2008 Rudolf Haraksim

You have saved my bottom :) Solved my problem with synchronisation of dynamic model to the UDP port without using real time windows target... Excellent

21 Nov 2007 Luis S

Excellent! It's what I was looking for.

04 Oct 2007 Satja Lumbar

Effective&easy to use

20 Feb 2007 Steven Persyn

Fantastic, your an angel :)

06 Nov 2006 Ivan U

Brilliant! I am making a virtual reality naval vessels simulator and this is just what I needed. So elegant and smooth. Brilliant ;)

14 Oct 2005 Stefan Engelke

perfect! i was searching for such a simple but working solution for a long time. thanks!

11 Aug 2004 Dan Salluce

Great code Leonardo...a couple of suggestions:

When you set the priority of the don't forget that you are also controlling the parent process (in this case the Matlab.exe). This is a bad bad thing because moving/scrolling a Matlab window around will also be completely dedicated- try it and see (in task manager) that you actually raise the priority of matlab.exe. The good thing is that you put it back on mdlTerminate(). This would only be useful for a RTW version...

The more valid approach is that of the thread priority. It seems you did a great job implementing this- but which thread? Do you create a new thread for the timer to run in and assign that prioirty?

Overall this is great and directly competes with the Realtime Windows Target for which you have to pay...

26 Jul 2004 Jisang Sun

Just Great~!!!!!!!!!!!!!!!!!

20 May 2004 Luigi Tenneriello

Very useful!

04 Dec 2003 Shu-An Lee


10 Jun 2003 Nelson Rojas


11 Apr 2003 Jean-Francois Desrosiers

Really useful for timers with less granularity. Also interesting to give better accuracy to heavy simulations. Eases the integration of external hardware. The provided link in the article provides further informations and other interesting blocks.

28 Mar 2003

Updated the title of the blockset (not the content)

18 Dec 2003

Updated only the summary and the description (added a note)

18 Dec 2003

Updated only the summary and the description (added a note and a screenshot)

Contact us