4.2.17 - eAIN() [U6 Datasheet] | LabJack
« Close

Datasheets and User Guides

App Notes

Software & Driver


4.2.17 - eAIN() [U6 Datasheet]

An easy function that returns a reading from one analog input. This is a simple alternative to the very flexible IOType based method normally used by this driver.

When needed, this function automatically configures the specified channel(s) for analog input.


LJ_ERROR _stdcall eAIN ( LJ_HANDLE Handle,
                         long ChannelP,
                         long ChannelN,
                         double *Voltage,
                         long Range,
                         long Resolution,
                         long Settling,
                         long Binary,
                         long Reserved1,
                         long Reserved2)

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

  • Handle – Handle returned by OpenLabJack().
  • ChannelP – The positive AIN channel to acquire. See Section 2.6.1.
  • ChannelN – The negative AIN channel to acquire. For differential readings on the U6, this should be and odd number equal to ChannelP+1. For single-ended readings on the U6, this parameter should be 0 or 15.
  • Range – Pass a range constant. See Section 4.3.3.
  • Resolution – Pass a resolution index. 0=default, 1-8=high-speed ADC, 9-12=high-res ADC. See Section 3.1 and Appendix B.
  • Settling – Pass a settling factor. 0-9 where 0=Auto. See the end of Section 2.6.
  • Binary – If this is nonzero (True), the Voltage parameter will return the raw binary value.
  • Reserved (1&2) – Pass 0.


  • Voltage – Returns the analog input reading, which is generally a voltage.



One of the passed parameters is 

Settling – Pass a settling factor.

But nowhere can I find what this means.


Added some links above.

I want to read the voltage betwen AI0 and AI1 differntial with the eAIN Funktion. It dosen't work, the value jumps from 35554 to 65535 although the AI0 and AI1 are shortet. When i connect 5V betwen the Inputs its the same. When i short AI0 and Ai1 the Value shoud be 0 and when i connect 20V it shoud be 65535... What i doing wrong? my code: Error = LJUD.eAIN(u6.ljhandle,0,1,Voltage,1,0,0,1) I use Visual Basic 2010

Does it work properly in the test panel in LJControlPanel?  Does it make a difference if you add a jumper to GND to both analog inputs are grounded?

I Have found the problem: I still have type in a Number for the gain factor. Here I must call the gainfactor about the range parameter :) Thanks for help!

I have not been able to use this function to make a simple single-ended A/D conversion on a U6.  The problem appears to be the "Range" value, which is not properly explained anywhere.  In section 4.3.3. you give some symbolic names like LJ_rgBIP10V, but give no actual numerical values.  In the file LabJackUD.h you give numerical values, but prefix that section with the less-than-helpful comment that "not all are supported on all devices."  I wrote a test program where I tried passing, in a loop, all the Range values between 1 and 10.  The actual input voltage was about 0.14V but the only Range values that resulted in a correct reading were 2 and 8; all the others gave a value of about 0.1V.  It looked like saturation of a +-0.1V range.  I guess 2 and 8 denote ranges of +-10V and +-1V respectively.  So the header file appears to be correct here.  But when I tried checking all range values from 101 to 114, expecting to get single-ended readings (what I really want), I always got about 0.1V.  I then fed in an actual analog voltage of about 0V and again tried all Range values from 101 to 114.  They all gave a small negative voltage.  So I can't get the U6 to do ANY single-ended conversions no matter what I do.  What values are actually supported on the U6 and what ranges do they correspond to?  Is there some trick to getting single-ended conversions?  My function call looks like eAIN(h,0,0,&voltage,range,0,0,0,0,0) where h is the handle, voltage is a double and range is an integer that gets varied as I have described.  I am feeding the analog signal into the AIN0 pin.

See the Differential Analog Inputs App Note, as I believe when you say "single-ended" you actually mean "unipolar".  The U6 only supports bipolar ranges +/-10V, +/-1V, +/-0.1V, and +/-0.01V ... see Section 2.6 of the U6 User's Guide.

If you pass in other range constants, the UD driver should use the closest bigger range, so if for example you passed in LJ_rgUNI1P25V=107=0-1.25V, the driver would tell the device to use the +/-10V range.  That does not sound like what you are seeing so will have a programmer here check on that.

What language are you using?  Whenever possible, to make easier to read code, you want to use the string constant as described in Section 4.3.3 of the U6 User's Guide, rather than looking up the numeric constant in the header file and hard-coding that.

The first link is broken.

Link has been fixed.

I have U6_Pro

i need to use 24 bit resolution with max SPS sample per second, how ?

also what is the Max SPS for 24 bit resolution ? , and how to enable 24 bit resolution, to use with differential analog inputs to read load cell

See Section 3 for information about data rates.  Also see the app note about noise and resolution.

A load cell is a bridge circuit, so see the bridge circuit forum topic and and for specific quick steps for the T7 (similar for the U6) see post #5 on topic 6871.

jvande's picture

The documentation does not mention the calibration argument (2nd argument), the arg count is wrong if you leave this out.

The statement that for Single Ended you put a 0, 15, or 199 in the negative channel number arg is not correct, specifically using 199 causes a sampling error. A 15 appears to work but I have not tried zero.

I suggest looking at the source .h file instead of the online documentation.

labjack support's picture

This documentation is for the Windows UD driver's implementation of eAIN.

For the Linux/Mac OS X examples' implementation of the U6 eAIN call which has an extra parameter look at the u6.h header file for documentation: