How can I set a block parameter dynamically during simulation? (e.g. with workspace variable)
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
Hi there! I have encountered a problem while using Simmechanics: I have a masked block with a single parameter "height". I want this parameter to be changed dynamically during simulation. This means, instead of writing a value in the parameters field, I want to use a workspace variable. I have tried using a workspace variable, but the block reads the variable only on simulation start and then never again. How can I solve this? Thank you very much, Hans
채택된 답변
What does that "height" variable reference? If it's inside SimMechanics blocks, then that value cannot be changed mid-simulation. It's only if your variable is on a Simulink block (Constant, Gain, etc.) that this will work.
For example,
- If "height" can be fed in using a Simulink Constant block that is connected to a motion-actuated Joint block in SimMechanics, then this approach would work.
- If "height" is a parameter in a Solid or Rigid Transform block, then you will not be able to change these values mid-simulation.
Also, if your model has the possibility for a tunable "height" variable, you still need to pause the simulation, update the diagram, and then resume the simulation for the changes to take effect.
- Sebastian
댓글 수: 8
I'm modelling a fuel tank. The tank is modelled as a solid. Its shape is defined by a function, which calculates a 2d shape, which is later rotated to create a 3d object. Here, "height", is the variable which defines the filling level of the tank. During the simulation, the filling level changes. This is what I want to model. The variable is used as a parameter in the simmechanics block "cross section" entry. If I understand you correctly, only simulink blocks can have "dynamic" parameters, but simmechanics blocks not? This is weird, because I've already created a simmechanics block with dynamic mass/inertia and it worked. But in this new case, with a dynamic geometry, it seems to not work....
Are you using SimMechanics First Generation blocks? In this one you can specify variable mass/inertia.
Also, if you're modeling the filling of a tank, you could use variable mass/inertia to take care of those dynamics, right?
I'm using SimMechanics Second generation. Is it possible to mix first and second generation?
After your answer I re-evaluated my model with the dynamic mass. I've found an error, which fooled me into thinking the mass has changed. :(
So, is it true that the parameters of a SimMechanics block cannot be changed during simulation? If this is true, I have one final question: is there any way to create a block with a variable mass in second generation SimMechanics?
I wouldn't recommend mixing first and second generation -- all the masses/inertias/forces/moments wouldn't necessarily translate if you try to communicate between two different types of blocks using regular Simulink signals.
And that's right, variable mass/inertia is one of the 2 features that (as of R2015a) is available in First Generation but not in Second Generation. The other is the point-on-curve constraint.
One way that you can still establish a variable-mass situation is by using an External Force + Torque block to apply a variable force to your system. For example, if you're simply modeling the vertical (up-down) dynamics of a tank filling up, you can take advantage of this assumption and apply a variable downward force equal to the weight of the water in the tank. That is,
Force = Density*Area*Height
where Height could be a time-varying signal that affects that downward force acting on your mechanical system.
If you need to worry about translation and rotation in other directions, I suppose you could try add more forces and torques about other axes using that same External Force/Torque block.
- Sebastian
Thank you for that hint!
Would it be possible to write a Simscape module with dynamic mass and use it in a SimMechanics model?
I wouldn't recommend it. If you use a mass on the Simscape side, it will only affect that joint -- however, all the masses/inertias for all dimensions on the SimMechanics side will not consider this mass, thereby leading to potential inconsistencies.
could you please give me some advice on hou to update the datas from workspace to simulink ,while the the simulation in on ? i have datas from sensors varing with time ,now i want to send them to simulink model to get a 'real-time' simulation .
Many thanks from china
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multibody Dynamics에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
