ePut (lngHandle, LJ_ioPUT_TIMER_VALUE, 2, 0, 0);
//Reset the duty-cycle measurement (Timer3) to zero, by writing
//a value of zero. The duty-cycle measurement is continuously
//updated, so a reset is normally not needed, but one reason
//to reset to zero is to detect whether there has been a new
//measurement or not.
ePut (lngHandle, LJ_ioPUT_TIMER_VALUE, 3, 0, 0);
//Reset the quadrature counters (Timer4 & Timer5) to zero, by
//writing a value of zero to either one.
ePut (lngHandle, LJ_ioPUT_TIMER_VALUE, 4, 0, 0);
//Reset Counter0 to zero.
ePut (lngHandle, LJ_ioPUT_COUNTER_RESET, 0, 1, 0);
Note that if a timer/counter is read and reset at the same time (in the same Add/Go/Get block), the read will return the value just
before reset.
4.3.7 - Stream Mode
There are five IOTypes used to control streaming:
LJ_ioCLEAR_STREAM_CHANNELS
LJ_ioADD_STREAM_CHANNEL
LJ_ioSTART_STREAM //Value returns actual scan rate.
LJ_ioSTOP_STREAM
LJ_ioGET_STREAM_DATA
The following constant is passed in the Channel parameter with the get stream data IOType to specify a read returning all scanned
channels, rather than retrieving each scanned channel separately:
LJ_chALL_CHANNELS
The following are special channels, used with the get/put config IOTypes, to write or read various stream values:
LJ_chSTREAM_SCAN_FREQUENCY
LJ_chSTREAM_BUFFER_SIZE //UD driver stream buffer size in samples.
LJ_chSTREAM_CLOCK_OUTPUT //True/False. [1]
LJ_chSTREAM_EXTERNAL_TRIGGER //True/False. [1]
LJ_chSTREAM_WAIT_MODE
LJ_chSTREAM_BACKLOG_COMM //Read-only. 0=0% and 128=100%.
LJ_chSTREAM_BACKLOG_CONTROL //Read-only. Number of samples.
LJ_chSTREAM_BACKLOG_UD //Read-only. Number of samples.
LJ_chSTREAM_SAMPLES_PER_PACKET //Read-only. Always 16 on the UE9.
LJ_chSTREAM_READS_PER_SECOND //Default 25.
[1] See Section 3.2.1.
With the wait mode special channel above, the following constants are passed in the value parameter to select the behavior when
reading data:
LJ_swNONE //No wait. Immediately return available data.
LJ_swALL_OR_NONE //No wait. Immediately return requested amount, or none.
LJ_swPUMP //Advance message pump wait mode.
LJ_swSLEEP //Wait until requested amount available.
The backlog special channels return information about how much data is left in the hardware stream buffers on the UE9. These
parameters are updated whenever a stream packet is read by the driver, and thus might not exactly reflect the current state of the
buffers, but can be useful to detect problems.
When streaming, the Control processor acquires data at precise intervals, and transfers it to the Comm processor which has a
large data buffer. The Control processor has a small data buffer (256 samples) for data waiting to be transferred to the Comm
processor, and the
LJ_chSTREAM_BACKLOG_CONTROL
special channel specifies the number of samples remaining in the
Control buffer. If this parameter is nonzero and growing, it suggests that the Control processor is too busy. Because the Control
buffer is so small, overflows very quickly, and generally only overflows if sampling faster than the specified rates, this parameter is
not often used.
The Comm processor holds stream data in a 4 Mbit FIFO buffer (512 kBytes, 11397 StreamData packets, 182361 samples) until
it can be sent to the host. The lower 7 bits of the
LJ_chSTREAM_BACKLOG_COMM
special channel specify how much data is
left in the Comm buffer in increments of 4096 bytes. A value of 0 means the buffer is empty and a value of 128 (or higher) means
the buffer has overflowed. The UD driver retrieves stream data from the UE9 in the background, but if the computer or
communication link is too slow for some reason, the driver might not be able to read the data as fast as the UE9 is acquiring it,
and thus there will be data left over in the UE9 buffer.
To obtain the maximum stream rates documented in Section 3.2, the data must be transferred between host and UE9 in large
chunks. The amount of data transferred per low-level packet is fixed at 16 samples on the UE9. The driver will use the parameter
LJ_chSTREAM_READS_PER_SECOND
to determine how many low-level packets to retrieve per read.
The size of the UD stream buffer on the host is controlled by
LJ_chSTREAM_BUFFER_SIZE
. The application software on the
host must read data out of the UD stream buffer fast enough to prevent overflow. After each read, use
LJ_chSTREAM_BACKLOG_UD
to determine how many samples are left in the buffer.
In stream mode the LabJack acquires inputs at a fixed interval, controlled by the hardware clock on the device itself, and stores the
data in a buffer. The LabJackUD driver automatically reads data from the hardware buffer and stores it in a PC RAM buffer until
requested. The general procedure for streaming is:
Update configuration parameters.
Build the scan list.
44
Summary of Contents for UE9
Page 84: ...84 ...