Simulink: changing gain based on input

조회 수: 8 (최근 30일)
Ismail Sahraoui
Ismail Sahraoui 2023년 3월 13일
댓글: Ismail Sahraoui 2023년 3월 14일
Hey all, somewhat novice user to Simulink. I am attempting to change the gain based on an input signal of my gyroscope position. The range of values of the input signal are from 0 - pi, and ideally, I would like the gain to range from 0 - 255. For instance, when I rotate the gyroscope component 180 degrees (or pi), the output gain should be max (255), and when it is at rest, it should be 0. I am not able to find any similar answers asked online, and am unsure if Simulink has any block(s) which can do this, apart from maybe the ramp function?
I've tried using multiple if/else statements but to no avail.
Additional information: the goal is to change the LED brightness (0 = off, 255 = max brightness) on my arduino board based on the gyroscope position input.
Thank you!

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2023년 3월 13일
For this, it sounds like you just need a Gain block. Set the gain value to be 255/pi, when the input is 0, the output is 0. When the input is pi, the output is 255.
  댓글 수: 1
Ismail Sahraoui
Ismail Sahraoui 2023년 3월 14일
Thank you! Don't know why I didn't think of this

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

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by