Real Time Simulation starts according to CPU clock
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Kaustubha Govind
on 1 Apr 2011
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 Comments
QiQin Zhan
on 30 Mar 2015
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
on 2 Apr 2015
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.
See Also
Categories
Find more on Model Preparation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!