Technical Notes
VXI Data Buffering Methods
Introduction
The objective in many data acquisition applications is to accurately measure the time history of one or more signals. The V200, V207, V208 and V213 provide internal programmable sample clocks that initiate a scan of a ll channels associated with the ADC on a precise time interval. Thus, sampled data for each channel is associated with the sample clock. A number of methods are provided to move sampled data. They are shown in the following table:
|
Readout Method |
Data Access |
Availability |
|
Ping-Pong memory |
via VXIbus |
standard on all of the above modules |
|
Multibuffer memory |
via VXIbus |
an option all of the above modules |
|
Digi-bus |
via the VXI Local bus |
an option on the V207 and the V208 |
This document discusses the various readout methods, including their features, limitations and general application guidelines. The results in a particular system are dependant on a wide range of factors. Our technical staff should be consulted if you have any questions regarding a particular application.
Ping-Pong Memory
The Ping-Pong memory provides a double-buffering method for acquiring data. This two-segment memory is accessible from the VXIbus. One segment co ntains data values for all active channels from the previous sample clock "tick," while the data values from the current "tick" are being transferred from the ADC to the other segment. The data from the first segment can now be read over VXIbus. As soon as a block of data is complete in the second segment, it can be read after the next sample clock edge.
Multibuffer Option
The optional Multibuffer memory acts as a large circular buffer for all channel data. It can be used in one of two operating modes—continuous and transient. When operated in continuous mode, it can be used to buffer n scans of the sample clock. In many systems this can effectively overcome the effects of system overhead by amortizing it over many data acquisition scans. The Multibuffer can also be used in transient mode. In this mode the large circular buffer stores pre-trigger and post-trigger samples. The size of the circular buffer is defined during setup up to the full available mem ory size. In transient mode the data can be read over VXIbus after the recording is complete, placing fewer restrictions on the effects of system throughput.
Digi-bus Option
This option represents a private bus to the left of the ADC. It uses the VXI Local bus for movement of data. If the Digi-bus option is used, the digital data can stream to the V165 Digital Signal Processor, the V110 RAM memory module or to other modules supporting Digi-bus protocol. While limited to the us e with data source and sink modules that support this protocol, the Digi-bus option has the advantage that it is immune to VXIbus latency issues.
Acquiring Data from the Ping-Pong Memory
For applications with slower aggregate sampling rates (sample clock rates), the Ping-Pong memory serves as a simple method of acquiring data. In such applications an interrupt or trigger line transition serves as a signal to the processor to read the data from Ping-Pong memory. Since this me mory only buffers a single data scan, it is incumbent on the application software to read the data from the memory between sample clock events. Thus, for a sample clock rate of 10 Hz, the application software must read all of the data from the Ping-Pong memory during each 100 ms time interval defined by the sample clock.
Typical applications frequently use a computer with a multi-tasking kernel to read data from the Ping-Pong memory. When using this technique, the user must insure that the appli cation task that reads the data can respond to the sample-clock event and read the data within one sample-clock period; otherwise data samples will be lost.
With today’s multitasking operating systems, the data acquisition task is not always guaranteed to respond to an event and read the data within a fixed time interval, even if it is the only user-selected task running. This is because multiple tasks may still be competing for the system resources. In many cases these are system tasks or drive rs responding to interrupts; both of these classes of tasks have higher priorities than a user task. In some cases, such as in systems operating under Windows 95, the user has little or no control over tasks. Even in operating systems where there is significant control (e.g. the VxWorks real-time kernel), it is difficult to prevent a low-priority task, for example, from issuing an I/O request that subsequently results in a very-high-priority driver I/O interrupt being handled. This is known as blocking.
The overriding issue is that a user data acquisition task will experience a variable latency in responding to an event (interrupt) and subsequently reading data. This delay is highly dependent on processor speed and configuration as well as on the other events that are pending or occurring during the period from the data acquisition event until the read request is satisfied.
In the case of data acquisition, loss of a single data scan can be quite undesirable. To prevent data loss it is necessary that the worst case process latency plus data transfer time be less than the sample-clock interval when using Ping-Pong memory. Worst case latency is a very difficult number to determine. As a general rule one can service the Ping-Pong memory reliably below 10 Hz. Somewhere between 10 Hz and 1 kHz, one will start to encounter excessive data loss. Above 10 kHz reliable data acquisition can only be achieved under highly controlled situations with dedicated processors using no operating sys tems or ones that are highly deterministic and exhibit low overhead.
Higher Ping-Pong sample rates can be achieved by the use of the KineticSystems Grand Interconnect (GI). If the V160 GI Slot-0 controller contains the Multibuffer option, that buffer can be used to receive data from the ADC's Ping-Pong memory over VXIbus, with the data transfer being isolated from any issues related to the host computer's operating system. Transactions between the V160 and the host computer system are similar to those for an ADC with Multibuffer.
Acquiring Data from the Multibuffer Memory—Continuous Mode
In the previous section we have discussed the problems caused by computer latency in response to an interrupt. For example, assume a 20 millisecond worst-case computer latency in a 50-channel data acquisition system with a sample rate of 100 Hz. If we use the Ping-Pong buffer, a 50-word block of data is available every 10 milliseconds (a 100 Hz rate). Also assume that a block of data is transferred from the buffer to the host at a rate of 2 megabytes/s (0.001 millisecond per 16-bit word). It follows that data will be lost whenever the latency plus the time to transmit the data block exceed the 10 millisecond sample rate. For this example, if the worst-case latency occurs during data transfer, the resulting total latency + transfer time will be:
20 ms + (50 x 0.001 ms) = 20.05 ms
If we use the Multibuffer to buffer multiple data scans, the effects of co mputer latency can be greatly reduced. If we take the previous example, but store 10-scan blocks of data (10 x 50 16-bit words = 500 words) in the Multibuffer, we get the following results:
20 ms + (500 x 0.001 ms) = 20.5 ms
The total time (worst-case latency + data transfer time) has increased slightly (20.5 ms instead of 20.05 ms), but we now have a 100 millisecond window (10 scans x 10 ms/scan) before the next block of data needs to be transferred. In a particu lar system the maximum throughput that can be achieved is affected by the computer latency, the number of channels per scan, the sample rate, the number of scans in a Multibuffer block, the block data transfer rate to the host system, and—if the data is to be transferred to disc storage in real time—the storage latency and transfer rate.
A consideration of buffering is that, if we wish to monitor the data in quasi-real time, the data available at the processor for monitoring may be delayed by as much as the buffering factor, and on average by the buffering factor/2. This can be partially overcome by subdividing the Multibuffer into multiple segments. The standard V207/V208 Multibuffer allows up to eight segments. The processor is interrupted when a segment is filled and the data is read. The segment size, however, can now be smaller since there are additional segments to fill before losing data, and the average latency is much less than the worst-case latency.
Acquiring Data from the Multibuffer Memory—Transient Mode
For applications that involve the recording of data over a finite time period, transient mode can be the most desirable buffering method. For this mode the size of the Multibuffer must be equal to—or greater than—the aggregate number of 2-byte samples to be recorded. For example, if 100 channels are to be recorded at 1000 samples/s per channel for 10 seconds, the total buffer size (in bytes) must be:
2 x 100 x 1000 x 10 = 2,000,000 bytes
Therefore a 4 Mbyte (4,194,304 byte) Multibuffer memory would be sufficient for this application. Note that the Total Buffer Size register in the V207 or V208 sets the actual circular buffer size and represents the number of 32-bit words (4-byte groups) to be transferred - 1. For this example, the data to be loaded in the Total Buffer Size register is:
(2,000,000/4) - 1 = 499,999 (7A11Fh)
To initiate transient recording, data sampling is started, and the synchronous transfer of data to the Multibuffer memory (circular buffer) within the module begins. When an event occurs, it causes the post-trigger countdown to begin (as the result of a trigger on the ADC front panel, from a VXI trigger line, from a preset limit being exceeded or from software). When the post-trigger countdown is complete, data is available to the host computer. The transfer of data to the host can now occur. Once the data is transferred, recording can be initiated and the cycle r epeated.
Since all of the data associated with an event is stored in the Multibuffer, the movement of data to the host does not limit the maximum aggregate sample rate—assuming that there is sufficient time to perform the data transfer to the host before sampling needs to be started for the next event. Sampling must be started early enough so that the actual recording buffer is filled with new data. Otherwise, some of the data at the beginning of the block will be old data from the previous event—or random data if this is the first test after power-on.
If, in the example above, we needed 60% post-trigger (40% pre-trigger) samples, we would load the number of 32-bit words in the V207 or V208 Countdown Register to select the post trigger samples:
0.6 x (2,000,000/4) = 300,000 (493E0h)
Since, in this example, the total recording time is 10 seconds, the time required for all of the pre-event samples to be recorded is 0.4 x 10, or 4 seconds.