Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 17 Devices

17.8 LabJack U12 device

Scroll Prev Top Next More

This device driver communicates with the LabJack U12 USB data acquisition device.  While this driver still functions, DAQFactory no longer supports channel commands and so functions listed below that require channel commands (such as streaming) are therefore no longer supported, though existing documents should still work.  If you need to expand existing use of the U12 or start anew, we recommend remaining on release 19.1 or earlier, or better yet consider updating to a newer version of the LabJack such as the U3 or T4.

To perform the basic functions of the LabJack U12, you simply have to create some channels for communication.  You should pass the ID number of the desired LabJack U12 as the Device # parameter of your channel.  A device number of 0 will select the first found LabJack U12 device and is the easiest method if you only have one LabJack U12.   You cannot use device number 0 if you have more than one LabJack U12.

Device Details:

The LabJack U12 requires 20ms to perform any acquisition block.  An acquisition block is either reading of up to 4 A to D channels, setting either or both D to A’s, setting / reading the digital outputs, and reading the counter.  Therefore, do not make your Channel Timing values less than 0.02 seconds, as the LabJack will not be able to keep up.  If you are using more than one acquisition block, your Timing values will have to be corresponding larger.  DAQFactory, is however, multithreaded, so while it takes 20ms to communicate with a single LabJack, if you have two LabJacks, you can communicate with the second LabJack at the same time, thus increasing the maximum throughput.  This follows for 3, 4, or more LabJacks.  In order to do this however, you must give the Channels on the different LabJacks a different Timing and Offset parameter.  The difference can be as small as 0.001 if you would like.  This is actually one of the uses for the Offset parameter.

Analog Input: There are two types of analog inputs with the LabJack, single ended and differential.  All are 12 bit and return measurements in volts. Single ended inputs are wired into AI0 through AI7 and GND and provide 8 inputs.  Differential inputs are wired in pairs, AI0-AI1, AI2-AI3, AI4-AI5, AI6-AI7.  The GND terminal is not used.  Because two lines are used for each differential input, the LabJack only provides 4 differential inputs.  Differential inputs have two advantages over single ended.  First, they cancel possible noise in your wiring, and second they have programmable range.  If you do not need to more than 4 inputs, we recommend using the differential inputs.

Example - Reading an analog input at 1 hz.  See under Streaming Analog Input below for rates faster than 50hz.

1. Starting from a blank document with a single LabJack plugged into your computer, click on CHANNELS: in the workspace to display the channel table.  Click on Add to add a blank row to the table.

2. Enter a simply channel name like Input0 for the channel name column.  For device type, select LabJack_U12.  For device number enter 0.  Select A to D for I/O type.

3. If you want to read one of the eight single ended inputs, enter 0 through 7 for channel number, corresponding to AI0 through AI7.  For differential inputs, use 8 through 11, corresponding to AI0-AI1, AI2-AI3, AI4-AI5, and AI6-AI7.  In this example, select one of the differential inputs, say 8.

4. The next column is timing which determines how often the analog channel is read.  The LabJack has a maximum software polled rate of 50hz, so the timing column should never have a value less than 0.02.  As you use more and more inputs and outputs, the minimum timing value will grow.  If you are getting C1038 Timing Lag errors then your timing values are probably too small.  For now, leave it at 1.00.

5. Click Apply to save your new channel.  DAQFactory will immediately start reading from the LabJack.  The LED on the LabJack unit should flash indicating DAQFactory is communicating with it.

6. To quickly see the data, click on the + sign next to CHANNELS in the workspace, then click on your new channel that will appear when the tree expands.  This will display the channel view.  Click on the Table tab to see the actual values in tabular form.

Example - Setting the range on a differential channel.  Range is not an option with single ended inputs.  Range is set using a channel command.

1. Create a new channel in the channel table: LabJack_12 device type with a device number of 0 (assuming you have only one LabJack).  I/O type is Command.  Channel # is 0.  If you have multiple channel commands on this LabJack, make sure each has a unique channel number.  

