« Close

Datasheets and User Guides

App Notes

Software & Driver


4.1 - Overview


The LabJackUD driver is the Windows driver/library for the U3, and also the U6 and UE9. LabJackUD is also referred to as UD and LJUD.

The general operation of the LabJackUD functions is as follows:

  • Open a LabJack U3, U6 or UE9.
  • Build a list of requests to perform (Add).
  • Execute the list (Go).
  • Read the result of each request (Get).

At the core, the UD driver only has 4 basic functions: Open, AddRequest, Go, and GetResult. Then with these few functions, there are many constants used to specify the desired actions. When programming in any language, it is recommended to have the header file handy, so that constants can be copied and pasted into the code.

The first type of constant is an IOType, which is always passed in the IOType parameter of a function call. One example of an IOType is the constant LJ_ioPUT_DAC, which is used to update the value of an analog output (DAC).

The second type of constant is a Channel Constant, also called a Special Channel. These constants are always passed in the Channel parameter of a function call. For the most part, these are used when a request is not specific to a particular channel, and go with the configuration IOTypes (LJ_ioPUT_CONFIG or LJ_ioGET_CONFIG). One example of a Special Channel is the constant LJ_chLOCALID, which is used to write or read the local ID of the device.

The third major type of constant used by the UD driver is a Value Constant. These constants are always passed in the Value parameter of a function call. One example of a Value Constant is the constant LJ_tmPWM8, which specifies a timer mode. This constant has a numeric value of 1, which could be passed instead, but using the constant LJ_tmPWM8 makes for programming code that is easier to read.

Following is pseudocode that performs various actions. First, a call is done to open the device. The primary work done with this call is finding the desired device and creating a handle that points to the device for further function calls. In addition, opening the device performs various configuration and initialization actions, such as reading the calibration constants from the device:

//Use the following line to open the first found LabJack U3
//over USB and get a handle to the device.
//The general form of the open function is:
//OpenLabJack (DeviceType, ConnectionType, Address, FirstFound, *Handle)

//Open the first found LabJack U3 over USB.
lngErrorcode = OpenLabJack (LJ_dtU3, LJ_ctUSB, "1", TRUE, &lngHandle);

Second, a list of requests is built in the UD driver using AddRequest calls. This does not involve any low-level communication with the device, and thus the execution time is relatively instantaneous:

//Request that DAC0 be set to 2.5 volts.
//The general form of the AddRequest function is:
//AddRequest (Handle, IOType, Channel, Value, x1, UserData)
lngErrorcode = AddRequest (lngHandle, LJ_ioPUT_DAC, 0, 2.50, 0, 0);

//Request a read from AIN3 (FIO3), assuming it has been enabled as
//an analog line.
lngErrorcode = AddRequest (lngHandle, LJ_ioGET_AIN, 3, 0, 0, 0);

Third, the list of requests is processed and executed using a Go call. In this step, the driver determines which low-level commands must be executed to process all the requests, calls those low-level functions, and stores the results. This example consists of two requests, one analog input read and one analog output write, which can both be handled in a single low-level Feedback call (Section 5.2.5):

//Execute the requests.
lngErrorcode = GoOne (lngHandle);

Finally, GetResult calls are used to retrieve the results (errorcodes and values) that were stored by the driver during the Go call. This does not involve any low-level communication with the device, and thus the execution time is relatively instantaneous:

//Get the result of the DAC0 request just to check for an errorcode.
//The general form of the GetResult function is:
//GetResult (Handle, IOType, Channel, *Value)
lngErrorcode = GetResult (lngHandle, LJ_ioPUT_DAC, 0, 0);

//Get the AIN3 voltage.  We pass the address to dblValue and the
//voltage will be returned in that variable.
lngErrorcode = GetResult (lngHandle, LJ_ioGET_AIN, 3, &dblValue);

The AddRequest/Go/GetResult method is often the most efficient. As shown above, multiple requests can be executed with a single Go() or GoOne() call, and the driver might be able to optimize the requests into fewer low-level calls. The other option is to use the eGet or ePut functions which combine the AddRequest/Go/GetResult into one call. The above code would then look like (assuming the U3 is already open):

//Set DAC0 to 2.5 volts.
//The general form of the ePut function is:
//ePut (Handle, IOType, Channel, Value, x1)
lngErrorcode = ePut (lngHandle, LJ_ioPUT_DAC, 0, 2.50, 0);

//Read AIN3.
//The general form of the eGet function is:
//eGet (Handle, IOType, Channel, *Value, x1)
lngErrorcode = eGet (lngHandle, LJ_ioGET_AIN, 3, &dblValue, 0);

In the case of the U3, the first example using add/go/get handles both the DAC command and AIN read in a single low-level call, while in the second example using ePut/eGet two low-level commands are used. Examples in the following documentation will use both the add/go/get method and the ePut/eGet method, and they are generally interchangeable. See Section 4.3 for more pseudocode examples.

All the request and result functions always have 4 common parameters, and some of the functions have 2 extra parameters:

  • Handle – This is an input to all request/result functions that tells the function what LabJack it is talking to. The handle is obtained from the OpenLabJack function.
  • IOType – This is an input to all request/result functions that specifies what type of action is being done.
  • Channel – This is an input to all request/result functions that generally specifies which channel of I/O is being written/read, although with the config IOTypes special constants are passed for channel to specify what is being configured.
  • Value – This is an input or output to all request/result functions that is used to write or read the value for the item being operated on.
  • ×1 – This parameter is only used in some of the request/result functions, and is used when extra information is needed for certain IOTypes.
  • UserData – This parameter is only used in some of the request/result functions, and is data that is simply passed along with the request, and returned unmodified by the result. Can be used to store any sort of information with the request, to allow a generic parser to determine what should be done when the results are received.



I am using labview to communicate  with the labjack u3 HV device. I build a vi called labjackall.vi that can read analog inputs, read  digital inputs, set digital outputs and  set analog outputs using open->addrequest->go one> get results in a case structure with a string control . I built a labview program logsave.vi  that uses labjackall.vi to  read all the configured analog inputs and configured digital inputs of the labjack u3 HV every 20 seconds. I built another program setdevice.vi that uses labjackall.vi to change the analog output or digital output of the labjack.

Finally  the problem is that  when I run logsave.vi it works and continues to log every 20s but when I  run setdevice.vi to change the analog out or digital out  I get an error in the open function. Also if I run setdevice.vi first it works but when I run  logsave.vi  it gets an error in the open function. 

Can the labjack communicate with multiple programs that call it? What do you think is wrong?



Through the UD driver a device can only be opened by 1 process at a time.  If these are VIs that you are running within the LabVIEW development environment, then they are all part of the same process (i.e. labview.exe).  What error are you getting?  What version of the UD driver are you using?

Error code:  7007 

UD Driver : 3.25

LJE_LABJACK_NOT_FOUND => "LabJack not found at the given id or address." =>  I would use LabVIEW debugging features to look at what you actually passed in to that OpenLabJack call.

For comparison, make a copy of "U3 Efunction Loop Example.vi".  Open and run both the original and the example at the same time and you should see that they work fine.


I found the error. The error was caused by a confusion of labjack ID's between the two programs. When I ran logsave program  the ID sent to open Labjack was 1 (works fine) but when I ran the setdevice program, it was sending an ID of empty space fallowed by 1 (gives error). This is because the setdevice program was reading the labjack ID from a  data base and someone might have put a space fallowed by a 1 in the ID column in the data base. 

Well I solved it now  and thanks for your help