EasyManua.ls Logo

LabJack UE9 - Page 46

LabJack UE9
86 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
//Retrieve the current Comm backlog. The UD driver retrieves
//stream data from the UE9 in the background, but if the computer
//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.
eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chSTREAM_BACKLOG_COMM, &dblCommBacklog, 0);
//Retrieve the current UD driver backlog. If this is growing, then
//the application software is not pulling data from the UD driver
//fast enough.
eGet(lngHandle, LJ_ioGET_CONFIG, LJ_chSTREAM_BACKLOG_UD, &dblUDBacklog, 0);
}
Finally, stop the stream:
//Stop the stream.
errorcode = ePut (Handle, LJ_ioSTOP_STREAM, 0, 0, 0);
4.3.7.1 - Stream DAC
Stream DAC is a feature where the DACs (digital-to-analog outputs or analog outputs) are updated by hardware in each stream
scan. A buffer for each DAC (DAC0 and/or DAC1) is loaded with 1-128 values, and the UE9 steps through the buffer(s) updating
the DAC(s) with each stream scan.
Requires UD driver V3.06+ and UE9 Control firmware V1.93+.
The DAC updates are done in addition to a normal input stream, so at least 1 input channel must be streamed.
In terms of stream speeds, the DAC updates do not count the same as input channels. Rather, if stream updates are enabled for 1
or both DACs, it adds a just few microseconds to the time of each scan.
There is one IOType to enable/disable this feature and load a buffer:
LJ_ioADD_STREAM_DAC //Channel= channel (0 or 1). Value= number of updates (0-128). x1= array of doubles.
Typical pseudocode would look like the following:
ePut(lngHandle, LJ_ioADD_STREAM_DAC, dacNum, numUpdates, padblUpdates);
The Channel parameter of the ePut call is 0 or 1 to specify DAC0 or DAC1 (two calls are used if both DACs are to be streamed).
The Value parameter specifies the number of updates in the buffer. The x1 parameter is an array with that many doubles.
Note that LJ_ioCLEAR_STREAM_CHANNELS does not affect Stream DAC. Rather, to disable a call like above must be made
for each enabled DAC with numUpdates=0.
If the special channel LJ_chDAC_BINARY has been used to specifiy that binary updates will be passed for the DACs, that is
supported with this Stream DAC feature, and the binary updates are still passed in the array of doubles.
A little trick in C: Since the x1 parameter is just defined as a long, cast the pointer to the array as a long and pass that for x1:
double adblUpdates[128] = {0};
long padblUpdates = (long)&adblUpdates[0];
4.3.8 - Raw Output/Input
There are two IOTypes used to write or read raw data. These can be used to make low-level function calls (Section 5) through the
UD driver. The only time these generally might be used is to access some low-level device functionality not available in the UD
driver.
LJ_ioRAW_OUT
LJ_ioRAW_IN
When using these IOTypes, channel # specifies the desired communication pipe. For the UE9, 0 is the normal pipe while 1 is the
streaming pipe. The number of bytes to write/read is specified in value (1-512), and x1 is a pointer to a byte array for the data.
When retrieving the result, the value returned is the number of bytes actually read/written.
Following is example pseudocode to write and read the simple low-level echo command. This is the simplest UE9 command and
consists simply of a write of 2 bytes (0×70, 0×70) and a read of the same two bytes.
writeArray[2] = {0x70,0x70};
numBytesToWrite = 2;
numBytesToRead = 2;
//Raw Out. This command writes the bytes to the device.
eGet(lngHandle, LJ_ioRAW_OUT, 0, &numBytesToWrite, pwriteArray);
//Raw In. This command reads the bytes from the device.
eGet(lngHandle, LJ_ioRAW_IN, 0, &numBytesToRead, preadArray);
4.3.9 - Easy Functions
The easy functions are simple alternatives to the very flexible IOType based method normally used by this driver. There are 6
functions available:
eAIN() //Read 1 analog input.
46