To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example allows the user to run code at different rate inside of one while loop.
Description
When the user turns the switch off it will delay for two seconds and then turn it back on. There is also a flashing LED running that turns on and off every 100 milliseconds to demonstrate that the delays are ultimately different. The principle behind this that every time the Wait function is triggered, a shift register adds one to itself. Once the shift register accumulates to 20, it triggers the inner-most case structure and then resets; this is why it is called a "divisor". This is a good way to keep to tasks in synchronization with each other while running at different rates.
Requirements
Steps to Implement or Execute Code
Additional Information or References
VI Front Panel
VI Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Since there's a small amount of code within this loop, it may be beneficial to use a Wait(ms) function rather than a Wait Until Millisecond Multiple.
In the switch case, to demonstrate behaviour it may be handy to reset the Shift Register back to zero once it has succeeded the correction constant, rather than writing to the 'Switch' value (I don't have LabVIEW 2012 so I'm hazarding a guess at that's what is happening). This makes these two tasks susceptible to losing their sequential synchronisation by allowing the user to change the value of the boolean.