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:
http://digilander.iol.it/LeoDaga, 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.
Does anyone know how to compile this for win64 and Matlab 2017a? I tried "mex -lrt -lwinmm RTBlock.cpp" but got unresolved externals.
Forgot Linux users?
I have Windows 7 x64 and Matlab 2013b. Can someone please help me how to make it run with my system?
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.
anybody can tell me how to install or use this block,,,and will it make any alteration to the MATLAB/Operating system
im also having problem with the R2008a!! can anyone help me?
Can anyone run this blockset in R2008a?
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 http://sse.xtreemhost.com/files.
For R2008b in RTBlock a mask parameter 'priority' should be changed manually to another name. Still Real-Time Blockset is a great solution!!!
You have saved my bottom :) Solved my problem with synchronisation of dynamic model to the UDP port without using real time windows target... Excellent
Excellent! It's what I was looking for.
Effective&easy to use
Fantastic, your an angel :)
Brilliant! I am making a virtual reality naval vessels simulator and this is just what I needed. So elegant and smooth. Brilliant ;)
perfect! i was searching for such a simple but working solution for a long time. thanks!
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...
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.
Updated only the summary and the description (added a note and a screenshot)
Updated only the summary and the description (added a note)
Updated the title of the blockset (not the content)
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.