2. Under Quick Note / Special / OPC for the channel a button should appear along the right side of the cell with three dots (...).  Click on this button.  

3. The Channel Parameters window will appear.  From the drop down at the top of the window, select Gain Settings.

4. There are two parameters that will appear in the table.  Channels takes a comma delimited list of channels to set the gain for.  Since single ended channels do not have gain, valid channels are 8 through 11.  For example 8,9,10,11 would set all the channels to the same gain.  The second parameter is the Gain.  Select from the drop down list the desired range.  Click OK.

5. Click Apply to save your new channel.  Simply creating the channel does not actually set the gain.  To do this you must set the channel to something.  It does not matter what.  The simple way to do this is to go to the Command / Alert window and enter myChannel = 0 where myChannel is the name of the channel you just created.

Analog Output: The U12 supports two 10 bit analog output channels.  These are both 0 to 5 volt outputs.

Example - Creating and setting an analog output channel.

1. Starting from a blank document with a single LabJack plugged into your computer, click on CHANNELS: in the workspace to display the channel table.  Click on Add to add a blank row to the table.

2. Enter a simply channel name like Output0 for the channel name column.  For device type, select LabJack_U12.  For device number enter 0.  Select D to A for I/O type.

3. The two analog output channels of the LabJack are numbered 0 and 1 corresponding to the AO0 and AO1 pins on the device.  Enter the desired number in the channel column.

4. Click Apply to create your new channel.  Once you have the channel created you can now set it to a value.  The quick way to do this is to go to the Command / Alert window and enter myChannel = 4, where myChannel is the name you gave the output channel, and 4 is the desired voltage setting between 0 and 5.  You can also set this value using various page components or in an automated sequence.  This is described in the rest of the DAQFactory documentation.

Digital I/O: The U12 supports 20 channels of Digital I/O numbered 0 to 19.  0 through 3 are the front panel IO0 though 3 pins.  4 through 19 are the D0 through D15 pins on the DB25 on the side of the unit.  Each can be configured for either input or output by simply assigning it to a DigIn or DigOut Channel.  The current state of a DigOut can be read back using the same DigIn channel once the DigOut is set.  Until a DigOut is set, the channel is assumed to be an output.  Use the Set I/O to Dig In command to revert a channel assigned as an output back to an input.

Example - To read a digital input, simply follow the example provided for the analog input, but use the Dig In I/O type instead.

Example - To create a digital output, simply follow the example provided for the analog output, but use the Dig Out I/O type instead.  When you get to step 4 you can set the channel to either 0 or 1 as digital outputs only have two valid values.

Example - All the I/O pins on the LabJack can be input or output.  When the LabJack is first plugged in, all the pins are set as inputs.  Once you set a pin to a value using the Dig Out I/O type, it is considered an output.  To switch it back to a digital input:

1. Create a new channel in the channel table: LabJack_12 device type with a device number of 0 (assuming you have only one LabJack).  I/O type is Command.  Channel # is 0.  If you have multiple channel commands on this LabJack, make sure each has a unique channel number.  

2. Under Quick Note / Special / OPC for the channel a button should appear along the right side of the cell with three dots (...).  Click on this button.  

3. The Channel Parameters window will appear.  From the drop down at the top of the window, select Set I/O to Dig In.

4. There is one parameter that will appear in the table.  The channels parameter takes a comma delimited list of channels to set to digital input, for example 0,1,2,3 would refer to the front IO0 through 3 pins.  Select your channels and click OK.

5. Click Apply to save your new channel.  Simply creating the channel does not actually set the digital channel.  To do this you must set the channel to something.  It does not matter what.  The simple way to do this is to go to the Command / Alert and enter myChannel = 0 where myChannel is the name of the channel you just created.  

Counter: The U12 supports a single 1 Mhz counter numbered 0.  Since there is only one counter, all data comes back on channel number 0.  By default, the counter is reset every time it is read.  There is a channel command associated with this I/O type that allows you to keep the counter from resetting.

Example - To read the counter, simply follow the example provided for the analog input, but use the Counter I/O type instead.  Only channel 0 is supported.

