Reading data continuously

When continuously reading a time series from TwinCAT, the client in LabVIEW™ continuously receives data packets from the ADS server. The data packets can be requested cyclically through a polling procedure or event-based as ADS notification. Both options are explained below.

Reading with polling cycle

Simple reading

With polling, the client sends requests to the server at a defined time interval. This can be easily built using the Low-Level VIs, for example. The ADS reader is initialized only once and requests a new data packet from TwinCAT with each cycle of the loop. With each cycle a new request is sent to the server and a corresponding response is awaited. The ADS reader is released once the termination condition of the loop has been reached. The image below shows the complete procedure in LabVIEW™.

Reading data continuously 1:

Example in LabVIEW™: Basic examples

The procedure is error-prone in the sense that it cannot be guaranteed that a cyclically changing value in the PLC is sampled without gaps. For this use case, it is recommended to work with e-notifications, which are described below.

Reading with LVB notification

Compared to Event-driven reading, the ADS notifications can also be read continuously with a specific polling cycle. Reading in this case happens asynchronously, as described in the graphic below. Here the ADS notifications are registered by the Thread1 and written into the LVBuffer. Later the LVBuffer is read with the Thread2.

Reading data continuously 2:

In contrast to Notification E-Buffered, no LabVIEW™ events are used in this case. Accordingly, the LabVIEW™ user has direct access to the LVBuffer. In LabVIEW™ the block diagram looks like this:

Reading data continuously 3:

Examples in LabVIEW™: Read Notification-LVBuffer Multiple

The block diagram uses the LVBuffer blocks (see LVBuffer):

  • Init LVBuffer Handle
  • Read From LVBuffer
  • LVBuffer status
  • Release LVBuffer Handle

The block diagram uses the ADS notification blocks:

Notice

Polling cycle

If the polling cycle is slower than the notification cycle time, the LVBuffer may overflow and samples may be lost.