How to simulate a limit switch in SIMULINK?

조회 수: 17 (최근 30일)
Kirill Dolgiy
Kirill Dolgiy 2021년 8월 14일
댓글: Kirill Dolgiy 2021년 8월 15일
Hi! I'm strugling to find a solution of my problem: i want to simulate a hydraulic model with a double acting hydraulic cylinder that changes the acting direction at a moment when the displacement of the rod reaches some value (for example 0.5 m) in a loop (see picture). I want it to check current displacement and return 1 if displacement is below 0.5 m and after it reaches 0.5 m i want to get -1. I tried to use "detect change" but unsuccessfully.
In general the problem i faced is inability to change the signal permanently. When i get -1 the rod goes back 1 step and than displacement is again < 0.5 m and the rod goes forward. And it happens in a loop.
I don't use "repeating sequence interpolated" because i will simulate the model with different speed of the rod but i want the direction of the action to be changed every time at the same moment.
You can find sample model in attachment. Thanks a lot!

채택된 답변

Peter O
Peter O 2021년 8월 14일
Try something like this. It's a little quickly done, so I'm sure there's room for optimization or elegance, but this works.
You need to track the velocity or direction command as a state in addition to the position. Pass the current one through if it's not outside of the upper or lower limit, and set the up/down direction if it passes it.
Take a look at the backlash (hysteresis) block too. It may not be useful here, but it's helpful to model things like stiction, which you might need if you're working with a hydraulic cylinder.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Upgrading Hydraulic Models to Use Isothermal Liquid Blocks에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by