Simulink: How to run simulation in real time

4 ビュー (過去 30 日間)
Craig
Craig 2015 年 1 月 16 日
コメント済み: Craig 2015 年 1 月 29 日
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.

回答 (1 件)

Jan Houska
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
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
Craig
Craig 2015 年 1 月 29 日
Thank you!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModel Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by