Simulink timer subsystem example

version 1.0.0.0 (34.7 KB) by Marc Compere
A single-pulse input initiates elapsed time comparison to a desired timer duration.

493 Downloads

Updated 13 Jun 2018

View License

This is the Readme.txt file for the Simulink timer subsystem example.
The timer is a Simulink implementation of a (simulation) timer that can be armed
by sending it a 1-pulse ping signal to 'ping input'.

A single-pulse input initiates an elapsed time calculation that is subsequently
compared to a desired timer duration. The boolean result of this comparison
provides the timer state output.

A 1-pulse ping can be generated with the change detect block that looks for
any difference in it's input signal.

The timer is armed when a 1-pulse ping is detected which begins an elapsed
time calculation. Elapsed time is compared to the desired timer duration
and the timer state is held high while t_elapsed <= t_timer_duration.

Inside the timer subsystem is a 'triggered capture-and-hold' block that captures
the current simulation time when a high is detected on the ping input signal.

This timer subsystem has been tested on Matlab R2016b and R2018a and a close
variant of this subsystem has been used as far back as 2004.

The soft real time subsystem shown in the screenshot is not included in this
single-file release but is freely avaialable under the MathWorks File Exchange
entry titled "Soft Real Time Block for Pacing Simulink Simulations" at:
https://www.mathworks.com/matlabcentral/fileexchange/67520-soft-real-time-block-for-pacing-simulink-simulations

There is no requirement for the soft real time subsystem for this timer to work
but running in soft real time helps illustrate how the timer subsystem works with
the manual switch blocks.
Alternatively the native Simulink 'Pace' block also helps run the system at a
manageable pace for clear demonstration using the manual switch block.

----------------------------------------------------------------------------------

Marc Compere, comperem@gmail.com
created : 12 Jun 2018
modified: 12 Jun 2018

Cite As

Marc Compere (2022). Simulink timer subsystem example (https://www.mathworks.com/matlabcentral/fileexchange/67712-simulink-timer-subsystem-example), MATLAB Central File Exchange. Retrieved .

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

Community Treasure Hunt

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

Start Hunting!