Simulink: How to run simulation in real time

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일

0 개 추천

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

Craig
Craig 2015년 1월 29일
Thanks for your answer. I have Real-Time Windows Target installed. Which is the block which will synchronize model execution with real time? And how do I configure it?
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!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Real-Time Model Preparation에 대해 자세히 알아보기

질문:

2015년 1월 16일

댓글:

2015년 1월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by