Writing Values to VeriStand Channels Without Data Loss Using VeriStand API

Updated Oct 16, 2023

Reported In

Software

  • VeriStand
  • LabVIEW

Issue Details

When writing values to a VeriStand channel using LabVIEW VeriStand API - Set Single/Multiple Channel Value VI, I noticed that some values were lost when writing quickly.

How can I avoid losing the value written by using Set Single/Multiple Channel Value VI?
 
VeriStand API.png

Solution

When you write a value from LabVIEW to VeriStand using Set Single/Multiple Channel Value VI, the VeriStand Gateway receives the value and passes the value to the VeriStand Engine. If a new value is written to VeriStand Gateway faster than it can be written to VeriStand Gateway, the old value will be overwritten and lost.

To ensure a handshake between write and read from VeriStand Gateway and VeriStand Engine, it is recommended to use blocking method. Blocking method means, after calling Set Channel Values, immediately read back the variable and compare with the written value using Get Channel Values VI. Below is an example:
 
Writing - Reading - Blocking Example.png
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram
 

Additional Information

Overview the system at the high level, there are three components involved:
  1. LabVIEW, where Set Single/Multiple Channel Value is being called
  2. VeriStand Gateway, Host Computer (Windows)
    https://www.ni.com/docs/en-US/bundle/veristand/page/vs-engine.html

  1. VeriStand Engine, Target Computer (Windows/RTOS)
    https://www.ni.com/docs/en-US/bundle/veristand/page/project-components.html

Gateway and VeriStand Engine.png

When Set Single/Multiple Channel Value is being called, here are what will happen:
  1. Set Single/Multiple Channel Value is sending a TCP packet from VeriStand Gateway to VeriStand Engine’s Communication Loops Receive.
  2. In VeriStand Engine, the packets are read and processed one at a time in a low priority TCP Loop (stored in RT FIFO with size of 20 arrays of 512 elements).

Please note that this approach of data transfer is not deterministic.
  1. Calling Set Single/Multiple Channel Value 21 times will cause RT FIFO to overflow, when the 21st call occurs, it can’t be pushed into the RT FIFO
  2. Calling Set Single/Multiple Channel Value multiple times for 512 channel values at a time is the best possible use case for the throughput. However, the TCP Loop will report an error if you write more than 512 values
Based on our findings, sustainable data rate is half of the PCL rate. For example, if you are requiring 50Hz data rate, your PCL should be at least at 100Hz. This performance is at best scenario, dependent on network connection, CPU Load on the RT controller and the inherent non-deterministic nature of Windows (specifically on communication from Windows to RT through VeriStand Gateway and the TCP loops being low priority in the VeriStand Engine)