Example - Setting the counter to not reset:

1. On the row of the counter channel that you created, under Quick Note / Special / OPC for the channel a button should appear along the right side of the cell with three dots (...).  Click on this button.  

2. The Channel Parameters window will appear.  From the drop down at the top of the window, select Reset.

3. The only parameter for this command is Reset?.  Select Yes or No then click OK.

4. Click Apply to save your changes to the channel.  The effect of the change is immediate.

Temperature / Humidity Probe (EI-1050): The EI-1050 is a digital temperature / humidity probe.  To query this device, create two channels, both with I/O type "Special", one with channel #0, and one with channel #1.  Channel #0 is the temperature in degrees C, while channel #1 is the humidity.  You must put a timing on channel #0 as this triggers the read of both sensors.

Streaming Analog Input: The U12 has the ability to stream its inputs instead of being polled for data.  When streaming, the internal clock of the LabJack determines when data is acquired and the data is passed back to DAQFactory in blocks.  This allows much faster data rates than would be possible using software polled mode described above.  Unfortunately, when the LabJack is streaming you cannot do anything else with that LabJack.  If you have two LabJacks you can work with the channels on the second LabJack, but on the streaming LabJack you should have the Timing parameter for all its channels set to 0.  There are three different modes of streaming:

Continuous Streaming: This mode causes the LabJack to continuously stream the requested inputs until manually stopped.  It is initiated with the Start Stream channel command, and stopped with the Stop Stream channel command.  The maximum data rate is 1200 samples per second.

Example:

1. Starting from a new document, go to the channel table by clicking on CHANNELS: in the workspace.

2. Click the Add button to add a new row.  Call the new channel StartStream, device type LabJack_U12, device number 0, I/O type Command, channel #0.

3. Under Quick Note / Special / OPC for the channel a button should appear along the right side of the cell with three dots (...).  Click on this button.  

4. When the parameter window appears, select Start Stream from the drop down at the top.

5. Four parameters will appear in the table:

a. Stream Channels: this takes a comma delimited list of channels to stream.  You can enter up to four channels.  For this example, enter 8,9,10,11.  This will stream the 4 differential channels.  

b. Stream Gains: this takes a comma delimited list of gain numbers (0-7) for each channel listed.  You can leave this blank to use the default gains.  This does not apply to single ended channels. For this example, leave it blank.

c. Stream Scan Rate: enter the desired scan rate.  A scan is the reading of all channels listed under Stream Channels.  Since the maximum rate is 1200 samples per second, the maximum scan rate is 1200 / number of channels read.  So if you are streaming four channels, the maximum scan rate is 300.  For this example, enter 100.

d. Stream Counter: you can optionally stream the counter reading.  This uses three of the four slots available for channels, so you can only stream one other A to D channel when streaming the counter.  Data comes in under the Counter I/O type, channel 0.  For this example, select No.

6. Click OK to close the parameters box, then click Duplicate to duplicate the channel you just created.  Give the new row the name StopStream.  Leave all the parameters as they are, but click on the Quick Note / Special / OPC button again to display the parameters window.

7. This time, select Stop Stream.  There are no parameters for this command, so hit OK, then Apply to save your two new channels.

8. Simply creating these channels does not actually perform streaming.  To do this you must set the channels to something.  It does not matter what.  The simple way to do this is to go to the Command/Alert window and in the small box type in StartStream = 0.  This should start the streaming.  The LED on your LabJack will flash rapidly.  You can also use components or sequences to set this channel and start streaming.

9. Even though the streaming is running, the data is going no where.  We have to create channels to accept the data.  In the channel table, click Add.  In the new row, call the new channel AI8, device type LabJack_U12, device number 0, I/O type A to D, channel #8.  Set the Timing to 0.  This is important or DAQFactory will try and read the channel in software polled mode and this will stop the streaming.

10. You can optionally create channels for 9, 10 and 11 which are also streaming.  When done, click Apply.

