Real Time Simulation starts according to CPU clock
2 次查看(过去 30 天)
显示 更早的评论
Hi. Are there any methods in Matlab/Simulink to set the real-time application to run according to the CPU's clock?
I want the simulation to run for example at 10.30am, when I have already click the 'connect to target' and 'start real-time code' button at 10.28am for example. The application will not start to run only at exactly 10.30am.
Which means I want the application to start exactly at that time, so that i do not need to manaual run it at 10.30am.
Any reply will be appreciated. Thank you.
0 个评论
回答(1 个)
Kaustubha Govind
2011-4-1
You should be able to implement such a solution using the Real-Time Windows Target command-line API. In MATLAB, use the clock function to get the current time and wait until 10.30am to kick off the simulation. Note that using the Simulink menu options will override this script - so you should probably run this script at 10.28am, so it can start at exactly 10.30am for you.
4 个评论
QiQin Zhan
2015-3-30
Hello, I'm doing a simulink project that I think is somewhat related to real-time simulation, but I have some troubles recently.
I have imported a scara robot model from Solidworks to simMechanics and the simulation works pretty well. The following picture is the model in the simMechanics.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/182515/image.png)
The realization of the model by simMechanics blocks is as follows.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/182516/image.png)
The scara robot has two revolute joints and a prismatic joint. The motions of these joints are all designated by the 'timeseries variables' in the workspace. In the first cycle of motion, the robot works as it should. But in the second cycle, the 'timeseries variables' will be changed to generate different motions. Then my question is how to make the real-time simulation of the robot. I would be appreciated if you know how to solve this problem.
Jan Houska
2015-4-2
Just to add to Kaustubha's suggestion above - it should be enough to wait before the 'start' simulation command. So, you can set mode to 'external' and perform the 'connect' command immediately upon the start of the function, and only perform the 'start' command at the specified time. This will give better precision of the start time because the 'connect' operation may take a few seconds for more complex models.
另请参阅
类别
在 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!