필터 지우기
필터 지우기

Help with State Transition Table

조회 수: 1 (최근 30일)
Joaquin
Joaquin 2023년 11월 17일
댓글: Fangjun Jiang 2023년 11월 18일
Greetings, I am diong a project where I am creating an air piano inside simulink with my arduino uno board. The table is for lighting three LED lights based on different distance inputs from an ultrasound sensor. The output I am currently getting is that only my green LED lights up despite inputting several different distances. any help or tips would be greatly appreciated. I have also included a picture of my blocks diagram in simulink.

채택된 답변

Joaquin
Joaquin 2023년 11월 18일
Thank you so much! This solved the issue I was having, I just needed to delete the state_off row and the fourth else-if, and change all of the states that were in $Self to % Ignore% and the program ran flawlessly.
  댓글 수: 2
madhan ravi
madhan ravi 2023년 11월 18일
But did you see @Fangjuns answer? The condition that you are using is still wrong.
Fangjun Jiang
Fangjun Jiang 2023년 11월 18일
The below example explains why you got the "correct" result after making the "wrong" changes.
After making the changes your described, please run a simulation where "distance" is fed with a Constant block with value 35. You will see the state stays at Green, which is obviously wrong.
You could attach your model for others to try.
distance=35;
[0<distance<10]
ans = logical
1

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2023년 11월 17일
편집: Fangjun Jiang 2023년 11월 17일
[0<distance<10] is not the correct syntax. Your state stays at the default.
changing all to style [0<distance && distance<10] should resolve the issue.
  댓글 수: 2
Fangjun Jiang
Fangjun Jiang 2023년 11월 17일
편집: Fangjun Jiang 2023년 11월 17일
distance=35;
[0<distance<10]
ans = logical
1
This is equivalant to
(0<distance) < 10
ans = logical
1
madhan ravi
madhan ravi 2023년 11월 17일
편집: madhan ravi 2023년 11월 17일

yes, proper logical and should be used for stateflow conditions in the similar way done in MATLAB

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by