herosdevices.hardware.texas_instruments.ads1256
===============================================

.. py:module:: herosdevices.hardware.texas_instruments.ads1256

.. autoapi-nested-parse::

   Drivers for the ADS1256 24-Bit, 30kSPS, 8-Channel ADC.







Module Contents
---------------

.. py:class:: ADS1256_CHANNEL

   Bases: :py:obj:`enum.Enum`


   Multiplexer channel.


   .. py:attribute:: AIN0
      :value: 0



   .. py:attribute:: AIN1
      :value: 1



   .. py:attribute:: AIN2
      :value: 2



   .. py:attribute:: AIN3
      :value: 3



   .. py:attribute:: AIN4
      :value: 4



   .. py:attribute:: AIN5
      :value: 5



   .. py:attribute:: AIN6
      :value: 6



   .. py:attribute:: AIN7
      :value: 7



   .. py:attribute:: AINCOM
      :value: 8



.. py:class:: ADS1256_GAIN

   Bases: :py:obj:`enum.Enum`


   Gain of the programmable gain amplifier.

   For voltage ranges for each gain settings refer to ADS1256 datasheet Table 8.


   .. py:attribute:: GAIN_1
      :value: 0



   .. py:attribute:: GAIN_2
      :value: 1



   .. py:attribute:: GAIN_4
      :value: 2



   .. py:attribute:: GAIN_8
      :value: 3



   .. py:attribute:: GAIN_16
      :value: 4



   .. py:attribute:: GAIN_32
      :value: 5



   .. py:attribute:: GAIN_64
      :value: 6



.. py:class:: ADS1256_DRATE

   Bases: :py:obj:`enum.Enum`


   Possible A/D Datarates.

   Refer to table: DRATE: A/D Data Rate (Address 03h) in the datasheet for more information.


   .. py:attribute:: DRATE_30000SPS
      :value: 240



   .. py:attribute:: DRATE_15000SPS
      :value: 224



   .. py:attribute:: DRATE_7500SPS
      :value: 208



   .. py:attribute:: DRATE_3750SPS
      :value: 192



   .. py:attribute:: DRATE_2000SPS
      :value: 176



   .. py:attribute:: DRATE_1000SPS
      :value: 161



   .. py:attribute:: DRATE_500SPS
      :value: 146



   .. py:attribute:: DRATE_100SPS
      :value: 130



   .. py:attribute:: DRATE_60SPS
      :value: 114



   .. py:attribute:: DRATE_50SPS
      :value: 99



   .. py:attribute:: DRATE_30SPS
      :value: 83



   .. py:attribute:: DRATE_25SPS
      :value: 67



   .. py:attribute:: DRATE_15SPS
      :value: 51



   .. py:attribute:: DRATE_10SPS
      :value: 32



   .. py:attribute:: DRATE_5SPS
      :value: 19



   .. py:attribute:: DRATE_2d5SPS
      :value: 3



.. py:class:: ADS1256_REG

   Bases: :py:obj:`enum.Enum`


   Registers of the ADS1256.


   .. py:attribute:: STATUS
      :value: 0



   .. py:attribute:: MUX
      :value: 1



   .. py:attribute:: ADCON
      :value: 2



   .. py:attribute:: DRATE
      :value: 3



   .. py:attribute:: IO
      :value: 4



   .. py:attribute:: OFC0
      :value: 5



   .. py:attribute:: OFC1
      :value: 6



   .. py:attribute:: OFC2
      :value: 7



   .. py:attribute:: FSC0
      :value: 8



   .. py:attribute:: FSC1
      :value: 9



   .. py:attribute:: FSC2
      :value: 10



