Flexible I/O Overview - T4 Only
Basics: Flexible I/O are ports, channels, or lines on a LabJack device that may be configured as analog inputs, as digital inputs, or as digital outputs.
Digital I/O: 13.0 Digital I/O
Analog I/O: 14.0 Analog Inputs
Available T4 Flexible I/O Channels
As Figure 13.1-1 shows below, the LabJack T4 has 8 flexible I/O lines:
- Four screw terminals labeled FIO4 through FIO7 (also named as DIO4-DIO7 and as AIN4-AIN7)
- Four DB15 pins labeled EIO0 through EIO3 (also named as DIO8-DIO11 and as AIN8-AIN11)
Figure 13.1-1 T4 Flexible I/O
 |
The flexible I/O lines are readable/writable as digital I/O using the register names DIO4 through DIO11:
Name |
Start Address |
Type |
Access |
DIO#(4:11)
Read or set the state of 1 bit of digital I/O. Also configures the direction to input or output. Read 0=Low AND 1=High. Write 0=Low AND 1=High.
|
2004 |
UINT16 |
R/W
|
DIO#(4:11)
- Starting Address: 2004
Read or set the state of 1 bit of digital I/O. Also configures the direction to input or output. Read 0=Low AND 1=High. Write 0=Low AND 1=High.
- Data type: UINT16 (type index = 0)
-
Readable and writable
Expanded Names |
Addresses |
DIO4,
DIO5,
DIO6,
DIO7,
DIO8,
DIO9,
DIO10,
DIO11
Show All
|
2004,
2005,
2006,
2007,
2008,
2009,
2010,
2011
Show All
|
|
The flexible I/O lines are readable as analog inputs using the register names AIN4 through AIN11:
Name |
Start Address |
Type |
Access |
AIN#(4:11)
Returns the voltage of the specified analog input.
|
8 |
FLOAT32 |
R
|
AIN#(4:11)
- Starting Address: 8
Returns the voltage of the specified analog input.
- Data type: FLOAT32 (type index = 3)
-
Read-only
- This register may be streamed
Expanded Names |
Addresses |
AIN4,
AIN5,
AIN6,
AIN7,
AIN8,
AIN9,
AIN10,
AIN11
Show All
|
8,
10,
12,
14,
16,
18,
20,
22
Show All
|
|
For examples on how to use these registers, see 13.0 Digital I/O and 14.0 Analog Inputs.
Flexible I/O Auto-Configuration
Flexible I/O lines will be auto-configured in some situations. Flexible I/O can also be manually configured, as described below.
Digital Inputs - Always Auto-Configured
Reading DIO4-DIO11 always auto-configures the given line to be a digital input (before returning the digital state a 1 or 0).
Digital Outputs - Not Always Auto-Configured
Writing DIO4-DIO11 only auto-configures the given line to be a digital output if the line is currently a digital input. If the channel is currently configured as an analog input, the channel will remain configured as an analog input and the write command will be ignored.
To force a flexible I/O line to be a digital output, you can read it as digital, then write to it as digital. Be aware that an analog sensor may be damaged by driving voltage into its output.
Analog Inputs — Always Auto-Configured
Reading from AIN4-AIN11 always auto-configures a channel to be an analog input.
Flexible I/O Manual and Bulk Configuration
The following registers can configure multiple flexible I/O lines at once:
Name |
Start Address |
Type |
Access |
DIO_INHIBIT
A single binary-encoded value where each bit determines whether _STATE, _DIRECTION or _ANALOG_ENABLE writes affect that bit of digital I/O.<br>0=Default=Affected,<br>1=Ignored.
|
2900 |
UINT32 |
R/W
|
DIO_INHIBIT
- Address: 2900
A single binary-encoded value where each bit determines whether _STATE, _DIRECTION or _ANALOG_ENABLE writes affect that bit of digital I/O. 0=Default=Affected, 1=Ignored.
- Data type: UINT32 (type index = 1)
-
Readable and writable
- Default value: 0
Constant |
Value |
Affected |
0 |
Ignored |
1 |
|
DIO_ANALOG_ENABLE
Read or write the analog configuration of all digital I/O in a single binary-encoded value. 1=Analog mode and 0=Digital mode. When switching from analog to digital, the lines will be set to input. Writes are filtered by the value in DIO_INHIBIT.
|
2880 |
UINT32 |
R/W
|
DIO_ANALOG_ENABLE
- Address: 2880
Read or write the analog configuration of all digital I/O in a single binary-encoded value. 1=Analog mode and 0=Digital mode. When switching from analog to digital, the lines will be set to input. Writes are filtered by the value in DIO_INHIBIT.
- Data type: UINT32 (type index = 1)
-
Readable and writable
Constant |
Value |
Digital mode |
0 |
Analog mode |
1 |
|
DIO_DIRECTION
Read or write the direction of all digital I/O in a single binary-encoded value. 0=Input and 1=Output. Writes are filtered by the value in DIO_INHIBIT.
|
2850 |
UINT32 |
R/W
|
DIO_DIRECTION
- Address: 2850
Read or write the direction of all digital I/O in a single binary-encoded value. 0=Input and 1=Output. Writes are filtered by the value in DIO_INHIBIT.
- Data type: UINT32 (type index = 1)
-
Readable and writable
Constant |
Value |
Input |
0 |
Output |
1 |
|
DIO_STATE
Read or write the state of all digital I/O in a single binary-encoded value. 0=Low AND 1=High. Does not configure direction. A read of an output returns the current logic level on the terminal, not necessarily the output state written. Writes are filtered by the value in DIO_INHIBIT.
|
2800 |
UINT32 |
R/W
|
DIO_STATE
- Address: 2800
Read or write the state of all digital I/O in a single binary-encoded value. 0=Low AND 1=High. Does not configure direction. A read of an output returns the current logic level on the terminal, not necessarily the output state written. Writes are filtered by the value in DIO_INHIBIT.
- Data type: UINT32 (type index = 1)
-
Readable and writable
Constant |
Value |
Low |
0 |
High |
1 |
|
To configure multiple flexible I/O lines, set the relevant bits of DIO_INHIBIT, DIO_ANALOG_ENABLE, DIO_DIRECTION, and DIO_STATE—where the relevant bits are the same as the DIO channel numbers. Examples:
- To configure DIO4 (screw terminal FIO4), set bit 4 of DIO_INHIBIT, DIO_ANALOG_ENABLE, etc.
- To configure DIO5 (screw terminal FIO5), set bit 5 of DIO_INHIBIT, DIO_ANALOG_ENABLE, etc.
- To configure DIO8 (DB15 pin EIO0), set bit 8 of DIO_INHIBIT, DIO_ANALOG_ENABLE, etc.
To configure digital input(s):
- Set the relevant bit(s) of DIO_INHIBIT to 0
- Set the relevant bit(s) of DIO_ANALOG_ENABLE to 0
- Set the relevant bit(s) of DIO_DIRECTION to 0
- Read the relevant DIO register(s) or read DIO_STATE
For example, to configure DIO4 (screw terminal FIO4) as a digital input:
-
- Set bit 4 of DIO_INHIBIT to 0
- Set bit 4 of DIO_ANALOG_ENABLE to 0
- Set bit 4 of DIO_DIRECTION to 0
- Read DIO4 or read bit 4 of DIO_STATE
To configure digital output(s):
- Set the relevant bit(s) of DIO_INHIBIT to 0
- Set the relevant bit(s) of DIO_ANALOG_ENABLE to 0
- Set the relevant bit(s) of DIO_DIRECTION to 1
- Write the relevant DIO register(s) or write to DIO_STATE
For example, to configure DIO4 (screw terminal FIO4) as a digital output:
-
- Set bit 4 of DIO_INHIBIT to 0
- Set bit 4 of DIO_ANALOG_ENABLE to 0
- Set bit 4 of DIO_DIRECTION to 0
- Write to DIO4 or write bit 4 of DIO_STATE
To configure analog input(s):
- Set the relevant bit(s) of DIO_INHIBIT to 0
- Set the relevant bit(s) of DIO_ANALOG_ENABLE to 1
- Read the relevant AIN register(s)
For example, to configure AIN4 (screw terminal FIO4) as a analog input:
-
- Set bit 4 of DIO_INHIBIT to 0
- Set bit 4 of DIO_ANALOG_ENABLE to 1
- Read AIN4
Tips for Constructing Bitmasks
The DIO_INHIBIT value for allowing a write command to only affect DIO4 and DIO5 is as follows:
0x7FFFFF - (1<<4)|(1<<5) which equals 0b11111111111111111001111, 0x7FFFCF, or 8388559.
After writing 0x7FFFCF to the DIO_INHIBIT register, the DIO_ANALOG_ENABLE value for configuring DIO4 and DIO5 as analog inputs is as follows:
(1<<4)|(1<<5) which equals 0b110000, 0x30, or 48.
Flexible I/O Pull-Up
Most users will not need to use this register.
Name |
Start Address |
Type |
Access |
DIO_PULLUP_DISABLE
This register will prevent pullups from being enabled on lines set to digital input. This is a binary coded value where bit 0 represent FIO0 and bit 11 represents EIO3. 1 = pullup disabled, 0 = pullup enabled. This register only affects flex-lines which can be configured as analog or digital. This register is not affected by the inhibit register.
|
2890 |
UINT32 |
R/W
|
DIO_PULLUP_DISABLE
- Address: 2890
This register will prevent pullups from being enabled on lines set to digital input. This is a binary coded value where bit 0 represent FIO0 and bit 11 represents EIO3. 1 = pullup disabled, 0 = pullup enabled. This register only affects flex-lines which can be configured as analog or digital. This register is not affected by the inhibit register.
- Data type: UINT32 (type index = 1)
-
Readable and writable
|