Synchronizing the Execution of Multiple Loops

By default, each loop iteration executes as quickly as possible based on the code inside the loop. However, consider a program that includes multiple loops that contain code requiring different amounts of time to execute. You might want to control the rate at which those loops execute in order to synchronize their execution and ensure that the loops begin each iteration at the same time. Use Wait Until Next Multiple to do this.

What to Use

What to Do

Create the following diagram to synchronize the execution of multiple loops.

Customize the gray sections for your unique programming goals.


1378

1378

Wire the same value to the inputs of the Wait Until Next Multiple nodes placed on the subdiagram of each loop. The loops wait until the value of the system clock becomes a multiple of the specified input before beginning each iteration. Therefore, the loops begin each iteration at exactly the same time.

1378

When specifying a value for the input of Wait Until Next Multiple, ensure that the value is greater than the time required to execute the code inside the loop. If a loop contains code that takes longer to execute than the time specified, Wait Until Next Multiple has no effect on the execution speed of the loop.