> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lagerdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ADC

> Read analog-to-digital converter values

Read analog-to-digital converter (ADC) values from your box. Supports LabJack T7, LabJack U3 and MCC USB-202 hardware with per-hardware channel naming and voltage ranges.

## Syntax

```bash theme={null}
lager adc [NET] [OPTIONS]
```

## Arguments

| Argument | Description                                              |
| -------- | -------------------------------------------------------- |
| `NET`    | Name of the ADC net to read (optional if default is set) |

## Options

| Option       | Description                                                   |
| ------------ | ------------------------------------------------------------- |
| `--box TEXT` | Lager Box name or IP address                                  |
| `--json`     | Emit a machine-readable JSON object instead of formatted text |
| `--help`     | Show help message and exit                                    |

## Usage

### Read ADC Value

Read voltage from an ADC net:

```bash theme={null}
lager adc SENSOR_1 --box my-lager-box
```

**Output:**

```
ADC 'SENSOR_1': 2.450000 V
```

The result is returned in volts with 6 decimal places.

### List ADC Nets

When invoked without a net name (and no default is set), lists all available ADC nets:

```bash theme={null}
lager adc --box my-lager-box
```

**Output:**

```
Name            Net Type  Instrument       Channel  Address
================================================================
VOLTAGE_SENSOR  adc       LabJack_T7       AIN0     USB::470026574
TEMP_SENSOR     adc       LabJack_T7       AIN1     USB::470026574
CURRENT_MON     adc       MCC_USB202       CH0      USB0::0x09DB::0x012B::...
```

## Supported Hardware

| Manufacturer          | Model   | Channels        | Voltage Range                                   | Input Mode   |
| --------------------- | ------- | --------------- | ----------------------------------------------- | ------------ |
| LabJack               | T7      | 14 (AIN0-AIN13) | +/-10 V                                         | Single-ended |
| LabJack               | U3      | 16 (AIN0-AIN15) | U3-HV: AIN0-AIN3 +/-10.3 V, AIN4-AIN15 0-2.44 V | Single-ended |
| Measurement Computing | USB-202 | 8 (CH0-CH7)     | +/-10 V                                         | Single-ended |

### Hardware Comparison

| Feature          | LabJack T7                          | MCC USB-202                       |
| ---------------- | ----------------------------------- | --------------------------------- |
| Channel count    | 14                                  | 8                                 |
| Channel names    | AIN0-AIN13                          | CH0-CH7                           |
| Pin input format | `0`-`13` or `AIN0`-`AIN13`          | `0`-`7` or `CH0`-`CH7`            |
| Voltage range    | +/-10 V (bipolar)                   | +/-10 V (bipolar)                 |
| Resolution       | 16-bit (\~0.3 mV/LSB)               | 12-bit (\~4.9 mV/LSB)             |
| Connection       | Shared handle (with DAC, GPIO, SPI) | Per-transaction open/close        |
| Device selection | Auto-discovered (no address needed) | Via serial number or VISA address |

### LabJack U3

The U3 uses a different driver stack from the T7: the LabJack Exodriver and LabJackPython. The two families can share one Lager Box.

* The ranges above are LabJack's figures for a U3-HV. On a U3-HV, `AIN0`-`AIN3` are fixed high-voltage inputs.
* `AIN4`-`AIN7` are the same physical pins as `FIO4`-`FIO7`, and `AIN8`-`AIN15` are the same pins as `EIO0`-`EIO7`. An `adc` read sets the pin to analog mode, and a `gpio` read or write on the same pin sets it back to digital mode.
* `AIN8`-`AIN15` are on the DB15 connector of the U3.
* Lager treats every U3 as a U3-HV, because a U3-LV reports the same USB product ID.

### Channel Naming

When you create an ADC net, use a channel name that `lager instruments` lists for the instrument. `lager nets add` refuses any other value, including a numeric shorthand such as `0`, and prints the valid channels.

**LabJack T7:** `AIN0`-`AIN13`

```bash theme={null}
lager nets add SENSOR_1 adc AIN0 USB0::0x0CD5::0x0007::::INSTR
```

**LabJack U3:** `AIN0`-`AIN15`

```bash theme={null}
lager nets add SENSOR_1 adc AIN0 USB0::0x0CD5::0x0003::::INSTR
```

**MCC USB-202:** `CH0`-`CH7`

```bash theme={null}
lager nets add SENSOR_1 adc CH0 USB0::0x09DB::0x012B::<SERIAL>::INSTR
```

### Instrument Name Matching

The backend driver is selected based on the instrument name in the net configuration:

| Pattern                                                       | Driver      |
| ------------------------------------------------------------- | ----------- |
| `labjack` + `t7` (case-insensitive, flexible separators)      | LabJack T7  |
| `labjack` + `u3` (case-insensitive, flexible separators)      | LabJack U3  |
| `mcc` + `usb` + `202` (case-insensitive, flexible separators) | MCC USB-202 |

## Default Net

Set a default ADC net to avoid specifying the name each time:

```bash theme={null}
lager defaults add --adc-net SENSOR_1
```

Then:

```bash theme={null}
lager adc
```

## Examples

```bash theme={null}
# Read ADC value from voltage sensor
lager adc VOLTAGE_SENSOR --box my-lager-box

# Read ADC value from temperature sensor
lager adc TEMP_SENSOR --box my-lager-box

# Read ADC value from current monitor
lager adc CURRENT_MONITOR --box my-lager-box

# List all ADC nets on the box
lager adc --box my-lager-box

# Use default net (if configured)
lager adc
```

## Scripting Example

```bash theme={null}
#!/bin/bash
# Read sensor and check threshold
RESULT=$(lager adc VOLTAGE_SENSOR --box my-lager-box)
echo "$RESULT"

# Extract numeric value
VOLTAGE=$(echo "$RESULT" | grep -oP '[\d.]+(?= V)')
if (( $(echo "$VOLTAGE > 3.0" | bc -l) )); then
    echo "Voltage too high: $VOLTAGE V"
    exit 1
fi
echo "Voltage OK: $VOLTAGE V"
```

## Notes

* Results are returned in volts with 6 decimal places
* The LabJack T7 and the USB-202 support bipolar measurement (+/-10 V range)
* On a LabJack U3, only `AIN0`-`AIN3` of a U3-HV are bipolar
* ADC nets must be configured before use with `lager nets add <name> adc <channel> <address>`
* Default net can be set with `lager defaults add --adc-net`
* LabJack T7 shares a connection handle with DAC, GPIO, and SPI operations on the same device
* USB-202 opens and closes the connection on each read
* Use `lager instruments --box <box>` to verify the ADC device is detected

## See Also

* [DAC](/source/reference/cli/dac) -- Digital-to-analog converter output (the complement of ADC)
* [Python ADC API](/source/reference/python/adc) -- Read ADC values in Python scripts
