How to simulate a limit switch in SIMULINK?
20 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Peter O
on 14 Aug 2021
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.
More Answers (0)
See Also
Categories
Find more on Upgrading Hydraulic Models to Use Isothermal Liquid Blocks 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!