MATLAB Answers

Simscape Multibody - model does not react to slider gain changes without stopping and starting the simulation again

3 views (last 30 days)
Martin Novak
Martin Novak on 20 May 2021
Answered: Martin Novak on 24 May 2021
Hi,
i am trying to make a simple mechanism in Simscape Multibody. A fixed platform with a rotating leg. I would like that the rotation is controlled by the user, with a slider gain. The result is viewed in Mechanics Explorer. However the changes in the gain are taken into account ONLY when I stop the simulation and then start it again. The animation viewed in Mechanics Explorer does not display the changes.
I have connected a scope to the Sensing (position) output of the joint and it does display the changing gain, but the joint is not moving.
When i replace the source with a sine wave, the joint rotates corectly.
Any ideas what is wrong? Model is attached.
Martin

Accepted Answer

Yifeng Tang
Yifeng Tang on 21 May 2021
The answer is that the slider gain actually is working as intended. It's changing the position of the swing bar, but we were not seeing that in the Mechanics Explorer, because your computer is too FAST :p
OK, seriously, the slider gain works. The simulation clock is running at about 100 times faster than the wall clock (YMMV), because this is a fairly simple model. The Mechanics Explorer, however, is playing the animation at 1x wall clock speed by default. So when you change anything on the slider gain, it's at like 300 sec simulation time (probably even longer because nothing is happening and the simulation just runs FAST), and you'll need to wait that long for it to show up in the Mechanics Explorer.
The solution is to slow the simulation down by "pacing it". Very simple to do: https://www.mathworks.com/help/simulink/ug/simulation-pacing.html
Make it 1x wall clock and you'll see the action of your slider in real speed.
Happy Modeling!

Community Treasure Hunt

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

Start Hunting!