« Close

Datasheets and User Guides

App Notes

Software & Driver

 

LabVIEW for UD - Windows

LabVIEW driver/example VIs for the Windows UD library. The Windows UD library is the high-level Windows library for the LabJack U3, U6 and UE9. For other LabJack devices, go to the Software page.

LabVIEW is one of the most popular programming languages used by our customers. LabVIEW is a graphical programming language, as demonstrated in the code snippet below, but understand that it is still a powerful programming language not a simple software tool.

http://www.ni.com/gettingstarted/labviewbasics/

Note that using a LabJack in LabVIEW is not identical to using NI hardware in LabVIEW.  The NI hardware is talked to through the NI-DAQ driver, while the LabJack is talked to through the LabJack UD library.  That means that you will not use measurement & automation explorer, DAQ assistant, or similar NI wizards.

The LabVIEW_LJUD archive is maintained in LabVIEW 7.1, but also available below are the last supported archives for LabVIEW 5 & 6.

Our normal software installation package is required by the attached LabVIEW examples.  You can find the latest version of that here.

 

Getting Started with the U3/U6/UE9 in LabVIEW:

  1. Go to the U3/U6/UE9 Quickstart Tutorial and follow the steps to install Windows software and confirm basic operation.
  2. Download the LabVIEW_LJUD archive below and extract the entire archive.  Don't forget to extract the archive before trying to open any of the VIs within.
  3. Read the "readme.txt" file in the archive as it does have some unique information.
  4. In LabVIEW you will be making calls to our UD library.  Read through Section 4.1 of the U3/U6/UE9 User's Guide for an overview of the UD library.
  5. Refer to Section 4.2 of the U3/U6/UE9 User's Guide for documentation of the parameters of each function.
  6. Refer to Section 4.3 of the U3/U6/UE9 User's Guide for documentation of what values to pass.
  7. Start with the easy function examples.  Open and run "Uxx eAIN Example.vi".
  8. If you need to move beyond the easy functions, start with "Uxx Single IO Example.vi", "Uxx Multiple IO Example.vi", and "Uxx Multiple IO Example Loop.vi".

 

Overview

The UD library has easy functions to read or write a single analog or digital I/O.  For basic applications these might be all that are needed:

  • eAIN() - read 1 analog input, "Uxx eAIN Example.vi".  Refer to "Configuration", "Analog Inputs", and "Easy Functions" pseudocode sections in the U3/U6/UE9 User's Guide.
  • eDAC() - write 1 analog output, "Uxx eDAC Example.vi".  Refer to "Analog Outputs" and "Easy Functions" pseudocode sections in the U3/U6/UE9 User's Guide.
  • eDI() - read 1 digital input, "Uxx eDI Example.vi".  Refer to "Digital I/O" and "Easy Functions" pseudocode sections in the U3/U6/UE9 User's Guide.
  • eDO() - write 1 digital output, "Uxx eDO Example.vi".  Refer to "Digital I/O" and "Easy Functions" pseudocode sections in the U3/U6/UE9 User's Guide.

For more flexible and efficient operation you would move on to the basic Add-Go-Get technique described in Section 4.1 of the U3/U6/UE9 User's Guide.  With this technique you give the drive a list of requests to perform (Add), execute the list (Go), and read the results of each request (Get).  There are a few different functions to perform different variations of Add-Go-Get, but they all have the same 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.  If you are operating on a singular input or output (e.g. IOType = LJ_ioGET_AIN), then Channel specifies which channel of I/O is being written/read.  If you are operating on something not specific to a particular channel (e.g. serial number), then IOType is usually LJ_ioGET_CONFIG or LJ_ioPUT_CONFIG and a special channel constant (e.g. LJ_chSERIAL_NUMBER) is used to specify what you are operating on.
  • 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.
  • x1 – This parameter is only used in some of the request/result functions, and is used when extra information is needed for certain IOTypes.

 

Where are the Functions & Parameters Defined?

Refer to Section 4.2 of the U3/U6/UE9 User's Guide for documentation of the parameters of each function.

 

What Values are Passed for Different Parameters?

The pseudocode sections, 4.3 of the U3/U6/UE9 User's Guide, are a good spot to look for this information.  Also see the applicable Hardware Description section in the U3/U6/UE9 User's Guide.

 

50 comments

There's no helping comment on each of the VI. It would have been helpful if you just writted one or two sentences for each VI to introduce their use. 

