From: Thomas Marullo on
I am synchronizing the start of two xPCs and on one system, I am utilizing the multitasking capabilities in Simulink. I have a subsystem that is defined as an atomic unit and runs at 10x my base sample rate. The reason why is that there is a large matrix calculation inside that does not complete within the base sample rate. Without this, I am able to synchronize the two xPCs, starting at the same time and keeping their sample rates aligned. However, when I introduce this multitasking subsystem with Rate Transition blocks at both the in and out ports, this xPC does not remain in sync.

I learned with the Kernel Time block and a free running counter block that the second xPC starts exactly the same time as the first (interrupt generating xPC) and the first sample rate step is correct, but then there is a large kernel time delta during the second sample rate step. After this step, the kernel time goes back down to normal and is consistent for the remainder of the execution time. The free running counter on the 2nd xPC never loses its pace. This proves that the 2nd xPC initially starts, then incurs a large delay because of the multitasking block and then resumes with no problem. The problem though is that this shifts the sampling window and the xPCs are no longer in sync.

Is there a proper way to do multitasking so that this initial delay does not occur and the sample windows on both xPCs remain synchronized?