Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 17 Devices > 17.9 LabJack M (T4 / T7 / T8 etc) > 17.9.4 Calling the LabJack M Driver

17.9.4.2 Doing Configuration Steps

Scroll Prev Top Next More

As we showed in the chapter Basic I/O, there is a lot you can do with DAQFactory and your LabJack without having to do any scripting.  More than likely you will move into a little scripting when you want to tweak the configuration of your LabJack.  This is often done in a sequence marked Auto-Start so the configuration is done automatically when your DAQFactory document loads.  The format of these configuration commands are quite simple:

1) Right click on SEQUENCES: in the Workspace and select Add Sequence.  Give it the name StartUp

2) The sequence editor window will appear.  Check the AutoStart at the top, and then in the window type in the following script:

 

using("device.labjack.")

 

global string ljID = "any"
 

// set AIN0-AIN3 to +/-10V, +/-10V, +/-1V, and +/-0.1V.

LJM_eWriteName(ljID, "AIN0_RANGE", 10)
LJM_eWriteName(ljID, "AIN1_RANGE", 10)

LJM_eWriteName(ljID, "AIN2_RANGE", 1)

LJM_eWriteName(ljID, "AIN3_RANGE", 0.1)

3) Click on Apply to save your changes.  

When you specify AutoStart, the sequence is run when the document is loaded.  It is not rerun every time you save changes, so you'll need to run the sequence at this point.

4) Right click on the sequence name StartUp in the workspace and select Begin Sequence.  This will run the sequence and configure the LabJack.  If you change this sequence, for example, to change the range on AIN1, you will need to rerun the sequence to actually send the commands to the LabJack.

A few comments:

This code uses a global string to hold the LabJack identifier so that we can change that identifier in the future without having to change every line of script.  This does not, however, affect the D# of any channels you have, which will have to be updated manually.

Setting the LabJack ID to "any" finds the first found LabJack.  This works well if you only have one LabJack, but can cause a problem if you have more than one LabJack T series as you cannot predict which one the driver will pick!  

Likewise, it is important not to use both "any" and a specific identifier to reference the same device as this will open two connections to the device.  This can in turn cause issues with some functions, especially streaming.

Please review the LabJack User's Manual for the various string values like AIN0_RANGE that are available.  These are LabJack specific and are the same strings you would use in other applications outside DAQFactory.

With the exception of streaming, these commands are passed directly to the LabJackM driver without any processing except for the ID.  The normal LabJackM drivers take a handle, but DAQFactory keeps track of the handle for you, tying it to the identifier string you provide.  This is why it is important to use the same identifier for a device and not mix "any" with a specific identifier like "192.168.0.10" when referring to the same device.