Performing basic analog and digital input and output with DAQFactory and a LabJack is quite simple. This is done by creating a channel for each desired I/O point.
To create an analog input channel:
1) Click on the word CHANNELS: in the Workspace under Local. This will bring up the channel table.
Unless otherwise specified, when we say click on CHANNELS: we mean the one under Local and not under V:.
2) Click on Add to add a new row to the table
3) In the Channel Name column, put a name, say Pressure.
The channel name can be anything you’d like as long as it starts with a letter and contains only letters, numbers and the underscore.
4) In the Device Type column, select LabJack.
All your LabJack channels will use this Device. Make sure not to select LabJack_U12 as this is for the U12 only.
5) In the D# column, enter the ID of your LabJack.
If you don't know the ID of your LabJack, please read the section on setting up your device in the last chapter.
If you only have one LabJack and never expect to use any more, you can use 0 (zero) to have DAQFactory use the first found LabJack on USB. Please see the Ethernet setup section if you are using an Ethernet connection to your LabJack (UE9 only).
6) In the I/O Type column, select A to D.
7) In the Channel column, enter 0 to read the first analog input channel on your device.
8) The next column, Timing, determines how often the LabJack is queried for a new value in seconds. The default is once a second, and we can leave it at this setting.
9) Leave all the other settings as is and click Apply. As soon as you click Apply, acquisition will start.
10) To quickly see your data coming in, click on the + next to CHANNELS: in the workspace to expand the tree, then click on your Pressure channel to display the channel view for this channel.
11) The channel view has multiple tabs. The first two repeat the settings in the channel table. Click on the last tab, Table to see your values coming in from the device.
This is not the primary way to view your data, but provides a quick indication that you are getting data. If you have nothing wired into your LabJack, you are most likely going to see a non-zero floating voltage reading.
On some LabJack devices, the pins can be either analog or digital input or output. DAQFactory automatically configures it to the appropriate setting, in this case an analog input.
To create a digital input, simply repeat the same procedure, using a different Channel Name, and selecting Dig In for the I/O Type. If you are using the U3, which uses the same pins for analog and digital signals, select a different Channel Number than the one we used for analog (zero) to use a different pin. If using the U3-HV, you will have to choose a Channel number that is greater than 3 as the first 4 pins (0-3) are analog input only.
Sample file: LJGuideSamples\InputsSimple.ctl
Some devices support differential inputs. To do differential, put the channel number for the negative side of the input in the Quick Note / Special / OPC column.
The U3 has a "special" range of 0-3.6 volts for a low-voltage channel or -10 to +20 volts for a high-voltage channel. This range is not specified with typical range commands in script, but rather by specifying a differential read where the negative channel is 32. This is a signal to the UD driver to use the special range, so put channel number 32 in the Quick Note / Special / OPC column. The result is not a differential reading, but a single-ended reading with the special range.
Sample file: LJGuideSamples\InputsSimpleU3Diff.ctl
DAQFactory uses sequential channel numbers. The various LabJack devices group their I/O pins. Here is how they correspond:
The U3 uses flex pins, meaning a pin can be either an analog input, digital input or digital output. They can also be counters or timers depending on configuration. For analog input, and digital I/O the pin mapping is:
I/O Pin: | Ch: | I/O Pin: | Ch: | I/O Pin: | Ch: |
FIO0 (AIN0) | 0 | EIO0 (AIN8) | 8 | CIO0 | 16 |
FIO1 (AIN1) | 1 | EIO1 (AIN9) | 9 | CIO1 | 17 |
FIO2 (AIN2) | 2 | EIO2 (AIN10) | 10 | CIO2 | 18 |
FIO3 (AIN3) | 3 | EIO3 (AIN11) | 11 | CIO3 | 19 |
FIO4 (AIN4) | 4 | EIO4 (AIN12) | 12 | ||
FIO5 (AIN5) | 5 | EIO5 (AIN13) | 13 | ||
FIO6 (AIN6) | 6 | EIO6 (AIN14) | 14 | ||
FIO7 (AIN7) | 7 | EIO7 (AIN15) | 15 |
Note that the CIO pins are digital only. You should only use a pin for one of the three uses, so be careful not to use the same channel number for separate analog input, digital input or digital output channels.
If you enable timers or counters, they will use up the appropriate number of pins starting with FIO0. This does not change the rest of the channel numbers. So, if you have two timers enabled, they will be on FIO0 and FIO1. FIO2 remains channel 2 to DAQFactory. Of course if you use the pin offset option for timers and counters, the timers might be on different pins, but even the mapping of DAQFactory channel numbers to pins remains the same.
The U6 and UE9 have separate pins for analog and digital I/O. The analog input pins correspond directly to channel numbers, so AIN0 is channel 0, AIN1 is channel1, etc. For digital I/O, the mapping is:
Channel: | I/O Pin: |
0-7 | FIO0-FIO7 |
8-15 | EIO0-EIO7 |
16-19 | CIO0-CIO3 |
20-22 | MIO0-MIO2 |
If you enable timers or counters, they will use up the appropriate number of pins starting with FIO0. This does not change the rest of the channel numbers. So, if you have two timers enabled, they will be on FIO0 and FIO1. FIO2 remains channel 2 to DAQFactory. Of course if you use the pin offset option for timers and counters, the timers might be on different pins, but even the mapping of DAQFactory channel numbers to pins remains the same.
Creating output channels is identical to creating input channels with one important difference. Since they are output, there is no Timing parameter. In fact, if you select Analog Output or Digital Output as an I/O type, you will not be able to edit the channel's timing parameter. So, to create an output channel, we follow the same steps as an input:
1) Click on the CHANNELS: in the Workspace under Local. This will bring up the channel table.
2) Click on Add to add a new row to the table.
3) In the Channel Name column, put a name, say Output.
The channel name can be anything you’d like as long as it starts with a letter and contains only letters, numbers and the underscore.
4) In the Device Type column, select LabJack.
All your LabJack channels will use this Device. Make sure not to select LabJack_U12 as this is for the U12 only.
5) In the D# column, enter the ID of your LabJack.
If you don't know the ID of your LabJack, please read the section on setting up your device in the last chapter. If you only have one LabJack and never expect to use any more, you can use 0 (zero) to have DAQFactory use the first found LabJack on USB. Please see the Ethernet setup section if you are using an Ethernet connection to your LabJack (UE9 only).
6) In the I/O Type column, select D to A.
7) In the Channel column, select 0 to set the first analog output channel on your device.
8) As mentioned, the next column, Timing, is not used for outputs.
9) Leave all the other settings as is and click Apply.
Unlike inputs where acquisition starts immediately on Apply, creating an output channel does not actually set it to a value.
10) To quickly set the output to a value we can use the Command / Alert window. This is not the primary method of setting an output, but a quick way to test your settings. We'll show a better way in the next chapter. The Command/Alert window may be rolled up at the bottom of the screen. Click on the Command / Alert tab to display it:
If you can't see the Command / Alert tab, try going to View - Command / Alert
The Command / Alert window is made up of two parts, the status / alert display, which takes up most of the window, and the command line, which is at the bottom and takes up one line. You can type in one line commands here and see the results in the status display. You can also do commands that have no display, but change things, such as outputs. So, to set our new channel to a value of 3 volts, we type:
Output = 3
and hit Enter. There will be no confirmation other than the command itself being displayed in the status / alert area, and no error displayed. Your output will also be at 3 volts.
Like the input channels, DAQFactory will automatically set your device into the proper settings for pins with multiple duties. So, for digital pins, for example, DAQFactory will automatically set them into output mode.
Sample file: LJGuideSamples\InputsSimpleWithDA.ctl