Generate a timer from 0 to the required period and when it reaches the period the timer must reset and start again

3 views (last 30 days)
I want to generate a timer which runs from 0 to the required time given and when the time is reached, the timer must reset and must start again from 0 to the time period this must happen until the stop time of the simulink is reached.
I tried with resettable system, mod and ramp block but nothing gives the required output

Answers (1)

Umang Pandey
Umang Pandey on 28 Nov 2023
Edited: Umang Pandey on 28 Nov 2023
Hi,
I understand that you're trying to implement a periodic timer in Simulink, which resets after reaching a specified time and starts over until the simulation stop time is reached.
A combination of the following Simulink blocks can be used to achieve this:
  • "Clock" block to monitor the current simulation time,
  • "Constant" block to set the desired timer duration, and
  • "Mod" block to implement the periodic reset.
Here is an example:
The output from the "Mod" block yields the current simulation time modulo the specified timer duration, which is essentially performing the reset operation.
Here’s the output of the “Scope” block:
The model has been attached for reference. Hope this helps.
Best,
Umang

Categories

Find more on Simulink Functions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!