Good suggestion, and we will work on adding more comments.  Many of the more complicated programs, such as stream examples, do already have comments on the front panel and/or wiring diagram.  Many of the simpler examples are explained by Section 4 of the applicable device user's guide, but I agree that more comments are good.

 

I think what Etienne means, is that in each VI you can place a comment in File->VI Properties and then selecting Documentation.  The reason this is more desirable (and also standard practice) than comments on the front panel or block diagram is that when you mouse over a sub-VI in an application (and many other places), the comments you place in this section will show up in the context help.  This is much more useful and accessible than a comment on the front panel or block diagram.

I'd second the suggestion, not just for more comments, but for the comments to be placed in the documentation section as described above.

In either case, two thumbs up for having LabVIEW example at all!  Thanks!

 

The setup for external triggering on UE in Labview.

See "UE9 Externally Triggered Stream Example.vi".

Hi!

Is it possible to have an example about multichannel in differential entrance for U6 device?. For stream mode, preferable.

That's because I need to meassure 6 diff channels at ~200 S/s. Thank you.

Check out "U6 easy Stream.vi".  The sub-vi "easy stream start U6.vi" has an unwired input for negative channels that you can use to get differential.  Or just look at "U6 easy Stream Full.vi".

Also check out the Differential Analog Inputs App Note as many common mistakes are made with differential inputs, and most signals (besides those from bridge circuits) are naturally single-ended and should be acquired that way.

Thanks,

But I don't know how to use exactly the Scan List (-), If I want to use single-ended then I should put in 199, but if I want to use differential then I should put pairs? like 0 for Scan List (+) and  0 for Scan List (-), or , 0 for Scan List (+) and  1 for Scan List (-) then 2 for Scan List (+) and  3 for Scan List (-) ...

 

Thank you.

 

ScanList- should have a matching element for each element in ScanList+.  These element pairs are the positive and negative channel.  From Section 2.6 and Section 2.6.1, differential channels are even/odd pairs, so you should use 0/1, 2/3, ..., and so on.

New LJ user, lost in startup under LabVIEW 2010 !

I see some simple example code to output or input a single bit, but I'm looking to output a set of a few bits to EIO, say EIO0-EIO2, and read back the state of EIO3.

RawOutIn.vi looked useful, as I want to perform that operation on a series of outputs, but I don't understand many of the parameters.

Channel Offset seemed clear, and I figured I'd need an offset of 8 to get from FIO0 to EIO0. Unfortunately, anything other than 0 or 1 throws an error in LJUD_eGetS.vi.

I also clearly need to set I/O bit functions (all digital is fine) and direction. I inserted PinConfigReset.vi and PinConfig.vi, the latter with all 0 and False, except leaving Timer/Counter Pin Offset at 4. That didn't seem to have any effect. Setting the 4 to 0 made things worse, throwing the error in LJUD_GetNextResutl.vi with any Channel Offset. With those two vi's, I still am missing direction bits, aren't I?

A little help or direction here would be greatly appreciated!

Dave

Which device do you have?  Make sure you read through Section 4 of the User's Guide first.  You want to understand what to do with the UD driver in general, and then do that general thing in your programming language (LabVIEW in this case).

You could just make a few calls to eDO and a call to eDI, but if you want the fastest time you want to combine your operations in a single Add/Go/Get block.  I suggest you do a request with iotype LJ_ioPUT_DIGITAL_PORT to set the state and direction of EIO0-EIO3 and then do a request with iotype LJ_ioGET_DIGITAL_BIT to read and set the direction of EIO4.  See Section 4.3.5 of the U3 User's Guide.

To see an add/go/get block in LabVIEW, check out "U3 Multiple IO Example.vi".

Sorry, I see I missed that - I'm using a U3-HV.

Yes, I wanted to move the data faster than successive calls to eDO/eDI, and also to have multiple output bits change state on the same operation.

I did read 4.3.5; that's the part where I was floundering, figuring out all the parameters, and mentally mapping them to the provided vi's.

I don't have LV on this machine (checking in from home), but will dig into this further tomorrow. If I understand your suggestion correctly, LJ_ioPUT_DIGITAL_PORT and LJ_ioGET_DIGITAL_BIT accomplish setting direction and data transfer in one step. That sounds perfect, with a loop sequencing my output state data and building the input data Boolean array. Now, I believe those are iotype enums, and I need to feed them to the I/O function vi(s). Is it correct that I load them into an Add, then execute the Go and Get functions, for each pass through the loop?

