NAME

Device::Chip::ADS1115 - chip driver for ADS1115

SYNOPSIS

use Device::Chip::ADS1115;
use Future::AsyncAwait;

my $chip = Device::Chip::ADS1115->new;
await $chip->mount( Device::Chip::Adapter::...->new );

await $chip->change_config( MUX => "0" );
await $chip->trigger;

printf "The voltage is %.2fV\n", await $chip->read_adc_voltage;

DESCRIPTION

This Device::Chip subclass provides specific communications to a chip in the Texas Instruments ADS111x family, such as the ADS1113, ADS1114 or ADS1115. Due to similarities in hardware, it also works for the ADS101x family, consisting of ADS1013, ADS1014 and ADS1015.

The reader is presumed to be familiar with the general operation of this chip; the documentation here will not attempt to explain or define chip-specific concepts or features, only the use of this module to access them.

METHODS

The following methods documented in an await expression return Future instances.

read_config

$config = await $chip->read_config;

Returns a HASH reference containing the chip's current configuration.

OS   => 0 | 1
MUX  => "0" | "1" | "2" | "3"            # single-ended
        | "0-1" | "0-3" | "1-3" | "2-3"  # bipolar
PGA  => "6.144V" | "4.096V" | "2.048V" | "1.024V" | "0.512V" | "0.256V"
MODE => "CONT" | "SINGLE"
DR   => 8 | 16 | 32 | 64 | 128 | 250 | 475 | 860

COMP_MODE => "TRAD" | "WINDOW"
COMP_POL  => "LOW" | "HIGH"
COMP_LAT  => 0 | 1
COMP_QUE  => 1 | 2 | 4 | "DIS"

change_config

await $chip->change_config( %changes );

Changes the configuration. Any field names not mentioned will be preserved at their existing values.

trigger

await $chip->trigger;

Set the OS bit configuration bit, which will cause the chip to take a new reading of the currently-selected input channel when in single-shot mode.

read_adc

$value = await $chip->read_adc;

Reads the most recent reading from the result register on the chip. This method should be called after a suitable delay after the "trigger" method when in single-shot mode, or at any time when in continuous mode.

The reading is returned directly from the chip as a plain 16-bit signed integer. To convert this into voltage use the "read_adc_voltage" method.

read_adc_voltage

$voltage = await $chip->read_adc_voltage;

Reads the most recent reading as per "read_adc" and converts it into a voltage level by taking into account the current setting of the PGA configuration option to scale it.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>