Simulink: How to run simulation in real time

5 visualizaciones (últimos 30 días)
Craig
Craig el 16 de En. de 2015
Comentada: Craig el 29 de En. de 2015
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.

Respuestas (1)

Jan Houska
Jan Houska el 27 de En. de 2015
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 comentarios
Jan Houska
Jan Houska el 29 de En. de 2015
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 el 29 de En. de 2015
Thank you!

Iniciar sesión para comentar.

Categorías

Más información sobre Model Preparation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by