Thanks for the help!

Dave

Put-digital-port lets you update a block of outputs in one command, and the comment in 4.3.5 notes that in addition to setting the states it also sets the directions to output.  Get-digital-bit reads 1 digital input and sets its direction to input at the same time (basically the same as eDI, except that you use it in an add/go/get block).

If you find you need to get into further detail, I suggest starting a topic on our forum.

I am using labjack U3 for interfacing level sensor with labview. To start programming i tried to run eDI.vi from the examles u have given. To execute the program which function should replce the questionmark block in the block diagram ??

I question mark sub-vi in a block diagram suggests that it did not find the sub-vi.  When you opened the VI did it give a message about locating a sub-vi?

Start with "U3 eDI Example.vi".  Does this open and run properly?

Perhaps you are talking about the function palette?  Post #2 of forum topic 4875 mentions something about this, and also see the function palette notes in the readme.txt file in the LabVIEW_LJUD archive downloaded from above.

yes,the message to open the sub vi is appearing . what type of sub vi should i must open to run the program for analog input.?

Again, I suggest you start by going through steps 1-5 above.  The example in step 5 is the easiest way to read an analog input.  It is an example of how to use the eAIN function.

what is the procedure for calling eDO & eDI VIs in labview program?

See the documentation for eDI and eDO in Sections 4.2.19 and 4.2.20 of the U3 User's Guide, see the easy function pseudocode in Section 4.3.9, and see the applicable LabVIEW examples.

can you send us the link for the following VIs: open_labjackS, error to string??

All sub-VIs are in the archive.  Before you try to open any VIs, make sure you first have unzipped the entire archive.  Don't just click on files within the zipped archive.

I suggest you start by going through steps 1-5 above.

Is there a way to have the U3 to work with Labview 5 ?

Labview 5 is the last version of Labview that allows user  to create executables with embedded Runtime engine.

This IMHO makes a huge difference if you need to distribute or sell your application.

We don't support LV5, but it is possible.  If you have LV6, you can revert our archive, or I actually found a version of the LabVIEW_LJUD archive from April 2007 that was reverted to LV5.  To get it post on our forum or email [email protected].

Hi,

Can I program in LabVIEW on a computer that does not

have a LJ U3 and have the LabVIEW program run on a

computer that does have the U3 attached?

JIM

In the new archive LJM read open config.vi is missing.

Fixed.  Thanks.

I have labJack U6 device and IDCA-10, trying to communicate in SPI mode. No examples are available to communicate in SPI for U6 in labview. can u help me out... and it is working fine in MCT software.

Look under \LabVIEW_LJUD\Examples\SPI.  Also, for general documentation see Section 4.3.10 of the U6 User's Guide.

I am using labview examples for T7 to comunicate with one T7-pro, (single AIN.vi, single DIO read.vi, etc). When I use only a few of them, it works fine, I can read and write, but in the whole program where they have to work several of them all together, it gives "error 7224". The same program was working with a couple of U3 and it worked fine.

Thank you.

If you pass that errorcode to LJM_ErrorToString() you should see that is "LJME_DEVICE_NOT_OPEN".  My best guess is you are not passing the correct handle, or you are calling "LJM_Close" somewhere and invalidating the handle.

Note that this is the LabVIEW_LJUD page, but the T7 uses LabVIEW_LJM.

Hello,

I am considereing the LabJack for my project, can be reassure me that it will work smoothly on W8.1 machine with LabView 2013 ?

Best regards

Martin

Plenty of people are using LV 2013 and there are no known issues, and we have no reason to expect any issues.  The link between any version of LV and our libraries is through the LV Call Library node, so really no reason to expect an LV complications.

Hi

Do you have any video / presentation tutorial for labview?

Thanks.

 

We do not provide an LabVIEW videos, but I suspect that NI and others do.  In fact, looking on youtube I do see lots of LabVIEW videos.

I'm new to labview and labjack and have searched for labview tutorials on youtube. Since you mentioned that labjack has its own drivers for labview i thought maybe you have some videos that describe those.

If you are new to LabVIEW, I suggest you just go through LabVIEW videos and tutorials.  LabVIEW is a programming language, not a simple tool, so you need to learn how to develop programs in LabVIEW.  You need to learn about controls & indicators, datatypes, dataflow, loops, arrays, and clusters, among other things.  All general LabVIEW stuff, not specific to LabJack.

