Create an index with stateflow that only increments one at the time
Show older comments
Hi there,
Im trying to build a index with stateflow, but I want to increment only once when the input signal is high and again when it goes from low to high.
I have done this with blocks but now I want to use a stateflow chart.
Any suggestion?

4 Comments
Walter Roberson
on 8 Mar 2021
Do I understand correctly that you want the logic:
- initial counter value 0
- if the initial value of the state is High, set the counter value to 1
- after that, increment the counter only when it goes from low to high ?
If so then the two first parts can be handled by initializing the counter to (initial state == high) and after that you just have an increment when going from low to high.
Do you have to worry about de-bouncing ?
Pedro Marques
on 9 Mar 2021
Walter Roberson
on 9 Mar 2021
Unfortunately I do not have enough experience to interpret that chart, but it does not look right to me.
Pedro Marques
on 9 Mar 2021
Answers (0)
Categories
Find more on Stateflow 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!