.. py:class:: ADS1256_CMD

   Bases: :py:obj:`enum.Enum`


   Command definitions.

   Refer to table 24 in the datasheet for details.


   .. py:attribute:: WAKEUP
      :value: 0



   .. py:attribute:: RDATA
      :value: 1



   .. py:attribute:: RDATAC
      :value: 3



   .. py:attribute:: SDATAC
      :value: 15



   .. py:attribute:: RREG
      :value: 16



   .. py:attribute:: WREG
      :value: 80



   .. py:attribute:: SELFCAL
      :value: 240



   .. py:attribute:: SELFOCAL
      :value: 241



   .. py:attribute:: SELFGCAL
      :value: 242



   .. py:attribute:: SYSOCAL
      :value: 243



   .. py:attribute:: SYSGCAL
      :value: 244



   .. py:attribute:: SYNC
      :value: 252



   .. py:attribute:: STANDBY
      :value: 253



   .. py:attribute:: RESET
      :value: 254



.. py:class:: ADS1256_CLKOUT

   Bases: :py:obj:`enum.IntEnum`


   Options for setting the the clock out pin of the ADS1256.


   .. py:attribute:: OFF
      :value: 0



   .. py:attribute:: CLKIN
      :value: 1



   .. py:attribute:: CLKIN_HALF
      :value: 2



   .. py:attribute:: CLKIN_QUARTER
      :value: 3



.. py:class:: ADS1256_SDCS

   Bases: :py:obj:`enum.IntEnum`


   Options for setting the sensor current detect.


   .. py:attribute:: OFF
      :value: 0



   .. py:attribute:: I05UA
      :value: 1



   .. py:attribute:: I2UA
      :value: 2



   .. py:attribute:: I10UA
      :value: 3



.. py:function:: delay_us(delay: int) -> None

   Delay execution by `delay` microseconds (Uses sleep function).

   :param delay: delay in microseconds.


.. py:class:: ADS1256(spi_bus: int = 0, spi_device: int = 0, drdy_pin: int = 17, rst_pin: int | None = None, spi=None, gpio_device: str = '/dev/gpiochip0', default_gain: ADS1256_GAIN = ADS1256_GAIN.GAIN_1, default_drate: ADS1256_DRATE = ADS1256_DRATE.DRATE_30000SPS)

   Interfacing the ADS1256 SPI ADC (as e.g. used on the Waveshare high-precision AD-DA board).


   .. py:method:: reset() -> None

      Reset the chip by pulsing the reset pin.



   .. py:method:: config_adc(gain: ADS1256_GAIN, drate: ADS1256_DRATE, lsb: bool = False, acal: bool = True, bufen: bool = False, clkout: ADS1256_CLKOUT = ADS1256_CLKOUT.OFF, sensor_detect: ADS1256_SDCS = ADS1256_SDCS.OFF) -> None

      Configure the gain and datarate of the ADC.

      :param gain: gain to set for the PGIA
      :param drate: conversion rate to set
      :param lsb: whether to transfer to conversion results with the lsb first
      :param acal: whether to enable the automatic calibration
      :param bufen: whether to enable the input buffer



   .. py:method:: self_calibration() -> None

      Run offset and gain self calibration.



   .. py:method:: set_channel(pos_channel: ADS1256_CHANNEL, neg_channel: ADS1256_CHANNEL = ADS1256_CHANNEL.AINCOM) -> None

      Set channel of the input multiplexer.

      The multiplexer performs a differential measurement between `pos_channel` and `neg_channel`. Details can be
      found in the datasheet under "Input Multiplexer".

      :param pos_channel: Positive channel.
      :param neg_channel: Negative channel. Defaults to AINCOM (non-differential measurement).



   .. py:method:: set_scan_mode(mode)


   .. py:method:: read_adc_data(samples: int) -> list[int]

      Read ADC value from the currently active channel in bits.



   .. py:method:: get_channel_value(pos_channel: ADS1256_CHANNEL, neg_channel: ADS1256_CHANNEL = ADS1256_CHANNEL.AINCOM, samples: int = 1) -> list[int]

      Read ADC value from the given channel in bits either single-ended or differential.



   .. py:method:: get_all() -> list[list[int]]

      Read ADC for all channels subsequently.



