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

Datasheets and User Guides

App Notes

Software & Driver


4.2.17 - eAIN() [U3 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.
  • ChannelN – The negative AIN channel to acquire. For single-ended channels on the U3, this parameter should be 31 or 199 (see Section 2.6.1).
  • Range – Ignored on the U3.
  • Resolution – Pass a nonzero value to enable QuickSample.
  • Settling – Pass a nonzero value to enable LongSettling.
  • 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.


I have 4 4-20 ma sensors going into 2 current shunts going to a u6 pro. I am using this code to read those sensors. I am seeing a lot of variability in the readings that is not there. Would the resolution value in the code help with this? I tried running a line from the negative power supply which is connected to all my negative sensors to signal ground, but that didn't really help. Do you have any ideas how to decrease the signal fluctuation?


First do a basic test to see if you can reproduce the noise figures from Appendix B of the U6 User's Guide.  Remove the LJTCS and instead place a small jumper wire from AINx to GND.  View the voltage readings using the test panel in LJControlPanel.  I would use the +/-10V range (BIP10V) as that is what you will likely use with the LJTCS, and you can try different resolution settings.

Once you confirm the ideal noise levels, remove the jumper and install the LJTCS, but instead of your signal use a simple/quiet voltage source with a resistor.  For example, take a AA battery and connect the battery+ to one side of a 270 ohm resistor, connect the other side of the resistor to INA+ on the LJTCS, and connect INA- to both GND and battery-.  Another source to try is connect DAC0 (set to 4.0 volts in the test panel) to a 1k resistor, connect the 1k resistor to INA+, and connect INA- to GND.

To continue along these lines I would post a comment on the LJTCS datasheet or the Noise and Resolution App Note.

If you find that everything is good, but just your signal has too much noise, then the noise is likely really there.  The question is whether that is the best the sensor can do, or there is something that can be changed to improve it.  To continue that, I would start a topic in our forums and provide more detail about the sensor and how it is connected.  Do initial troubleshooting with just one sensor connected and nothing else.

Hello there, I am getting some errors in my reading and I was wondering if I can do anything about it or is it because of my device. I have an U3-HV by the way.I connected a wire between DAC1 and AIN0, set the output to be 1V and I am doing 40-50 consecutive readings. There are 3 distinct values: 0.986261, 0.991352 and 0.996443. Is this normal? I am using .NET (C#). These are the 3 functions I am calling with the corresponding parameters. OpenLabJack, eDAC are called once and eAIN is called in a for loop. LabJack.LabJackUD.LJUD.OpenLabJack(LabJack.LabJackUD.LJUD.DEVICE.U3, LabJack.LabJackUD.LJUD.CONNECTION.USB, "", true, ref deviceHandle);LabJack.LabJackUD.LJUD.eDAC(deviceHandle, 0, 1, 0, 0, 0);LabJack.LabJackUD.LJUD.eAIN(deviceHandle, 0, 31, ref voltage, -1, -1, -1, 0);  Thank you, Remus

By "errors", do you mean the varying values (noise) or the difference from 1.0 (accuracy)?



Noise:  From Appendix A of the U3 User's Guide, the typical noise of an analog input is +/-1 count (which is excellent BTW).  On the +/-10V range, each count is 20/4096 => ~ 5mV.  With your data you have a center value of 0.991 and then +/-1, so typical and expected.

Accuracy:  From Appendix A of the U3 User's Guide, the accuracy is +/-0.13 % full-span, which on the +/-10V range equates to 20*0.0013 => +/-26mV.  DAC0 has its own inaccuracy, but assume it is perfect and giving you 1.0 volts.  If your average reading is 0.991 volts, you have a -9mV error which is within spec.