Use a channel wire to communicate between two (or more) parallel process loops contained within the same VI, and use a channel wire to stop parallel loops with one "stop" button. Requires LabVIEW 2016 or later version.
Use cases
Communicate data, control, and status between two or more parallel process loops contained within the same VI (“VI-scoped”)
Make the latest value of a variable available to other process loops (tag)
Establish point-to-point lossless communication (stream)
Stop multiple parallel loops from a single control
Makes dataflow visually evident, i.e., can see a wire spanning process loop boundaries
Provides a variety of data communication schemes:
Stream: buffered channel between two endpoints, operates like a queue or FIFO (first-in first-out) buffer; options for lossless, lossy, single-element, and real-time streams
Tag: single-value lossy buffer that allows multiple writers and readers
Messenger: many-to-many communications channel
“Real Time Stream” channel wire links deterministic (timed) process loops to nondeterministic loops without inducing jitter
IMPORTANT: Stream-style channel wire readers do not time out by default and will prevent process loops from stopping even when their “stop” condition is true. Either wire a time-out value to each reader or wire the “stop” condition wire to the “last element? (F)” input of each writer to close the stream.
LabVIEW block diagram elements
Channel wire endpoint writers and readers are subVIs created “on the fly” instead of existing in subpalettes. Simply right-click on an output terminal or wire and select “Create | Channel Writer” (similar to the way you create an indicator); right-click on a channel writer output or channel wire and select “Create | Channel Reader”.
Expect to see a noticeable delay as the subVI is constructed.
Example code
Connect your Academic RIO Device to your PC using USBLAN, Ethernet, or Wi-Fi. NOTE: Not all Academic RIO Devices have Ethernet and Wi-Fi connectivity options.
Download and unpack the
rt_channel-wire.zip (for use with NI myRIO 1900)
or the
NIELVISIII-rt_channel-wire.zip (for use with NI ELVIS III)
archive, and then double-click the ".lvproj" file to open the project. NOTE: This project was written for a NI myRIO 1900 or NI ELVIS III connected by USBLAN at IP address 172.22.11.2.
If you are using a different IP address or another Academic RIO Device (Example: NI myRIO 1950 or NI RIO Control Module) do the following:
If using the NI myRIO 1950 or NI RIO Control Module start with the NI myRIO 1900 Archive.
Different IP address: Right-click on the "NI myRIO 1900" Device, choose "Properties", and then enter the new IP address
Different device:
Right-click on the top of the project hierarchy, select "New Targets and Devices", keep the "Existing target or device" option, and then find and select your particular device
Select all of the components under the "NI myRIO 1900" device: click the first one and then shift+click the last one
Drag the selected components to the new device
Right-click the "NI myRIO 1900" device and select "Remove from project"
Run the “RT Main” VI:
The “fast counter” in Process Loop #1 increments once each loop cycle
The Boolean “reset” generated by Process Loop #2 resets the fast counter
The “slow counter” in Process Loop #2 increments each time the fast counter reaches 10 counts; this condition also enables the “reset” signal
The “slowest counter” in Process Loop #3 increments every two seconds
Channel Wires (http://www.ni.com/white-paper/53423/en/)
From the overview: "The channel wire, a new, feature in LabVIEW 2016, simplifies the programming involved in data transfer between parallel loops, such as the common producer/consumer pattern. This white paper provides an introduction to channel wires and highlights specific use cases".