synch a .exe with simulink simulation
1 view (last 30 days)
Hi yall i am running matlab r2009a with simulink. I have a 4 degree of freedom robot being controlled through my simulink block diagram and Quarc target. I also have a .exe which runs as a start callback function when i hit start on my simulation. This program controls a camera that takes a picture of the robot every 5 seconds...The thing im having problems with is getting the program synched with simulink, so is there a way i can have the program grab the simulation time and start with that time or is there a way i can have simulink grab the programs runtime and run the simulation from that time? or any other simple ways to synch the 2 programs? my .exe is c++. Thanks Robert
Seth Popinchalk on 12 Feb 2011
It is best to let Simulink keep track of time for you, and try to interface with your camera when Simulink needs a new frame of data. Often, interfacing with real hardware requires that you run your simulation in pseudo-real-time or real-time depending on the application. This can be done only if the simulation currently runs faster than real time.
You can use an S-function to accomplish both goals of pacing the simulation and interfacing to your camera hardware. At the beginning of the simulation when tsim=0, capture the real time from your system treal0. With each step of the S-function you can pause just long enough to let treal catch up with tsim. For each step of the simulation you will need to pause until treal-(tsim+treal0) is greater than or equal to 0.
The benefit of using the S-function for your camera interface too is that it will ensure you synchronize captures at the right times during the simulation.
If all you need to do is slow the simulation down to real-time, the Simulation Pace block from the Aeropsace Blockset provides this capability.