11. To quickly see the data coming in, click on the + next to CHANNELS: in the workspace, then click on the AI8 channel.  This will display the channel view for that channel.  Click on the Graph page to view a graph of the incoming data, or optionally, click on Table to see the readings in tabular form.  You can now use the rest of the DAQFactory page components, such as the 2D graph, to better display your data.

Burst Streaming: This mode causes the LabJack to stream for a preset amount of time.  This mode allows for faster data rates, up to 8192 samples per second, but can only take 4096 samples at a time.  It is initiated with the Burst Mode channel command.

Example:

1. Starting from a new document, go to the channel table by clicking on CHANNELS: in the workspace.

2. Click the Add button to add a new row.  Call the new channel StartBurst, device type LabJack_U12, device number 0, I/O type Command, channel #0.

3. Under Quick Note / Special / OPC for the channel a button should appear along the right side of the cell with three dots (...).  Click on this button.  

4. When the parameter window appears, select Burst Mode from the drop down at the top.

5. Six parameters will appear in the table:

a. Burst Channels: this takes a comma delimited list of channels to burst stream.  You can enter up to four channels.  For this example, enter 8,9,10,11.  This will stream the 4 differential channels.  

b. Burst Gains: this takes a comma delimited list of gain numbers (0-7) for each channel listed.  You can leave this blank to use the default gains.  This does not apply to single ended channels. For this example, leave it blank.

c. Burst Scan Rate: enter the desired scan rate.  A scan is the reading of all channels listed under Stream Channels.  Since the maximum rate is 8192 samples per second, the maximum scan rate is 8192 / number of channels read.  So if you are streaming four channels, the maximum scan rate is 2048.  For this example, enter 1000.

d. Burst Number of Scans: enter the desired number of scans to perform.  The maximum number of samples is 4096, so if you are sampling 4 channels per scan, the maximum number of scans is 1024.  For this example, enter 100.

e. Burst Trigger: You can optionally have the LabJack use one of the IO pins as a trigger for the burst.  In this row, you can select which IO pin to use, or select None or leave blank for no triggering.  For this example, just leave this field blank.

f. Burst Trigger State: If you specified a burst trigger, you will need to specify whether you want to trigger when the indicated IO pin goes high (5V), or low (0V). For this example, leave the field blank.

6. Click OK to close the parameters box.  Now we need to create channels to receive the data.  In the channel table, click Add.  In the new row, call the new channel AI8, device type LabJack_U12, device number 0, I/O type A to D, channel #8.  Set the Timing to 0.  This is important or DAQFactory will try and read the channel in software polled mode and this will stop the streaming.

7. You can optionally create channels for 9, 10 and 11 which will also burst stream.  When done, click Apply.

8. In this example, we will create some screen components for triggering the burst and graphing the data on AI8.  Go to the page view by clicking on Page_0 in the workspace.  The page view will be a blank white screen.

9. Right click in the upper left corner of the white space and select Buttons-Button.  Right click on the new component and select Properties...

10. In the Text property, enter Burst.  Then go to the Action page and select Toggle Between.  Next to Action Channel enter StartBurst.  For the two toggle between parameters, enter 0 and 0.  It does not matter what we set the StartBurst channel too, so we are just going to set it to 0 every time the button is clicked.  Click OK.

11. Right click in another area of the screen and select Graphs - 2D Graph.  You may want to resize the graph that appears by holding down the Ctrl key and dragging one of the black squares surrounding the graph.

12. Right click on the graph and select Properties...

13. Under Y Expression enter AI8 and then click OK.

14. Now click on the button you created to start burst mode.  The burst mode only lasts 0.1 seconds, so it will go quick.  The graph should update, but might be out of range.  Right click on the graph and select AutoScale - Y axis to fix this.

PreTrigger Streaming: This allows you to run in stream mode, but only log data around a certain event, either a threshold crossing for an analog channel, or a digital channel going high or low (or both).  It is initiated with the PreTrigger Stream channel command and can be stopped with the Stop Stream channel command.  Since it uses continuous streaming, the maximum data rate is 1200 samples per second.  The setup is very similar to burst and stream.  Here are the parameters of the channel command that are different than the Start Stream:

