|
| 1 | +# Copyright (C) 2025 Analog Devices, Inc. |
| 2 | +# |
| 3 | +# SPDX short identifier: ADIBSD |
| 4 | +import numpy as np |
| 5 | + |
| 6 | +from adi.context_manager import context_manager |
| 7 | +from adi.rx_tx import rx |
| 8 | + |
| 9 | + |
| 10 | +class ad7768_1(rx, context_manager): |
| 11 | + |
| 12 | + """ AD7768-1 1-channel, Dynamic Signal Analysis Sigma-Delta ADC """ |
| 13 | + |
| 14 | + _device_name = " " |
| 15 | + _rx_data_type = np.int32 |
| 16 | + |
| 17 | + def __init__( |
| 18 | + self, uri="ip:analog.local", |
| 19 | + ): |
| 20 | + """Initialize.""" |
| 21 | + context_manager.__init__(self, uri, self._device_name) |
| 22 | + |
| 23 | + self._ctrl = self._ctx.find_device("ad7768-1") |
| 24 | + self._rxadc = self._ctx.find_device("ad7768-1") |
| 25 | + self._device_name = "ad7768-1" |
| 26 | + |
| 27 | + if not self._ctrl or not self._rxadc: |
| 28 | + raise Exception("Error in selecting matching device: ctrl or rxadc") |
| 29 | + |
| 30 | + self._rx_channel_names = [] |
| 31 | + for ch in self._rxadc.channels: |
| 32 | + name = ch._id |
| 33 | + self._rx_channel_names.append(name) |
| 34 | + |
| 35 | + rx.__init__(self) |
| 36 | + |
| 37 | + @property |
| 38 | + def sampling_frequency_available(self): |
| 39 | + """Get available sampling frequencies.""" |
| 40 | + return self._get_iio_dev_attr("sampling_frequency_available") |
| 41 | + |
| 42 | + @property |
| 43 | + def sampling_frequency(self): |
| 44 | + """Get sampling frequency.""" |
| 45 | + return self._get_iio_dev_attr("sampling_frequency") |
| 46 | + |
| 47 | + @sampling_frequency.setter |
| 48 | + def sampling_frequency(self, rate): |
| 49 | + """Set sampling frequency.""" |
| 50 | + if rate in self.sampling_frequency_available: |
| 51 | + self._set_iio_dev_attr("sampling_frequency", rate) |
| 52 | + else: |
| 53 | + raise ValueError( |
| 54 | + "Error: Sampling frequency not supported \nUse one of: " |
| 55 | + + str(self.sampling_frequency_available) |
| 56 | + ) |
| 57 | + |
| 58 | + @property |
| 59 | + def common_mode_voltage_available(self): |
| 60 | + """Get common mode voltage available.""" |
| 61 | + return self._get_iio_dev_attr_str("common_mode_voltage_available") |
| 62 | + |
| 63 | + @property |
| 64 | + def common_mode_voltage(self): |
| 65 | + """Get common mode voltage.""" |
| 66 | + return self._get_iio_dev_attr_str("common_mode_voltage") |
| 67 | + |
| 68 | + @common_mode_voltage.setter |
| 69 | + def common_mode_voltage(self, rate): |
| 70 | + """Set sampling frequency.""" |
| 71 | + if rate in self.common_mode_voltage_available: |
| 72 | + self._set_iio_dev_attr_str("common_mode_voltage", rate) |
| 73 | + else: |
| 74 | + raise ValueError( |
| 75 | + "Error: Common mode voltage not supported \nUse one of: " |
| 76 | + + str(self.common_mode_voltage_available) |
| 77 | + ) |
| 78 | + |
| 79 | + |
| 80 | +class adaq776x_1(ad7768_1): |
| 81 | + |
| 82 | + """ ADAQ776x-1 is a 24-bit single channel μModule Data Acquisition System """ |
| 83 | + |
| 84 | + _compatible_parts = ["adaq7767-1", "adaq7768-1", "adaq7769-1"] |
| 85 | + |
| 86 | + def __init__(self, uri="ip:analog.local"): |
| 87 | + super().__init__(uri) |
| 88 | + |
| 89 | + @property |
| 90 | + def sync_start_enable_available(self): |
| 91 | + """Get available sync start enable types.""" |
| 92 | + return self._get_iio_dev_attr_str("sync_start_enable_available") |
| 93 | + |
| 94 | + @property |
| 95 | + def sync_start_enable(self): |
| 96 | + """Get sync start enable.""" |
| 97 | + return self._get_iio_dev_attr_str("sync_start_enable") |
| 98 | + |
| 99 | + @sync_start_enable.setter |
| 100 | + def sync_start_enable(self, ftype): |
| 101 | + """Set sync start enable.""" |
| 102 | + if ftype in self.sync_start_enable_available: |
| 103 | + self._set_iio_dev_attr_str("sync_start_enable", ftype) |
| 104 | + else: |
| 105 | + raise ValueError( |
| 106 | + "Error: Sync start enable not supported \nUse one of: " |
| 107 | + + str(self.sync_start_enable_available) |
| 108 | + ) |
0 commit comments