|On this page…|
SimMechanics™ animation videos play at a fixed speed of 30 frames per second (fps), with each frame corresponding to a simulation time step. When the step size differs from the 1/30 second duration of a video frame, the video speed differs from the simulation speed. To ensure that the two speeds are equal, you must adjust the configuration parameters for your model. The exact approach depends on the type of solver that you select: variable-step or fixed-step.
Variable-step solvers are commonly used in SimMechanics simulations. With a variable-step solver, the step size can vary between minimum and maximum values that you specify in your model's Configuration Parameters menu. Because each video frame corresponds to a simulation step, a variable step size can introduce time distortion into the video.
For example, when the step size is larger than 1/30 second, it must shrink to fit the 1/30 second duration of a video frame, causing the video to appear faster than the simulation. Similarly, when the step size is smaller than 1/30 second, it must expand to fit the 1/30 second duration of a video frame, causing the video to appear slower than the simulation.
To avoid time distortion in the video, you must sample the simulation at regularly spaced intervals. By using a 1/30 second sampling time interval, you can ensure that the resulting video plays at the simulation speed:
On the Simulink® menu bar, select Simulation > Model Configuration Parameters.
On the Configuration Parameters tree browser, select Data Import/Export.
In the Output Options drop-down list of the Save options pane, select Produce specified output only.
In Output times, enter (1:N)*dt, replacing N with the number of data samples, and dt with the sampling time interval in seconds, 1/30. This array specifies the times at which to record the frames of the video.
In terms of the duration of a simulation T, the number of samples N equals T/dt. For example, if the simulation lasts ten seconds (T = 10) and the sampling time interval is 1/30 second (dt = 1/30), then N = 300. In this case, the array you enter in Output times must be (1:300)*1/30.
If you change the time interval dt in the array from 1/30, the video playback speed changes accordingly. Changing dt to 1/15 causes the resulting video to play at twice the simulation speed. Similarly, changing dt to 1/60 second causes the resulting video to play at half the simulation speed.
Fixed-step solvers are less commonly used in SimMechanics simulations. With a fixed-step solver, the simulation step size remains constant at a value that you specify in your model's Configuration Parameters menu. Because the step size is constant, the resulting video displays no time distortion. It can, however, play at a different speed than the simulation.
To change the playback speed of the video, you must change the step size of the simulation. Change the step size to 1/30 second to ensure that the video plays at the same speed as the simulation:
On the Simulink menu bar, select Simulation > Model Configuration Parameters.
On the Solver options pane, check that Type is set to Fixed-step.
In Fixed-step size (fundamental sample time), enter 1/30.
Changing the step size from 1/30 causes the animation video to play at a different speed. The effect of changing the step size is similar to the effect of changing the sampling time interval for a variable-step solver. Changing the step size to 2/30 causes the resulting video to play at twice the simulation speed. Similarly, changing the step size to 1/60 causes the resulting video to play at half the simulation speed.