To download NI software, including the products shown below, visit ni.com/downloads.
This VI shows the different behavior of using local variables and queues in a producer/consumer design pattern with different loop rates
This vi is based on the producer consumer design pattern where the producer loop generates one point of a sine signal every 50ms. This data is stored in a local variable and in a queue that are read from different loops which rate is configurable. With this architecture it can be easily seen which is the effect of reading data from a variable and from a queue at rates that differ from the rates of the producer loop.
In the local variable consumer loop, the number of samples that are duplicated (in case the loop rate is faster than the producer loop rate) and the number of samples that are missed (in case the loop rate is slower than the producer loop rate) are calculated.
In the queue consumer loop, the number of samples in the queue when the loop rate is slower than the producer loop rate are calculated.
When the applications stops, all the data in the queue is retrieved.
4. Steps to Implement or Execute Code
5. Additional Information or References
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.