View License

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

» Watch video

Highlights from
Real-Time Pacer for Simulink

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.8 | 16 ratings Rate this file 130 Downloads (last 30 days) File Size: 18.7 KB File ID: #29107 Version:
image thumbnail

Real-Time Pacer for Simulink



21 Oct 2010 (Updated )

Simulink block for forcing a simulation to run in real (wall clock) time

| Watch this File

File Information

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 supported Simulink platform. It does not support 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.


The following FX entries also implement "real time" functionality for Simulink. They are based on C S-functions and therefore support code generation.

* Simulink Real Time Execution (Real-Time Slower) (Filex# 21908)
* Real-Time Blockset 7.1 for Simulink (Filex# 3175)
* RTsync Blockset (Filex# 24975)


This file inspired Simulink Xplane10 Communication Via Udp, Sphero Connectivity Package, and Mars Rover Robot 2014 Competition.

Required Products Simulink
MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (18)
14 Oct 2016 Nathan

Nathan (view profile)

Best real-time block implementation (tried 5 others that failed to work).
The only one that I've seen with a good readme, and great functionality for custom timing.


21 Sep 2016 Gabriel H  
28 Aug 2016 Mateus Antonio  
12 Aug 2016 Mikel Iturbe

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.

08 Jun 2016 Dinart Braga

Gautam, thank you very much.
Your code solved my problem in 1 minute.

Also, your install instructions could not be simpler. Nice job!

11 Apr 2016 Pan Song

works fine with me:)

03 Apr 2016 sagar pawar

please guide me....for using this blocks for speed control of dc motor with arduino with matlab...

14 Mar 2016 Alon Tuchner

Works very well.

30 Jan 2016 Kenneth De Leener

Thanks much appreciated

23 Jul 2015 Michael Rice

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.

04 Jun 2015 Krisando lalal

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 /Users/Myusername/Documents/MATLAB/realtimeP
realtimeP - folder with m, s files and models.

and i run addpath('/User/Myusername/Documents/MATLAB/realtimeP')

I have MAC OS X, I would be gratefull for answer :)

Comment only
15 Dec 2014 Chethan Pandarinath

Thanks, this worked well for me.

26 Nov 2014 Diego

Diego (view profile)

Hi it don't runs in linux

24 Apr 2014 Pramit Biswas

Pramit Biswas (view profile)

Elapsed real time is what I'm searching for. Very nice implementation. Superb.

Thank you very much for sharing.

12 Jul 2013 Pieter Mosterman

Great functionality. Does exactly what I was looking for, including scaled real time. Perfect. Thanks so much, Gautam!

10 Jun 2013 Jeff Orchard

Nice. It does exactly what I want, and it was simple to use. Thanks!

23 Mar 2012 Walter

Walter (view profile)

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 account for the time losses.

20 Jul 2011 Gustavo

Gustavo (view profile)

Very nice work!

Comment only
01 Sep 2016

Updated license

Contact us