Part 5: Sending RT Data to the Host Computer

In this part of the tutorial you use Network Streams functions to send streaming data across the network. Refer to the Data Communication Methods in LabVIEW topic in the LabVIEW Help for information about other methods of data transfer.

Configuring the Network Stream Writer

To configure a network stream for sending data, you must specify the writer name, data type, and writer buffer size. These properties specify the endpoint sending the data, the type of data being sent, and how much data to send.

Complete the following steps to configure a Create Network Stream Writer Endpoint function:

  1. Add a Create Network Stream Writer Endpoint function to the block diagram of Real-Time Main.vi.
  2. Delete the error wire between the RT FIFO Create function and the RT FIFO Read function.
  3. Connect the error wires sequentially between the RT FIFO Create function, the Create Network Stream Writer Endpoint function, and the RT FIFO Read function.
  4. Right-click the writer name input of the Create Network Stream Writer Endpoint function and select Create»Constant from the short-cut menu.
  5. Enter RTAcqData as the constant to name the writer endpoint.
  6. Wire a DBL Numeric Constant to the data type input of the Create Network Stream Writer Endpoint function.
  7. Right-click the writer buffer size input of the Create Network Stream Writer Endpoint function and select Create»Constant from the short-cut menu.
    Note   The buffer size you set should be large enough to accommodate the data you need to stream. Using an inadequate buffer size results in errors.
  8. Set the constant to 4096.

Transferring Data from the RT FIFO Function to the Network Stream

Like RT FIFOs, network streams transfer buffered data. However, because networks streams transfer data over the network instead of within the RT target, they do not guarantee deterministic communication. All network communication is inherently non-deterministic because execution time and transfer rates over a network vary from iteration to iteration.

Complete the following steps to set up a network stream writer to stream data to the network:

  1. Select False from the Case structure selector label.
  2. Add a Write Single Element to Stream function within the Case structure.
  3. Delete the error wire running through the Case structure.
  4. Connect the error wires sequentially between the RT FIFO Read function, the Write Single Element to Stream function, and the Active? variable.
  5. Wire the writer endpoint output of the Create Network Stream Writer Endpoint function to the endpoint in input of the Write Single Element to Stream function.
  6. Delete the error out indicator.
  7. Wire the element out output of the RT FIFO Read function to the data in input of the Write Single Element to Stream function.
  8. Add a Destroy Stream Endpoint function outside and to the right of the loops. This function closes the network stream safely.
  9. Delete the error wire between the Merge Errors function and the RT FIFO Delete function.
  10. Connect the error wires sequentially between the Merge Errors function, the Destroy Stream Endpoint function, and the RT FIFO Delete function.
  11. Wire the endpoint out output of the Write Single Element to Stream function to the endpoint in input of the Destroy Stream Endpoint function.
  12. Select True from the Case structure selector label.
  13. Connect the error wire through the Case structure.
  14. Connect the endpoint wire through the Case structure.
  15. Save the VI.

Result

Do not run your VI at this time. The network stream can send data using the writer endpoint, but it cannot receive data until you add a reader endpoint. You can test your VI after you add a reader endpoint in the next part of this tutorial.