Skip to main content
Skip table of contents

8.1 - Using() and include() for LabJack (Applies to UD-Series)

There are two important commands to make communicating with a LabJack using script easier. With these commands, script in DAQFactory for communicating with a LabJack will look almost identical to the psuedo-code that is in the LabJack User's Guide, and any C examples provided by LabJack. We recommend putting these two functions at the top of a sequence setup as AutoStart, so that it runs when your document is loaded. All subsequent samples assume this has been done. To do this:

1) Right click on SEQUENCES: in the workspace and select Add Sequence

2) Type in a name, say StartUp for the new sequence and click OK

3) The sequence editor will appear. Click in it and type the following two lines:

include("c:\program files\labjack\drivers\labjackud.h")

You may need to change the path in the second line to match the location of your labjackud.h file if you did not install the LabJack drivers in their default location.

4) Check the box just above the editor that says Auto-Start, then click Apply to save your changes.

5) If you are going to continue to work on the document without reloading it, you'll need to manually run this sequence, so right click on the sequence name, StartUp, in the Workspace and select Begin Sequence. The sequence will run instantly, so you won't really be able to tell that it ran.

Next time you load this document, the sequence will run and you are ready to go.

Now an explanation:


DAQFactory supports a wide variety of devices. Each device has different functions available to it. In LabJack's case, some of the functions are AddRequest, GoOne, etc. Because it is possible for two different devices to use the same function names, you normally have to prefix all your LabJack function calls with device.labjack. For example:


If you are only using a LabJack, this extra typing can be a pain, and makes code harder to read, so we allow you to specify different objects that don't require the object designation. Technically speaking this is bringing the function
into the global namespace, but you don't have to worry about that. Just know that once you do the command in a document:


You don't have to put device.labjack. in front of the LabJack functions.

This resets when you load a new document, so you'll need to put this function call in an AutoStart sequence for each
of your documents.

include("c:\program files\labjack\drivers\labjackud.h")

The LabJack UD Driver uses a large number of constants to allow you access to the rather large number of features in these devices. To get access to these constants, we could hard code them into DAQFactory, but the folks at LabJack are constantly improving their devices and adding more features. With more features comes more constants and we simply can't keep up. So, with this include() call you are loading all the constants from the LabJack supplied file. That way, you always get the latest LabJack capabilities, without having to upgrade DAQFactory. This function works just like a C include, except that it only pulls out numeric constants.

Once the command has run, you can go to the Command / Alert window and in the bottom command area type:


hit Enter, and it will display 200, the value of this constant.

It should be noted that while C is a case sensitive language, DAQFactory is not, so ? lj_ioadd_stream_channel will work just as well. That said, it will probably make your code more readable if you keep the case used in the constants.

JavaScript errors detected

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

If this problem persists, please contact our support.