3/5/2019
Real-Time Pacer for Simulink - File Exchange - MATLAB Central
File Exchange Real-Time Pacer for Simulink
4.8 41 Ratings
version 1.0.0.1 (18.7 KB) by Gautam Vallabha
154 s
Simulink block for forcing a simulation to run in real (wall clock) time
Updated 01 Sep 2016 View License
Follow
Overview
Functions
Models
Editor's Note: This file was selected as MATLAB Central Pick of the Week
The RealTime Pacer block slows down ("paces") simulation time so that it synchronizes with real elapsed time. The degree of slowdown is controllable via a Speedup parameter. 1) The block is implemented using an M S-function, so it works on any ed Simulink platform. It does not code generation. 2) The block uses the MATLAB PAUSE function to slow down the simulation. The PAUSE command gives up the processor during the pause, so system performance does not degrade. 3) The M-S function illustrates how to use nested functions to simplify the code. The matching between simulation time and elapsed real time is approximate, with expected differences on the order of 10 to 30 milliseconds. This limitation is due to difficulties of precise timing with a multitasking operating system. -------RELATED FX ENTRIES The following FX entries also implement "real time" functionality for Simulink. They are based on C S-functions and therefore code generation. * Simulink Real Time Execution (Real-Time Slower) (Filex# 21908) * Real-Time Blockset 7.1 for Simulink (Filex# 3175) * RTsync Blockset (Filex# 24975)
Comments and Ratings (47) Rate this submission
1 2 3 4 5
(Rating not required)
Comment on this submission
Hossein Rezazadeh 22 Feb 2019
Does not work in external mode
Matthew Gordon 25 Jan 2019
https://www.mathworks.com/matlabcentral/fileexchange/29107-real-time-pacer-for-simulink
1/6
3/5/2019
Real-Time Pacer for Simulink - File Exchange - MATLAB Central
Kai Zhao 28 Oct 2018
Tobias Kull 31 Aug 2018
lunkai xiang 17 May 2018
Antonin 20 Mar 2018
This is now built in Simulink, starting in R2018a!
The buildt-in simulation pacing of R2018a does not work for me, while this file is working! Thanks
https://www.mathworks.com/help/releases/R2018a/simulink/ug/simulation-pacing.html Deepak Devendran 26 Feb 2018
Ajith Shenoy 24 Feb 2018
JUAN JOSE MUÑOZ 14 Jan 2018
JUAN JOSE MUÑOZ 14 Jan 2018
Could you explain how to install this package?, thanks you!
Pramod Chaudhary 21 Dec 2017
Boyang 27 Nov 2017
Severin K 20 Nov 2017
Rômulo Fernandes da Costa 30 Oct 2017
Muhammad Naufan Yuslim 18 Sep 2017
Amit Kumar 4 Sep 2017
Raoul Dominique 12 Aug 2017
Excellent! Works perfectly
It would be nice, if we could change the speedup value in Real Time. I am seeding a fault in the model. At the beginning it should run in accelerated mode (speedup = inf), but after sometime at real time (speedup = 1)
Could you explain how to install this package?
works fine
good work!
Works fine with R2016b, thanks for sharing!
Very nice!
Hi, could anybody tell me in wich folder i should copy the files ? Thanks
Giovanni 3 Aug 2017
It helped me in making simulations for "marketing" or "know-how sharing" purposes
https://www.mathworks.com/matlabcentral/fileexchange/29107-real-time-pacer-for-simulink
2/6
3/5/2019
Real-Time Pacer for Simulink - File Exchange - MATLAB Central
Michael Wagner 23 Jul 2017
Damjan Miklic 10 Jul 2017
Subin Kuttappan Stellal Mary 29 Jun 2017
The MATLAB Command Window gets blocked in each step while simulation is running. Is there any way to avoid that?
Tasfin Mahmud 11 Jun 2017
Vilian Petkov 23 May 2017
Ben 27 Feb 2017
Roshan Sharma 7 Feb 2017
Nice work. Should be part of the standard Simulink libraries. It does run with Linux
Simple and efficient, works as d.
Worked nice for me. Thanks a lot.
Was very useful for me, works as far as I can tell.
Big thanks, simple to use and works great for what I want to do!
Great work! Thanks a lot... This file exchange is a superb substitution to the real time kernel. It works for me just great. I use it to read/write data from NI-USB 6003 from National Instruments along with the MPC toolbox. I used to use the "real-time sync" block from Simulink Desktop real-time toolbox provided by Mathworks, with real time kernel. But I (and many others) have a huge problem with it. The U usage was always 100% with the fan running at the top speed. The problem continued even when the real time kernel was uninstalled and MATLAB was uninstalled. Restarting computer did not help. Task manger becomes unmanageable. The only work-around was to create a restore point and restore the PC to earlier working state. Thanks to this simple solution. Now I do not have to worry about restoring my PC.
RP 10 Jan 2017
voiceafx 31 Dec 2016
Thank you! I spent forever screwing around trying to get something that plays back close to real-time, for visualization purposes. What a pain in the posterior for something so simple. Your block did the job, no problems whatsoever. Cheers!
Karthiga Mahalingam 7 Dec 2016
Great work! But I have to run a stepper motor using matlab and arduino and I get the following error message: The corresponding 'msfun_realtime_elapsed.tlc' file for the MATLAB S-function 'msfun_realtime_elapsed' in block 'realtime_pacer_example/Elapsed Real Time1' must be located in the current working directory, the MATLAB Sfunction directory 'C:\s\ShreeKarthiga\Desktop', or the directory 'C:\s\ShreeKarthiga\Desktop\tlc_c'. Is there any way out of this.
Jon Eskils 21 Nov 2016
Nathan 14 Oct 2016
https://www.mathworks.com/matlabcentral/fileexchange/29107-real-time-pacer-for-simulink
3/6
3/5/2019
Real-Time Pacer for Simulink - File Exchange - MATLAB Central Best real-time block implementation (tried 5 others that failed to work). The only one that I've seen with a good ree, and great functionality for custom timing. Thanks!
Gabriel H 21 Sep 2016
Mateus Antonio 28 Aug 2016
Mikel Iturbe 12 Aug 2016
Dinart Braga 8 Jun 2016
Despite a previous comment claiming that it does not work on Linux, I was able to run the example and use it in my simulations with Matlab 2016a on Ubuntu 16.04, out of the box.
Gautam, thank you very much. Your code solved my problem in 1 minute. Also, your install instructions could not be simpler. Nice job!
Pan Song 11 Apr 2016
sagar pawar 3 Apr 2016
Alon Tuchner 14 Mar 2016
Kenneth De Leener 30 Jan 2016
Michael Rice 23 Jul 2015
Krisando lalal 4 Jun 2015
Hey, thanks! I have problem with setting the path. There are any blocks in simulink library after adding the path. I simply put the whole folder to /s/Myname/Documents/MATLAB/realtimeP realtimeP - folder with m, s files and models.
works fine with me:)
please guide me....for using this blocks for speed control of dc motor with arduino with matlab...
Works very well.
Thanks much appreciated
I have MAC OS X Yosemite. This solutions did exactly what I wanted. Thank you for making this robust enough to work on multiple platforms over multiple releases.
and i run addpath('//Myname/Documents/MATLAB/realtimeP') I have MAC OS X, I would be gratefull for answer :) Chethan Pandarinath 15 Dec 2014
Diego 26 Nov 2014
Pramit Biswas 24 Apr 2014
Thanks, this worked well for me.
Hi it don't runs in linux
Elapsed real time is what I'm searching for. Very nice implementation. Superb.
https://www.mathworks.com/matlabcentral/fileexchange/29107-real-time-pacer-for-simulink
4/6
3/5/2019
Real-Time Pacer for Simulink - File Exchange - MATLAB Central Thank you very much for sharing.
Pieter Mosterman 12 Jul 2013
Jeff Orchard 10 Jun 2013
Walter 23 Mar 2012
Gustavo 20 Jul 2011
Very nice work!
Great functionality. Does exactly what I was looking for, including scaled real time. Perfect. Thanks so much, Gautam!
Nice. It does exactly what I want, and it was simple to use. Thanks!
This pacer for Labview works very well for slowing a SIMULINK developed control system to match the timing of a real time device. We are using it to provide control logic to a LabView DAQ system which then controls a hydraulic pump and motor system. To overcome the problem of Microsoft Operating System interrupts, we have added memory to the control system to for the time losses.
Updates 1 Sep 2016
1.0.0.1
Updated license
Requires Simulink
MATLAB Release Compatibility Created with R2008b Compatible with any release
Platform Compatibility Windows macOS Linux
Tags Add Tags pace
pick of the week
real time sychron...
Cancel
realtime
potw
real time
real time execution
real time simulation
synchronization
Save
Others Also ed Simulink Block for Real Time Execution 39 s
MATLAB for MinGW-w64 C/C++ Compiler 6653 s
https://www.mathworks.com/matlabcentral/fileexchange/29107-real-time-pacer-for-simulink
5/6
3/5/2019
Real-Time Pacer for Simulink - File Exchange - MATLAB Central
Real-Time Blockset 7.1 for Simulink 14 s
Acknowledgements Inspired: Mars Rover Robot - 2014 Competition, Simulink-Xplane10 Communication Via UDP, Arduino Temperature Control Lab for Simulink and MATLAB, Fidget Spinner 3DOF Gyro (Simscape Multibody), Sphero Connectivity Package
Discover Live Editor Create scripts with code, output, and formatted text in a single executable document.
Learn About Live Editor
RealTime_Pacer/ msfun_realtime_elapsed(block) msfun_realtime_pacer(block) slblocks
RealTime_Pacer/ realtime_pacer_example.mdl realtime_pacer_lib.mdl
mathworks.com © 1994-2019 The MathWorks, Inc. MATLAB and Simulink are ed trademarks of The MathWorks, Inc. See mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or ed trademarks of their respective holders.
https://www.mathworks.com/matlabcentral/fileexchange/29107-real-time-pacer-for-simulink
6/6