Simulink: How to run simulation in real time
조회 수: 4 (최근 30일)
이전 댓글 표시
I am using the joystick input block from the 3d animation library, and I am using it to control a robot arm imported from solidworks using the simmechanics simscape package. The coordiantes of the end effector are displayed in a simulink display sink block.
The problem is that the simulation runs much faster than real time, so I puch the joystick up, and the coordiates of the end effector respond imediately, and it would seem like the robot arm had lifted in a fraction of a second, however if you look at the simulation time it has taken about 10 seconds.
the Mechanics explorer window records the simulation and can play it back in real time, but because it is a recording it is completley out of sinc with my actions on the joystick.
I need the simulink simulation to run in real time, how do I do this?
Thanks!
EDIT:
I have found a temporary solution. I changed the simulation to fixed step, and then by trial and error changed the value of the step size so the simulation time roughly matches real time. Also, as long as the simulation time is slighlty slower than real time, the mechanics exploer window plays the simulation at its most recent values, so it is completley in sync with the joystick inputs. However, I would still like a propper way to play the simulation in real time as this method isn't perfect.
댓글 수: 0
답변 (1개)
Jan Houska
2015년 1월 27일
You may want to try Real-Time Windows Target www.mathworks.com/products/rtwt . It contains a block to synchronize model execution with real time.
댓글 수: 3
Jan Houska
2015년 1월 29일
The name of the block is Real-Time Sync and you just put it in your model. Its Sample time parameter specifies synchronization granularity (how often you synchronize) - the default of 0.1 should be a good starting point.
You will need to install Real-Time Windows Target real-time kernel if you haven't installed it already - this is done by
rtwintgt -setup
참고 항목
카테고리
Help Center 및 File Exchange에서 Model Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!