How to simulate a limit switch in SIMULINK?
19 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Upgrading Hydraulic Models to Use Isothermal Liquid Blocks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!