File Exchange

image thumbnail

Simulink Block for Real Time Execution

version 1.2.0.0 (8.82 KB) by Ivo Houtzager
C-MEX S-function that reduces the execution speed of a model close to real time.

18 Downloads

Updated 11 Jul 2015

View Version History

View License

This block is a version of the block given in the submission "Simulink Real Time Execution" (File ID:#21908) with some enhanced features. These blocks could be used to reduce the speed of a Simulink model so that it can be observed running in real time. Compared to the previous submission this version takes the execution time between the calculation steps into account. Furthermore, a high-resolution performance counter is used to get the time that exceeds one microsecond accuracy. As last the remaining time is calculated and given as output.

Cite As

Ivo Houtzager (2021). Simulink Block for Real Time Execution (https://www.mathworks.com/matlabcentral/fileexchange/30953-simulink-block-for-real-time-execution), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (19)

Daniel Meer

I also got following error:
sfun_rttime.c:(.text+0x1a0): undefined reference to `hightimer'

Defining the hightimer() function as static solved the issue:
__inline static double hightimer()

Marcos M

Works when I compile the function first using the mex command:
mex -O sfun_rttime.c

It's what I was looking for. Thank you.

Nicola Pambakian

Mmh I get this error in R2019a:
Error in S-function 'rttime_example/Timer for Real-Time': S-Function 'sfun_rttime' does not exist

Hossein Rezazadeh

only works in simulink. can not be compiled on target hardware.

Firas Abi Farraj

Qingyu

Great contribution! Appreciate it!

Fabio Cassinelli

sfun_rttime.obj:sfun_rttime.c:(.text+0x1c0): undefined reference to `hightimer'
sfun_rttime.obj:sfun_rttime.c:(.text+0x1f0): undefined reference to `hightimer'
sfun_rttime.obj:sfun_rttime.c:(.text+0x219): undefined reference to `hightimer'

Durango

Amadeusz Jacobs

Rodrigo Rolle

Al ReD

Bongani Maseko

Carlos

This works embedded too.

Biswa Dhal

Nandor

When trying to compile I get this error message:

sfun_rttime.o: In function `hightimer':
sfun_rttime.c:(.text+0x2085): undefined reference to `clock_gettime'
sfun_rttime.o: In function `mdlOutputs':
sfun_rttime.c:(.text+0x2116): undefined reference to `clock_gettime'
sfun_rttime.c:(.text+0x2191): undefined reference to `clock_gettime'
sfun_rttime.c:(.text+0x21d4): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status

mex: link of 'sfun_rttime.mexa64"' failed.

could anyone advise please? Many thanks

Pulkit Goyal

Thanks a lot. It worked!

Ivo Houtzager

You have to compile the function first using the mex command.

mex -O sfun_rttime.c

Pulkit Goyal

I keep getting this error: Error in S-function 'rttime_example/Timer for Real-Time': S-Function 'sfun_rttime' does not exist.

Can someone please help me with this?

jrocket567

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!