*idnum – Local ID, serial number, or -1 for first found.
demo – Send 0 for normal operation, >0 for demo mode. Demo mode allows this function to be called without a LabJack.
stateIOin – Output states for IO0-IO3.
updateIO – If >0, state values will be written. Otherwise, just a read is performed.
ledOn – If >0, the LabJack LED is turned on.
numChannels – Number of analog input channels to read (1,2, or 4). If readCount is >0, numChannels should be 4.
*channels – Pointer to an array of channel commands with at least numChannels elements. Each channel command is 0-7
for single-ended, or 8-11 for differential.
*gains – Pointer to an array of gain commands with at least numChannels elements. Gain commands are 0=1, 1=2, …,
7=20. This amplification is only available for differential channels.
*scanRate – Scans acquired per second. A scan is a reading from every channel (1,2, or 4). The sample rate (scanRate *
numChannels) must be between 200 and 1200.
disableCal – If >0, voltages returned will be raw readings that are not corrected using calibration constants.
reserved1 – Reserved for future use. Send 0.
readCount – If >0, the current count (CNT) is returned instead of the 2nd, 3rd, and 4th analog input channels. 2nd channel is
bits 0-11. 3rd channel is bits 12-23. 4th channel is bits 24-31. This feature was added to the LabJack U12 starting with
firmware version 1.03, and this input has no effect with earlier firmware versions.
Outputs:
*idnum – Returns the local ID or –1 if no LabJack is found.
*scanRate – Returns the actual scan rate, which due to clock resolution is not always exactly the same as the desired scan
rate.
ActiveX Function Differences:
The “channels” and “gains” arrays are replaced with “channelsPacked” and “gainsPacked”. The OCX has a function “FourPack”
(4.39) which will convert 4 elements to a packed value. The packed value is determined as: element[0] + (element[1] * 2
8
) +
(element[2] * 2
16
) + (element[3] * 2
24
).
The parameters “demo”, “ledOn”, “disableCal”, “updateIO”, and “stateIOin”, are replaced by an “optionBits” parameter. Call the
OCX function “BuildOptionBits” (4.38) to determine this parameter.
Declaration (ActiveX):
long AIStreamStartX ( long FAR* idnum,
long numChannels,
long channelsPacked,
long gainsPacked,
float FAR* scanRate,
long optionBits,
long readCount)
4.9 - AIStreamRead
Waits for a specified number of scans to be available and reads them. AIStreamStart should be called before this function and
AIStreamClear should be called when finished with the stream. Note that while streaming the LabJack U12 is too busy to do
anything else. If any function besides AIStreamRead is called while a stream is in progress, the stream will be stopped.
Note that you must pass the actual local ID to this function, not the idnum parameter used for most functions. Usually you simply
pass the value returned by the idnum parameter in AIStreamStart.
Declaration:
long AIStreamRead ( long localID,
long numScans,
long timeout,
float (*voltages)[4],
long *stateIOout,
long *reserved,
long *ljScanBacklog,
long *overVoltage )
Parameter Description:
Returns: LabJack errorcodes or 0 for no error.
Inputs:
localID – Send the local ID from AIStreamStart.
numScans – Function will wait until this number of scans is available. Minimum is 1. Maximum numSamples is 4096, where
numSamples is numScans * numChannels. Internally this function gets data from the LabJack in blocks of 64 samples, so it
is recommended that numSamples be at least 64.