Skip to main content
Skip table of contents

4.8 - AIStreamStart [U12 Datasheet]

Starts a hardware timed continuous acquisition where data is sampled and stored in the LabJack RAM buffer, and can be simultaneously transferred out of the RAM buffer to the PC application. A call to this function should be followed by periodic calls to AIStreamRead, and eventually a call to AIStreamClear. 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.

Execution time for this function is 30 milliseconds or less (typically 24 milliseconds in Windows).

If the LED is enabled (ledOn>0), it will toggle every 40 samples during acquisition and turn on when the stream operation stops.

If demo is TRUE, the 1st channel will return the scan count. If readCount is FALSE, depending on numChannels the other channels will return a random value in the +/-5V range or a constant -2.5V. If readCount is TRUE the other channels return the current time.


long AIStreamStart ( long *idnum,
long demo,
long stateIOin,
long updateIO,
long ledOn,
long numChannels,
long *channels,
long *gains,
float *scanRate,
long disableCal,
long reserved1,
long readCount )

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.

  • *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.


  • *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)

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.