0
votes

In simulink if I run any simulation, it follows an internal clock. I want to run these simulations in real time.

Example: if I use a PWM pulse generator and give it a sample time of 1 second, I expect that it will generate a sample at the end of every one second real-time but the simulink clock moves very very fast (every one second real time corresponds to about 1e6 seconds smulink time). Is there any way to synchronize the simulink clock with the real time clock?

I actually need to give input to hardware at the end of every 2 seconds in a loop and that is why this kind of synchronization is needed.

1

1 Answers

2
votes

Firstly note that Simulink is not a real-time environment, so anything you do related to this is not guaranteed to be anything but approximate in the timing achieved.

If your model runs faster than real-time then it can be paused at each time step until clock-time and simulation time are (approximately) equal. This is achieved by writing an S-Function.

There are several examples of doing this. For instance here or here.