Skip to content

Commit

Permalink
Add support for ADAQ42xx
Browse files Browse the repository at this point in the history
AD4630 and ADAQ42xx designs are very similar, differing mainly on the
availability (or not) of PGIA gain.
Add input scale properties to handle ADAQ42xx PGIA control and add
ADAQ4216, ADAQ4220, and ADAQ4224 to the list of supported devices.

Signed-off-by: Marcelo Schmitt <[email protected]>
  • Loading branch information
machschmitt committed Nov 1, 2023
1 parent 1ee2658 commit df285a8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
41 changes: 37 additions & 4 deletions adi/ad4630.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX short identifier: ADIBSD

from decimal import Decimal

import numpy as np
from adi.attribute import attribute
Expand All @@ -25,25 +26,27 @@ class ad4630(rx, context_manager, attribute):

""" AD4630 is low power 24-bit precision SAR ADC """

_compatible_parts = ["ad4630-24", "ad4030-24", "ad4630-16"]
_complex_data = False
_data_type = np.uint32
_device_name = ""
_rx_channel_names = []

""" Default part to initialize is ad4630-24. If you don't hardware test fails"""

def __compat_parts__(self):
return ad4630._compatible_parts

def __init__(self, uri="", device_name="ad4630-24"):

context_manager.__init__(self, uri, self._device_name)

compatible_parts = ["ad4630-24", "ad4030-24", "ad4630-16"]

if device_name not in compatible_parts:
if device_name not in self.__compat_parts__(self):
raise Exception(
"Not a compatible device: "
+ str(device_name)
+ ". Please select from "
+ str(compatible_parts)
+ str(self.__compat_parts__(self))
)
else:
self._ctrl = self._ctx.find_device(device_name)
Expand Down Expand Up @@ -166,3 +169,33 @@ def calibscale(self):
def calibscale(self, calibscale):
"""Set calibration scale value."""
self._set_iio_attr(self.name, "calibscale", False, calibscale, self._ctrl)


class adaq42xx(ad4630):

""" ADAQ4224 is a 24-bit precision SAR ADC data acquisition module """

_compatible_parts = ["adaq4224", "adaq4216", "adaq4220"]

def __compat_parts__(self):
return adaq42xx._compatible_parts

def __init__(self, uri="", device_name="adaq4224"):
super().__init__(self, uri="", device_name="adaq4224")

class _channel(ad4630._channel):
"""ADAQ42xx differential channel."""

@property
def scale_available(self):
"""Provides all available scale(gain) settings for the ADAQ42xx channel"""
return self._get_iio_attr(self.channel[0].name, "scale_available", False)

@property
def scale(self):
"""ADAQ42xx channel scale"""
return float(self._get_iio_attr_str(self.name, "scale", False))

@scale.setter
def scale(self, value):
self._set_iio_attr(self.name, "scale", False, str(Decimal(value).real))
3 changes: 3 additions & 0 deletions supported_parts.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
- AD4858
- AD9739A
- ADA4961
- ADAQ4216
- ADAQ4220
- ADAQ4224
- ADAQ8092
- ADAR1000
- ADF4159
Expand Down

0 comments on commit df285a8

Please sign in to comment.