Once you know some LabVIEW, talking to the U3/U6/UE9 is relatively simple.  Steps 1-6 in the instructions above give you the outline, but at the simplest level to read or write a single I/O you just drop in the sub-vi to make a call to eAIN, eDAC, eDI, or eDO.  The applicable examples show this, such as "Uxx eAIN Example.vi".

My machine has LV2014 full development installed. The Labjack installer for my U6-Pro seems to have stalled whilst loading LV runtime 7.1. Do I even need to install this, as I must already have that base covered with the main LabView installation?

The LabVIEW 7.1 runtime engine is used by LJLogUD and LJStreamUD.  If you don't intend to use these applications, then you do not need the LabVIEW 7.1 runtime engine.  I'm unsure if the newer runtime engines can run executables created with older versions, but it might be worth trying.

Sadly LJLogUD, which I was hoping to use as a starting point, insists on the 7.1 runtime. Am I right in thinking that this version just won't run on Win7, in which case maybe you could consider updating?

We have 3-5 workstations running Windows 7, and several running Windows 8, and the LabVIEW 7.1 run-time engine + LJLogUD runs normally on all of them.  Perhaps there is a conflict on your system which is preventing the LV 7.1 runtime engine from installing correctly?  You can always download & open the source code for LJLogUD, and convert it to LV 2009, '10, '11, '12, or '13 by saving the files in your newer version, and building the executable yourself.

Download the source files from this page http://labjack.com/support/ud/examples/labview

LabVIEW_LJUD_2014_11_21\LabVIEW_LJUD\Examples\LJlogUD\LJLogUD.vi

Hi I am trying to create a simple program to drive a stepper motor a certain number of steps with a time delay after each movement. After each movement I intend to take a potential reading with a probe that is connected to threaded rod over a charged metal plate. I am using an 8 wire stepper motor with unipolar configuration. Do you have any labview VI that can provide me with a starting point? I intend to buy Labjack U12 or U3 device for interfacing. Which one is more suitable? Many thanks.

The U3 is more capable than the U12 for making pulses.  See the Waveform Generation App Note.

It is probably possible to control your stepper by using a U3 to control discrete transistors or solid-state relays which energize the phases in the proper sequence, but no one does that.  You want to get a stepper controller, and then use the U3 to send a pulse-per-step to the controller.  Search labjack.com using the term stepper controller to find related forum topics.

 

Hi,

Can labjack be used to control an 8 wire stepper motor using Easy Driver? 

I googled Easy Driver and it seems to be a board that holds the A3967.  This will work fine, but one detail is that if the logic supply voltage is 5 volts (50mA typical!), the input high logic threshold is 3.5 volts, whereas the U3 provides 3.3 volts, so a detail that needs to be addressed.  Start a forum topic if you need more help with that.

Hi Everyone. What I want is to control Lock-in Amplifier with Labview. I just want the output data from Lock-In, maybe 1000 readings and take an average of them. Is it possible by Labjack. Please reply ASAP.

Thanks

What sort of signal will you get out of the amplifier?  What shape?  What frequency?  What amplitude & offset?

How fast do you want the 1000 readings?  Are you using a particular LabJack?

MADY's picture

hi , 

I am trying to read a multiple AIN , and the example is fantastic and its work very well, but the problem is i need more than 4 input and in the sample there is only 4 in put in array  channels, so the question is how can i add more input to this array ? in addition a have a CB37 Terminal Board to get more AIN input. i use labjack t7 pro

many thanks

LabJack Support's picture

We responded to your forum topic about this same issue:

https://labjack.com/forums/t7/read-multiple-ain

michael.r's picture

Hope someone can help.

I have installed the the Labjack Software installer, downloaded the LabVIEW_LJUD and extracted it to a directory, read the all important ReadMe file.

The suggestion is to open and run the  "Uxx eAIN Example.vi". If I open the VI the code is visible and the display shows the voltage. If however I have a blank VI and insert the VI the block only shown the error out terminal data and no other information. Screen Shot attached. 

LabJack Support's picture

"U6 eAIN Example.vi" is not set up to be used as a sub-vi.  Rather, it is a top level VI that demonstrates the use of some sub-vis.

Most of the examples in the \Examples folder of the LabVIEW_LJUD archive are top level VIs and not designed to be used as sub-vis.  The sub-vis you will use in your program are located in the folder \LabJackUD DLL Functions and perhaps also \Utility VIs.

To get started, I suggest you copy the code from the block diagram of "U6 eAIN Example.vi" and paste it onto the block diagram of your new VI.