Trigger Channels: takes a comma delimited list of channels to monitor.  These channels must be among the channels listed in Scan Channels.  

Trigger Thresholds: takes a comma delimited list of voltage readings above or below which the trigger will have said to occur.  There should be one threshold for each Trigger Channel listed.  

Reset Threshold: the value above or below which the trigger is reset and another trigger can occur.  For no historesis, set these values to the same values as the Trigger Thresholds.

Trigger Types: determines whether the trigger occurs above or below the threshold.

Digital Trigger Channels:  takes a comma delimited list of digital channels to use as triggers.  Only channels 0-3 can be used (IO0-IO3).

Digital Trigger States (trigger on 1 or 0): takes a comma delimited list, one item for each digital trigger.  If the item is 1, then the digital trigger occurs when the signal goes high.  If the item is 0, then the digital trigger occurs when the signal goes low.  

Pretrig Samples: the number of samples before the trigger event occurs to log.  Can be 0.

PostTrig Samples: the number of samples after the trigger event occurs to log (including the trigger value).  Must be >= 2.

Immediate Retrigger: If yes, then a reset followed by a trigger while the PostTrig samples are being logged results in the posttrig sample counter being reset to Posttrig Samples.  If no, then a retrigger during posttrig acquisition does nothing.  Digital triggers do not need to be reset, a digital signal that remains in its trigger state will continually trigger.

Display Incoming?: If yes, then data from the stream will be output to channels of I/O type Special throughout the PreTriggering.  This allows you to view the data being taken at all times.  Simply create new Channels with I/O type Special, and channel numbers matching the A/D channels.  

Some notes about PreTriggering:  

· Data is not logged until all the PostTrig samples are taken.

· If the type is Above, the trigger occurs when reading > threshold and resetting occurs when reading < reset threshold. (and vice-versa)

· You can trigger off of any, or all of the channels being streamed.  Each trigger must be independently reset before that particular trigger will refire.  However, if a trigger on one channel fires, but is not reset, then a trigger on another channel fires, the second trigger will be recognized.

· Digital triggers do not need to be reset.  They will continually refire if they remain in the trigger state.  This allows you to use digital lines to start and stop logging.

Note: while doing high speed acquisition, you cannot do any other I/O on the LabJack.  Any attempt will stop the high speed acquisition. If you have multiple LabJacks, you can perform high speed acquisition on only one LabJack.  You can however, perform I/O on the other LabJacks while the high speed acquisition is occurring.

Note: when taking and logging data faster than 20hz you'll need to set the Alignment Threshold parameter of your logging set to 0 to avoid missing data points in your logging set.

Sequence optimization channel commands:

The following channel commands are typically used in sequences to utilize the LabJack in the most efficient manner:

Read Digital Block: Reads a block of digital channels in one call to the LabJack.  Put a comma delimited list of desired digital channels (0-19) in the channels parameter.

Write Digital Block: Writes a block of digital channels in one call to the LabJack.  Put a comma delimited list of desired digital channels (0-19) in the channels parameter, and a corresponding comma delimited list of 0's or 1's to output to each channel in the Values parameter.

Write Digital Block Single Value:  Writes a block of digital channels in one call to the LabJack.  Put a comma delimited list of desired digital channels (0-19) in the Channels parameter.  The Value parameter takes a single value that is bitwise parsed to each digital output channel.  The first channel in the list is the LSB, the last, the MSB.  So, if you put 0,3,5,7 in the Channels parameter, and 9 in the Value parameter, you would get a 1 output to channels 0 and 7, and a 0 output to channels 3 and 5.  This command is very useful if you put the word "Value" in for the Value parameter.  Then the outputs are set to whatever you set this channel command to.

Read Analog Block: Reads a block of analog channels in one call to the LabJack.  Put a comma delimited list of desired analog channels (0-11) in the Channels parameter.

Write Analog Block: Writes a block of analog channels in one call to the LabJack.  Put a comma delimited list with two values in the Values parameter.  The first value in the list is output to AO0, the second to AO1.