Increment and decrement counter

Hello,
How to increment counter upto 5 and after reaching to 5 start decrement it till 0 and again start increment from 0 to 5 and from 5 to 0 continuously, by using simulink blocks.
Thank you

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 19 Jul. 2020

0 Stimmen

Use a 'Unit Delay' block. That is the counter. Add a number to it. The number is either 1 or -1.
Use S-R Flip-Flop block to generate the number. Its output is either 1 or 0 but you can multiple it by 2 and then minus 1 to get either 1 or -1.
Compare the counter value with 5 and 0 to get the Set and Reset signal for the S-R Flip-Flop block.

3 Kommentare

shubham diwate
shubham diwate am 20 Jul. 2020
Hello,
Yes I can implement by using up and down counter but I am not able to find switching from up to down counter.
Is there any solution using just simulink blocks not by electronics toolbox?
Fangjun Jiang
Fangjun Jiang am 20 Jul. 2020
All blocks come from Simulink.
chaithanya
chaithanya am 27 Jul. 2023
why do we use SR flip flop

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Gefragt:

am 19 Jul. 2020

Kommentiert:

am 27 Jul. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by