Clear Filters
Clear Filters

Manual Switch management for Simscape simulation

10 views (last 30 days)
I'm using Manual Switches in a Simscape simulation with Simulink Desktop Real-Time to change a valve states (close <-> open). In doing this I'm encountering to different inconvenient:
  1. I'm feeding a derivative state block, the valve, with a non-continuous signal generated by the manual switch
  2. Every time I stop the simulation, I need to reset the state of the manual switches since they remain in the last position
First issue: since the manual switch will be replaced by signal coming from PLC that is non continuous as well, I need something to put in the middle between the valve and the non-continuous signal to manage this discontinuity (if it exists).
Second issue: I thought to use the "setparam" function but there are a lot of manual switches, so I want to ask if there is a faster way.

Answers (1)

Jan Houska
Jan Houska on 29 Jul 2023
Hi,
for the first issue, if the discontinuity is the problem, a simple first-order delay should do the trick. However, feeding discontinuities into the input of derivatives may also mean that you have oversimplified your model and there's some dynamic behavior that you may have neglected. This is difficult to say without actually seeing the model.
For the second issue, an alternative way would be just to close the model without saving it, then re-open it. This probably won't be faster than set_param but can be simpler. However, I'd probably still prefer finding the manual switches by find_system and then using set_param to set their values.
Good Luck, Jan

Community Treasure Hunt

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

Start Hunting!