13.1 Flexible I/O (T4 Only) [T-Series Datasheet]
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.
Device Control Basics:
All T-series device features are controlled by reading and writing Modbus TCP registers via Modbus TCP (either directly or through our LJM library).
We have register descriptions throughout documentation detailing relevant register names, starting addresses, types, and access permissions (read/write).
See Section 3.0 Communication for other detailed communication information.
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)
The flexible I/O lines are readable/writable as digital I/O using the register names DIO4 through DIO11:
The flexible I/O lines are readable as analog inputs using the register names AIN4 through AIN11:
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:
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
The T4 can disable the pull-ups on some of its IO lines. An IO line with its pull-up disabled will be floating, any readings will not be meaningful until an external signal is connected. Pull-ups can be disabled on FIO4(DIO4) through EIO3 (DIO11).