![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1739456/image.png)
I know it seems easy, but I'm having trouble doing this, Can anyone tell me how to design a timer of 2 sec using simulink or stateflow? or is there any inbuild block for this?
4 views (last 30 days)
Show older comments
I know it seems easy, but I'm having trouble doing this, Can anyone tell me how to design a timer of 2 sec using simulink or stateflow? or is there any inbuild block for this? because I couldent find the same in my license version.
0 Comments
Answers (1)
Suman
on 23 Jul 2024
Hi Satish,
You can look at this sample model to build a timer / counter using Simulink Blocks: https://www.mathworks.com/matlabcentral/fileexchange/44534-simulink-timer-counter
You can find the example model in the Models tab and you may coustomize it as per you needs.
If you want a simple delay timer, you can model it something like this:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1739456/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1739456/image.png)
You can set the inputSignal to be 1 when you wan't to start the timer and the timerSetting value to be the time in seconds you want to count.
The way this model works is that say the inputSignal is 1(high) at any moment, the start_output is also 1(high) and then the digClock keeps adding on to the inputSignal every second and once this becomes greater than the time specified by the timerSetting value, the stop_output becomes 1(high) and switch makes start_output to be 0(low).
I hope that helps!
0 Comments
See Also
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!