diff --git a/adi/__init__.py b/adi/__init__.py index 86f43b091..f521b1292 100644 --- a/adi/__init__.py +++ b/adi/__init__.py @@ -58,8 +58,17 @@ from adi.adg2128 import adg2128 from adi.adis16460 import adis16460 from adi.adis16475 import adis16475 -from adi.adis16480 import adis16480 -from adi.adis16495 import adis16495 +from adi.adis16480 import ( + adis16375, + adis16480, + adis16485, + adis16488, + adis16490, + adis16495, + adis16497, + adis16545, + adis16547, +) from adi.adis16507 import adis16507 from adi.adl5240 import adl5240 from adi.adl5960 import adl5960 diff --git a/adi/adis16480.py b/adi/adis16480.py index 70a89e937..f3e7b1c3a 100644 --- a/adi/adis16480.py +++ b/adi/adis16480.py @@ -2,15 +2,17 @@ # # SPDX short identifier: ADIBSD +from abc import ABC, abstractmethod + from adi.attribute import attribute from adi.context_manager import context_manager from adi.rx_tx import rx -class adis16480(rx, context_manager): - """ ADIS16480 Ten Degrees of Freedom Inertial Sensor with Dynamic Orientation Outputs """ +class adis16XXX(rx, context_manager, ABC): _complex_data = False + _rx_channel_names = [ "anglvel_x", "anglvel_y", @@ -18,41 +20,37 @@ class adis16480(rx, context_manager): "accel_x", "accel_y", "accel_z", - "magn_x", - "magn_y", - "magn_z", - "pressure0", "temp0", ] + _device_name = "" - def __init__(self, uri="", device_name="adis16480", trigger_name="adis16480-dev0"): + """Disable mapping of trigger to RX device.""" + disable_trigger = False + + # @property + @abstractmethod + def compatible_parts(self): + raise NotImplementedError + + def __init__(self, uri="", device_name=None, trigger_name=None): context_manager.__init__(self, uri, self._device_name) - compatible_parts = [ - "adis16375", - "adis16480", - "adis16485", - "adis16488", - "adis16490", - "adis16495-1", - "adis16495-2", - "adis16495-3", - "adis16497-1", - "adis16497-2", - "adis16497-3", - ] - - if device_name not in compatible_parts: + if not device_name: + device_name = self.compatible_parts[0] + + if device_name not in self.compatible_parts: raise Exception( "Not a compatible device:" + str(device_name) + ".Please select from:" - + str(compatible_parts) + + str(self.compatible_parts) ) else: self._ctrl = self._ctx.find_device(device_name) self._rxadc = self._ctx.find_device(device_name) + if not trigger_name: + trigger_name = device_name + "-dev0" if self._ctrl is None: print( @@ -60,7 +58,7 @@ def __init__(self, uri="", device_name="adis16480", trigger_name="adis16480-dev0 + device_name + ". Searching for a device found in the compatible list." ) - for i in compatible_parts: + for i in self.compatible_parts: self._ctrl = self._ctx.find_device(i) self._rxadc = self._ctx.find_device(i) if self._ctrl is not None: @@ -76,14 +74,17 @@ def __init__(self, uri="", device_name="adis16480", trigger_name="adis16480-dev0 self.accel_y = self._anglvel_accel_channels(self._ctrl, "accel_y") self.accel_z = self._anglvel_accel_channels(self._ctrl, "accel_z") self.temp = self._temp_channel(self._ctrl, "temp0") - self.pressure = self._pressure_channel(self._ctrl, "pressure0") - self.magn_x = self._magn_channel(self._ctrl, "magn_x") - self.magn_y = self._magn_channel(self._ctrl, "magn_y") - self.magn_z = self._magn_channel(self._ctrl, "magn_z") + self.deltaangl_x = self._delta_channels(self._ctrl, "deltaangl_x") + self.deltaangl_y = self._delta_channels(self._ctrl, "deltaangl_y") + self.deltaangl_z = self._delta_channels(self._ctrl, "deltaangl_z") + self.deltavelocity_x = self._delta_channels(self._ctrl, "deltavelocity_x") + self.deltavelocity_y = self._delta_channels(self._ctrl, "deltavelocity_y") + self.deltavelocity_z = self._delta_channels(self._ctrl, "deltavelocity_z") # Set default trigger - self._trigger = self._ctx.find_device(trigger_name) - self._rxadc._set_trigger(self._trigger) + if not self.disable_trigger: + self._trigger = self._ctx.find_device(trigger_name) + self._rxadc._set_trigger(self._trigger) rx.__init__(self) self.rx_buffer_size = 16 # Make default buffer smaller @@ -137,35 +138,47 @@ def get_accel_z(self): accel_z_conv = property(get_accel_z, None) - def get_magn_x(self): + def get_temp(self): + """Value returned in millidegrees Celsius.""" + return self.__get_scaled_sensor_temp("temp0") + + temp_conv = property(get_temp, None) + + def get_deltaangl_x(self): """Value returned in radians.""" - return self.__get_scaled_sensor("magn_x") + return self.__get_scaled_sensor("deltaangl_x") - magn_x_conv = property(get_magn_x, None) + deltaangl_x_conv = property(get_deltaangl_x, None) - def get_magn_y(self): + def get_deltaangl_y(self): """Value returned in radians.""" - return self.__get_scaled_sensor("magn_y") + return self.__get_scaled_sensor("deltaangl_y") - magn_y_conv = property(get_magn_y, None) + deltaangl_y_conv = property(get_deltaangl_y, None) - def get_magn_z(self): + def get_deltaangl_z(self): """Value returned in radians.""" - return self.__get_scaled_sensor("magn_z") + return self.__get_scaled_sensor("deltaangl_z") - magn_z_conv = property(get_magn_z, None) + deltaangl_z_conv = property(get_deltaangl_z, None) - def get_temp(self): - """Value returned in millidegrees Celsius.""" - return self.__get_scaled_sensor_temp("temp0") + def get_deltavelocity_x(self): + """Value returned in meters per second.""" + return self.__get_scaled_sensor("deltavelocity_x") - temp_conv = property(get_temp, None) + deltavelocity_x_conv = property(get_deltavelocity_x, None) - def get_pressure(self): - """Value returned in kilo Pascal.""" - return self.__get_scaled_sensor("pressure0") + def get_deltavelocity_y(self): + """Value returned in meters per second.""" + return self.__get_scaled_sensor("deltavelocity_y") - pressure_conv = property(get_pressure, None) + deltavelocity_y_conv = property(get_deltavelocity_y, None) + + def get_deltavelocity_z(self): + """Value returned in meters per second.""" + return self.__get_scaled_sensor("deltavelocity_z") + + deltavelocity_z_conv = property(get_deltavelocity_z, None) @property def sample_rate(self): @@ -239,42 +252,6 @@ def accel_z_calibbias(self): def accel_z_calibbias(self, value): self._set_iio_attr("accel_z", "calibbias", False, value) - @property - def magn_x_calibbias(self): - """User calibration offset for magnetometer for the x-axis.""" - return self._get_iio_attr("magn_x", "calibbias", False) - - @magn_x_calibbias.setter - def magn_x_calibbias(self, value): - self._set_iio_attr("magn_x", "calibbias", False, value) - - @property - def magn_y_calibbias(self): - """User calibration offset for magnetometer for the y-axis.""" - return self._get_iio_attr("magn_y", "calibbias", False) - - @magn_y_calibbias.setter - def magn_y_calibbias(self, value): - self._set_iio_attr("magn_y", "calibbias", False, value) - - @property - def magn_z_calibbias(self): - """User calibration offset for magnetometer for the z-axis.""" - return self._get_iio_attr("magn_z", "calibbias", False) - - @magn_z_calibbias.setter - def magn_z_calibbias(self, value): - self._set_iio_attr("magn_z", "calibbias", False, value) - - @property - def pressure_calibbias(self): - """User calibration offset for pressure.""" - return self._get_iio_attr("pressure0", "calibbias", False) - - @pressure_calibbias.setter - def pressure_calibbias(self, value): - self._set_iio_attr("pressure0", "calibbias", False, value) - ##### @property def anglvel_x_calibscale(self): @@ -384,33 +361,6 @@ def accel_z_filter_low_pass_3db_frequency(self): def accel_z_filter_low_pass_3db_frequency(self, value): self._set_iio_attr("accel_z", "filter_low_pass_3db_frequency", False, value) - @property - def magn_x_filter_low_pass_3db_frequency(self): - """Bandwidth for magnetometer for the x-axis.""" - return self._get_iio_attr("magn_x", "filter_low_pass_3db_frequency", False) - - @magn_x_filter_low_pass_3db_frequency.setter - def magn_x_filter_low_pass_3db_frequency(self, value): - self._set_iio_attr("magn_x", "filter_low_pass_3db_frequency", False, value) - - @property - def magn_y_filter_low_pass_3db_frequency(self): - """Bandwidth for magnetometer for the y-axis.""" - return self._get_iio_attr("magn_y", "filter_low_pass_3db_frequency", False) - - @magn_y_filter_low_pass_3db_frequency.setter - def magn_y_filter_low_pass_3db_frequency(self, value): - self._set_iio_attr("magn_y", "filter_low_pass_3db_frequency", False, value) - - @property - def magn_z_filter_low_pass_3db_frequency(self): - """Bandwidth for magnetometer for the z-axis.""" - return self._get_iio_attr("magn_z", "filter_low_pass_3db_frequency", False) - - @magn_z_filter_low_pass_3db_frequency.setter - def magn_z_filter_low_pass_3db_frequency(self, value): - self._set_iio_attr("magn_z", "filter_low_pass_3db_frequency", False, value) - @property def firmware_revision(self): """firmware_revision: the firmware revision for the internal firmware""" @@ -515,3 +465,270 @@ def calibscale(self): @calibscale.setter def calibscale(self, value): self._set_iio_attr(self.name, "calibscale", False, value) + + class _delta_channels(attribute): + """ADIS16480 delta angle and delta velocity channels.""" + + def __init__(self, ctrl, channel_name): + self.name = channel_name + self._ctrl = ctrl + + +class adis16XXX_with_delta_angl(adis16XXX): + def __init__(self, uri="", device_name=None, trigger_name=None): + adis16XXX.__init__(self, uri, device_name, trigger_name) + + self._rx_channel_names.append("deltaangl_x") + self._rx_channel_names.append("deltaangl_y") + self._rx_channel_names.append("deltaangl_z") + self._rx_channel_names.append("deltavelocity_x") + self._rx_channel_names.append("deltavelocity_y") + self._rx_channel_names.append("deltavelocity_z") + + +class adis16XXX_with_mag(adis16XXX): + def __init__(self, uri="", device_name=None, trigger_name=None): + adis16XXX.__init__(self, uri, device_name, trigger_name) + + self._rx_channel_names.append("pressure0") + self._rx_channel_names.append("magn_x") + self._rx_channel_names.append("magn_y") + self._rx_channel_names.append("magn_z") + self.pressure = self._pressure_channel(self._ctrl, "pressure0") + self.magn_x = self._magn_channel(self._ctrl, "magn_x") + self.magn_y = self._magn_channel(self._ctrl, "magn_y") + self.magn_z = self._magn_channel(self._ctrl, "magn_z") + + def get_magn_x(self): + """Value returned in radians.""" + return self.__get_scaled_sensor("magn_x") + + magn_x_conv = property(get_magn_x, None) + + def get_magn_y(self): + """Value returned in radians.""" + return self.__get_scaled_sensor("magn_y") + + magn_y_conv = property(get_magn_y, None) + + def get_magn_z(self): + """Value returned in radians.""" + return self.__get_scaled_sensor("magn_z") + + magn_z_conv = property(get_magn_z, None) + + def get_pressure(self): + """Value returned in kilo Pascal.""" + return self.__get_scaled_sensor("pressure0") + + pressure_conv = property(get_pressure, None) + + @property + def magn_x_calibbias(self): + """User calibration offset for magnetometer for the x-axis.""" + if self.magn_x: + return self._get_iio_attr("magn_x", "calibbias", False) + return 0 + + @magn_x_calibbias.setter + def magn_x_calibbias(self, value): + if self.magn_x: + self._set_iio_attr("magn_x", "calibbias", False, value) + + @property + def magn_y_calibbias(self): + """User calibration offset for magnetometer for the y-axis.""" + if self.magn_y: + return self._get_iio_attr("magn_y", "calibbias", False) + return 0 + + @magn_y_calibbias.setter + def magn_y_calibbias(self, value): + if self.magn_y: + self._set_iio_attr("magn_y", "calibbias", False, value) + + @property + def magn_z_calibbias(self): + """User calibration offset for magnetometer for the z-axis.""" + if self.magn_z: + return self._get_iio_attr("magn_z", "calibbias", False) + return 0 + + @magn_z_calibbias.setter + def magn_z_calibbias(self, value): + if self.magn_z: + self._set_iio_attr("magn_z", "calibbias", False, value) + + @property + def pressure_calibbias(self): + """User calibration offset for pressure.""" + if self.pressure: + return self._get_iio_attr("pressure0", "calibbias", False) + return 0 + + @pressure_calibbias.setter + def pressure_calibbias(self, value): + if self.pressure: + self._set_iio_attr("pressure0", "calibbias", False, value) + + @property + def magn_x_filter_low_pass_3db_frequency(self): + """Bandwidth for magnetometer for the x-axis.""" + if self.magn_x: + return self._get_iio_attr("magn_x", "filter_low_pass_3db_frequency", False) + return 0 + + @magn_x_filter_low_pass_3db_frequency.setter + def magn_x_filter_low_pass_3db_frequency(self, value): + if self.magn_x: + self._set_iio_attr("magn_x", "filter_low_pass_3db_frequency", False, value) + + @property + def magn_y_filter_low_pass_3db_frequency(self): + """Bandwidth for magnetometer for the y-axis.""" + if self.magn_y: + return self._get_iio_attr("magn_y", "filter_low_pass_3db_frequency", False) + return 0 + + @magn_y_filter_low_pass_3db_frequency.setter + def magn_y_filter_low_pass_3db_frequency(self, value): + if self.magn_y: + self._set_iio_attr("magn_y", "filter_low_pass_3db_frequency", False, value) + + @property + def magn_z_filter_low_pass_3db_frequency(self): + """Bandwidth for magnetometer for the z-axis.""" + if self.magn_z: + return self._get_iio_attr("magn_z", "filter_low_pass_3db_frequency", False) + return 0 + + @magn_z_filter_low_pass_3db_frequency.setter + def magn_z_filter_low_pass_3db_frequency(self, value): + if self.magn_z: + self._set_iio_attr("magn_z", "filter_low_pass_3db_frequency", False, value) + + +11 + + +class adis16375(adis16XXX): + """ADIS16375 Low Profile, Low Noise Six Degrees of Freedom Inertial Sensor + + Args: + uri: URI of IIO context with ADIS16375 device + device_name: Name of the device in the IIO context. Default is adis16375 + trigger_name: Name of the trigger in the IIO context. Default is adis16375-dev0 + """ + + compatible_parts = ["adis16375"] + + +class adis16480(adis16XXX_with_mag): + """ADIS16480 Ten Degrees of Freedom Inertial Sensor with Dynamic Orientation Outputs + + Args: + uri: URI of IIO context with ADIS16480 device + device_name: Name of the device in the IIO context. Default is adis16480 + trigger_name: Name of the trigger in the IIO context. Default is adis16480-dev0 + """ + + compatible_parts = ["adis16480"] + + +class adis16485(adis16XXX): + """ADIS16485 Tactical Grade Six Degrees of Freedom MEMS Inertial Sensor + + Args: + uri: URI of IIO context with ADIS16485 device + device_name: Name of the device in the IIO context. Default is adis16485 + trigger_name: Name of the trigger in the IIO context. Default is adis16485-dev0 + """ + + compatible_parts = ["adis16485"] + + +class adis16488(adis16XXX_with_mag): + """ADIS16488 Tactical Grade Ten Degrees of Freedom Inertial Sensor + + Args: + uri: URI of IIO context with ADIS16488 device + device_name: Name of the device in the IIO context. Default is adis16488 + trigger_name: Name of the trigger in the IIO context. Default is adis16488-dev0 + """ + + compatible_parts = ["adis16488"] + + +class adis16490(adis16XXX): + """ADIS16490 Tactical Grade, Six Degrees of Freedom Inertial Sensor + + Args: + uri: URI of IIO context with ADIS16490 device + device_name: Name of the device in the IIO context. Default is adis16490 + trigger_name: Name of the trigger in the IIO context. Default is adis16490-dev0 + """ + + compatible_parts = ["adis16490"] + + +class adis16495(adis16XXX): + """ADIS16495-X Tactical Grade, Six Degrees of Freedom Inertial Sensor + + This class is compatible with the following parts: + - adis16495-1 + - adis16495-2 + - adis16495-3 + + Args: + uri: URI of IIO context with ADIS16495 device + device_name: Name of the device in the IIO context. Default is adis16495-1 + trigger_name: Name of the trigger in the IIO context. Default is adis16495-1-dev0 + """ + + compatible_parts = ["adis16495-1", "adis16495-2", "adis16495-3"] + + +class adis16497(adis16XXX): + """ADIS16497-X Ten Degrees of Freedom Inertial Sensor with Dynamic Orientation Outputs + + This class is compatible with the following parts: + - adis16497-1 + - adis16497-2 + - adis16497-3 + """ + + compatible_parts = ["adis16497-1", "adis16497-2", "adis16497-3"] + + +class adis16545(adis16XXX_with_delta_angl): + """ADIS16545-X Tactical Grade, Six Degrees of Freedom Inertial Sensor + + This class is compatible with the following parts: + - adis16545-1 + - adis16545-2 + - adis16545-3 + + Args: + uri: URI of IIO context with ADIS16545 device + device_name: Name of the device in the IIO context. Default is adis16545-1 + trigger_name: Name of the trigger in the IIO context. Default is adis16545-1-dev0 + """ + + compatible_parts = ["adis16545-1", "adis16545-2", "adis16545-3"] + + +class adis16547(adis16XXX_with_delta_angl): + """ADIS16547-X Tactical Grade, Six Degrees of Freedom Inertial Sensors + + This class is compatible with the following parts: + - adis16547-1 + - adis16547-2 + - adis16547-3 + + Args: + uri: URI of IIO context with ADIS16547 device + device_name: Name of the device in the IIO context. Default is adis16547-1 + trigger_name: Name of the trigger in the IIO context. Default is adis16547-1-dev0 + """ + + compatible_parts = ["adis16547-1", "adis16547-2", "adis16547-3"] diff --git a/adi/adis16495.py b/adi/adis16495.py deleted file mode 100644 index 2debf2bbb..000000000 --- a/adi/adis16495.py +++ /dev/null @@ -1,284 +0,0 @@ -# Copyright (C) 2020-2024 Analog Devices, Inc. -# -# SPDX short identifier: ADIBSD - -import numpy as np -from adi.context_manager import context_manager -from adi.rx_tx import rx - - -class adis16495(rx, context_manager): - """ADIS16495 Precision, Miniature MEMS IMU.""" - - _complex_data = False - _rx_channel_names = [ - "anglvel_x", - "anglvel_y", - "anglvel_z", - "accel_x", - "accel_y", - "accel_z", - ] - _device_name = "" - _rx_data_si_type = float - - def __init__(self, uri="", name="adis16495-3"): - """Initialize an adis16495 object. - - parameters: - uri: type=string - URI of IIO context with adis16495. - name: type=string - Name of the device. Set to adis16495-3 - by default. - """ - trigger_name = name + "-dev0" - context_manager.__init__(self, uri, self._device_name) - - self._ctrl = self._ctx.find_device(name) - self._rxadc = self._ctx.find_device(name) - # Set default trigger - self._trigger = self._ctx.find_device(trigger_name) - self._rxadc._set_trigger(self._trigger) - rx.__init__(self) - self.rx_buffer_size = 16 # Make default buffer smaller - - # device attributes - @property - def sample_rate(self): - """Sample_rate: Sample rate in samples per second.""" - return self._get_iio_dev_attr("sampling_frequency") - - @sample_rate.setter - def sample_rate(self, value): - self._set_iio_dev_attr_str("sampling_frequency", value) - - @property - def current_timestamp_clock(self): - """Current_timestamp_clock: Source clock for timestamps.""" - return self._get_iio_dev_attr("current_timestamp_clock") - - @current_timestamp_clock.setter - def current_timestamp_clock(self, value): - self._set_iio_dev_attr_str("current_timestamp_clock", value) - - # channel attributes - def get_temp(self): - """Value returned in millidegrees celsius.""" - raw = self._get_iio_attr("temp0", "raw", False) - off = self._get_iio_attr("temp0", "offset", False) - scale = self._get_iio_attr("temp0", "scale", False) - - return (raw + off) * scale - - temperature = property(get_temp, None) - - def __get_scaled_sensor(self, channel_name: str) -> float: - raw = self._get_iio_attr(channel_name, "raw", False) - scale = self._get_iio_attr(channel_name, "scale", False) - - return raw * scale - - # get anglvel_x related attributes - def get_anglvel_x(self): - """Value returned in radians per second.""" - return self.__get_scaled_sensor("anglvel_x") - - anglvel_x = property(get_anglvel_x, None) - - @property - def anglvel_x_filter_low_pass_3db_frequency(self): - return self._get_iio_attr("anglvel_x", "filter_low_pass_3db_frequency", False) - - @anglvel_x_filter_low_pass_3db_frequency.setter - def anglvel_x_filter_low_pass_3db_frequency(self, value): - """Value returned in HZ.""" - self._set_iio_attr("anglvel_x", "filter_low_pass_3db_frequency", False, value) - - @property - def anglvel_x_calibbias(self): - """User bias adjustment for the x-axis.""" - return self._get_iio_attr("anglvel_x", "calibbias", False) - - @anglvel_x_calibbias.setter - def anglvel_x_calibbias(self, value): - self._set_iio_attr("anglvel_x", "calibbias", False, value) - - @property - def anglvel_x_calibscale(self): - """User scale adjustment for the x-axis.""" - return self._get_iio_attr("anglvel_x", "calibscale", False) - - @anglvel_x_calibscale.setter - def anglvel_x_calibscale(self, value): - self._set_iio_attr("anglvel_x", "calibscale", False, value) - - # get anglvel_y related attributes - def get_anglvel_y(self): - """Value returned in radians per second.""" - return self.__get_scaled_sensor("anglvel_y") - - anglvel_y = property(get_anglvel_y, None) - - @property - def anglvel_y_filter_low_pass_3db_frequency(self): - """Value returned in HZ.""" - return self._get_iio_attr("anglvel_y", "filter_low_pass_3db_frequency", False) - - @anglvel_y_filter_low_pass_3db_frequency.setter - def anglvel_y_filter_low_pass_3db_frequency(self, value): - self._set_iio_attr("anglvel_y", "filter_low_pass_3db_frequency", False, value) - - @property - def anglvel_y_calibbias(self): - """User bias adjustment for the y-axis.""" - return self._get_iio_attr("anglvel_y", "calibbias", False) - - @anglvel_y_calibbias.setter - def anglvel_y_calibbias(self, value): - self._set_iio_attr("anglvel_y", "calibbias", False, value) - - @property - def anglvel_y_calibscale(self): - """User scale adjustment for the y-axis.""" - return self._get_iio_attr("anglvel_y", "calibscale", False) - - @anglvel_y_calibscale.setter - def anglvel_y_calibscale(self, value): - self._set_iio_attr("anglvel_y", "calibscale", False, value) - - # get anglvel_z related attributes - def get_anglvel_z(self): - """Value returned in radians per second.""" - return self.__get_scaled_sensor("anglvel_z") - - anglvel_z = property(get_anglvel_z, None) - - @property - def anglvel_z_filter_low_pass_3db_frequency(self): - """Value returned in HZ.""" - return self._get_iio_attr("anglvel_z", "filter_low_pass_3db_frequency", False) - - @anglvel_z_filter_low_pass_3db_frequency.setter - def anglvel_z_filter_low_pass_3db_frequency(self, value): - self._set_iio_attr("anglvel_z", "filter_low_pass_3db_frequency", False, value) - - @property - def anglvel_z_calibbias(self): - """User bias adjustment for the z-axis.""" - return self._get_iio_attr("anglvel_z", "calibbias", False) - - @anglvel_z_calibbias.setter - def anglvel_z_calibbias(self, value): - self._set_iio_attr("anglvel_z", "calibbias", False, value) - - @property - def anglvel_z_calibscale(self): - """User scale adjustment for the z-axis.""" - return self._get_iio_attr("anglvel_z", "calibscale", False) - - @anglvel_z_calibscale.setter - def anglvel_z_calibscale(self, value): - self._set_iio_attr("anglvel_z", "calibscale", False, value) - - # get accel_x related attributes - def get_accel_x(self): - """Value returned in m/s^2.""" - return self.__get_scaled_sensor("accel_x") - - accel_x = property(get_accel_x, None) - - @property - def accel_x_filter_low_pass_3db_frequency(self): - """Value returned in HZ.""" - return self._get_iio_attr("accel_x", "filter_low_pass_3db_frequency", False) - - @accel_x_filter_low_pass_3db_frequency.setter - def accel_x_filter_low_pass_3db_frequency(self, value): - self._set_iio_attr("accel_x", "filter_low_pass_3db_frequency", False, value) - - @property - def accel_x_calibbias(self): - """User bias adjustment for the x-axis.""" - return self._get_iio_attr("accel_x", "calibbias", False) - - @accel_x_calibbias.setter - def accel_x_calibbias(self, value): - self._set_iio_attr("accel_x", "calibbias", False, value) - - @property - def accel_x_calibscale(self): - """User scale adjustment for the x-axis.""" - return self._get_iio_attr("accel_x", "calibscale", False) - - @accel_x_calibscale.setter - def accel_x_calibscale(self, value): - self._set_iio_attr("accel_x", "calibscale", False, value) - - # get accel_y related attributes - def get_accel_y(self): - """Value returned in m/s^2.""" - return self.__get_scaled_sensor("accel_y") - - accel_y = property(get_accel_y, None) - - @property - def accel_y_filter_low_pass_3db_frequency(self): - """Value returned in HZ.""" - return self._get_iio_attr("accel_y", "filter_low_pass_3db_frequency", False) - - @accel_y_filter_low_pass_3db_frequency.setter - def accel_y_filter_low_pass_3db_frequency(self, value): - self._set_iio_attr("accel_y", "filter_low_pass_3db_frequency", False, value) - - @property - def accel_y_calibbias(self): - """User bias adjustment for the y-axis.""" - return self._get_iio_attr("accel_y", "calibbias", False) - - @accel_y_calibbias.setter - def accel_y_calibbias(self, value): - self._set_iio_attr("accel_y", "calibbias", False, value) - - @property - def accel_y_calibscale(self): - """User scale adjustment for the y-axis.""" - return self._get_iio_attr("accel_y", "calibscale", False) - - @accel_y_calibscale.setter - def accel_y_calibscale(self, value): - self._set_iio_attr("accel_y", "calibscale", False, value) - - # get accel_y related attributes - def get_accel_z(self): - """Value returned in m/s^2.""" - return self.__get_scaled_sensor("accel_z") - - accel_z = property(get_accel_z, None) - - @property - def accel_z_filter_low_pass_3db_frequency(self): - """Value returned in HZ.""" - return self._get_iio_attr("accel_z", "filter_low_pass_3db_frequency", False) - - @accel_z_filter_low_pass_3db_frequency.setter - def accel_z_filter_low_pass_3db_frequency(self, value): - self._set_iio_attr("accel_z", "filter_low_pass_3db_frequency", False, value) - - @property - def accel_z_calibbias(self): - """User bias adjustment for the z-axis.""" - return self._get_iio_attr("accel_z", "calibbias", False) - - @accel_z_calibbias.setter - def accel_z_calibbias(self, value): - self._set_iio_attr("accel_z", "calibbias", False, value) - - @property - def accel_z_calibscale(self): - return self._get_iio_attr("accel_z", "calibscale", False) - - @accel_z_calibscale.setter - def accel_z_calibscale(self, value): - """User scale adjustment for the z-axis.""" - self._set_iio_attr("accel_z", "calibscale", False, value) diff --git a/doc/source/devices/adi.adis16375.rst b/doc/source/devices/adi.adis16375.rst new file mode 100644 index 000000000..0018260f3 --- /dev/null +++ b/doc/source/devices/adi.adis16375.rst @@ -0,0 +1,9 @@ + +adis16375 +========= + +.. autoclass:: adi.adis16375 + :members: + :undoc-members: + :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16460.rst b/doc/source/devices/adi.adis16460.rst index 9797e4597..b6e2d0e90 100644 --- a/doc/source/devices/adi.adis16460.rst +++ b/doc/source/devices/adi.adis16460.rst @@ -1,7 +1,8 @@ adis16460 ==================== -.. automodule:: adi.adis16460 +.. autoclass:: adi.adis16460 :members: :undoc-members: :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16475.rst b/doc/source/devices/adi.adis16475.rst index bb08ee017..43ae5f56f 100644 --- a/doc/source/devices/adi.adis16475.rst +++ b/doc/source/devices/adi.adis16475.rst @@ -1,7 +1,8 @@ adis16475 ==================== -.. automodule:: adi.adis16475 +.. autoclass:: adi.adis16475 :members: :undoc-members: :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16480.rst b/doc/source/devices/adi.adis16480.rst index af13ad5c1..f827ff0e8 100644 --- a/doc/source/devices/adi.adis16480.rst +++ b/doc/source/devices/adi.adis16480.rst @@ -1,7 +1,8 @@ adis16480 ==================== -.. automodule:: adi.adis16480 +.. autoclass:: adi.adis16480 :members: :undoc-members: :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16485.rst b/doc/source/devices/adi.adis16485.rst new file mode 100644 index 000000000..71dae6e70 --- /dev/null +++ b/doc/source/devices/adi.adis16485.rst @@ -0,0 +1,9 @@ + +adis16485 +========= + +.. autoclass:: adi.adis16485 + :members: + :undoc-members: + :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16488.rst b/doc/source/devices/adi.adis16488.rst new file mode 100644 index 000000000..cd5c3b903 --- /dev/null +++ b/doc/source/devices/adi.adis16488.rst @@ -0,0 +1,9 @@ + +adis16488 +========= + +.. autoclass:: adi.adis16488 + :members: + :undoc-members: + :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16490.rst b/doc/source/devices/adi.adis16490.rst new file mode 100644 index 000000000..c98f08252 --- /dev/null +++ b/doc/source/devices/adi.adis16490.rst @@ -0,0 +1,9 @@ + +adis16490 +========= + +.. autoclass:: adi.adis16490 + :members: + :undoc-members: + :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16495.rst b/doc/source/devices/adi.adis16495.rst index d8d79e382..1b8eb3856 100644 --- a/doc/source/devices/adi.adis16495.rst +++ b/doc/source/devices/adi.adis16495.rst @@ -1,7 +1,9 @@ + adis16495 -==================== +========= -.. automodule:: adi.adis16495 +.. autoclass:: adi.adis16495 :members: :undoc-members: :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16497.rst b/doc/source/devices/adi.adis16497.rst new file mode 100644 index 000000000..fa04d876d --- /dev/null +++ b/doc/source/devices/adi.adis16497.rst @@ -0,0 +1,9 @@ + +adis16497 +========= + +.. autoclass:: adi.adis16497 + :members: + :undoc-members: + :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16545.rst b/doc/source/devices/adi.adis16545.rst new file mode 100644 index 000000000..c50d7c300 --- /dev/null +++ b/doc/source/devices/adi.adis16545.rst @@ -0,0 +1,9 @@ + +adis16545 +========= + +.. autoclass:: adi.adis16545 + :members: + :undoc-members: + :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/adi.adis16547.rst b/doc/source/devices/adi.adis16547.rst new file mode 100644 index 000000000..82c17d4af --- /dev/null +++ b/doc/source/devices/adi.adis16547.rst @@ -0,0 +1,9 @@ + +adis16547 +========= + +.. autoclass:: adi.adis16547 + :members: + :undoc-members: + :show-inheritance: + :inherited-members: diff --git a/doc/source/devices/index.rst b/doc/source/devices/index.rst index 2b41e444f..0401722cf 100644 --- a/doc/source/devices/index.rst +++ b/doc/source/devices/index.rst @@ -64,11 +64,18 @@ Supported Devices adi.adf4371 adi.adf5610 adi.adg2128 + adi.adis16375 adi.adis16460 adi.adis16475 adi.adis16480 + adi.adis16485 + adi.adis16488 + adi.adis16490 adi.adis16495 + adi.adis16497 adi.adis16507 + adi.adis16545 + adi.adis16547 adi.adl5240 adi.adl5960 adi.admv8818 diff --git a/doc/update_devs.py b/doc/update_devs.py index 0176e4499..0e9e8df81 100644 --- a/doc/update_devs.py +++ b/doc/update_devs.py @@ -15,7 +15,23 @@ def update_devs(): devices_all = devices + [mfile] if os.path.exists(mfile) else devices # Remove device docs before updating + + # Autodoc won't generate these pages + classes_not_modules = [ + "adi.adis16375.rst", + "adi.adis16480.rst", + "adi.adis16485.rst", + "adi.adis16488.rst", + "adi.adis16490.rst", + "adi.adis16495.rst", + "adi.adis16497.rst", + "adi.adis16545.rst", + "adi.adis16547.rst", + ] + for dev in devices_all: + if os.path.basename(dev) in classes_not_modules: + continue print("Removing {}".format(dev)) os.remove(dev) @@ -27,6 +43,8 @@ def update_devs(): # Remove adi. and modules strings for dev in devices: + if os.path.basename(dev) in classes_not_modules: + continue with open(dev, "r") as f: txt = f.read() txt = txt.replace("adi.", "") diff --git a/examples/adis16480_example.py b/examples/adis16480_example.py index 8f06a55cb..86e285319 100644 --- a/examples/adis16480_example.py +++ b/examples/adis16480_example.py @@ -1,15 +1,19 @@ # Copyright (C) 2021 Analog Devices, Inc. # # SPDX short identifier: ADIBSD +import sys import adi import matplotlib.pyplot as plt # Set up ADIS16480 -dev = adi.adis16480(uri="ip:localhost", device_name="adis16480") +my_dev_name = sys.argv[1] +my_uri = sys.argv[2] + +dev = adi.adis16480(device_name=my_dev_name, uri=my_uri) dev.rx_output_type = "raw" -dev.rx_enabled_channels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +dev.rx_enabled_channels = [0, 1, 2, 3, 4, 5] dev.sample_rate = 10 dev.rx_buffer_size = 10 @@ -26,12 +30,20 @@ print("Y angular velocity: " + str(dev.anglvel_y_conv) + " rad/s") print("Z angular velocity: " + str(dev.anglvel_z_conv) + " rad/s") +print("\nX delta velocity: " + str(dev.deltavelocity_x_conv) + " m/s") +print("Y delta velocity: " + str(dev.deltavelocity_y_conv) + " m/s") +print("Z delta velocity: " + str(dev.deltavelocity_z_conv) + " m/s") + +print("\nX delta angle: " + str(dev.deltaangl_x_conv) + " rad") +print("Y delta angle: " + str(dev.deltaangl_y_conv) + " rad") +print("Z delta angle: " + str(dev.deltaangl_z_conv) + " rad") + dev.sample_rate = 2000 dev.magn_x_filter_low_pass_3db_frequency = 100 dev.anglvel_y_calibscale = 30 dev.anglvel_x_calibbias = 100 -print("Sampling frequency: " + str(dev.sample_rate)) +print("\nSampling frequency: " + str(dev.sample_rate)) print("Temperature raw value: " + str(dev.temp.raw)) print("Temperature scale value: " + str(dev.temp.scale)) @@ -45,7 +57,7 @@ data = dev.rx() plt.clf() for i, d in enumerate(data): - plt.plot(d, label=dev._rx_channel_names[i]) + plt.plot(d, label=dev._rx_channel_names[dev.rx_enabled_channels[i]]) plt.legend() plt.show(block=False) plt.pause(0.1) diff --git a/supported_parts.md b/supported_parts.md index 060665fd1..e20cb0d5e 100644 --- a/supported_parts.md +++ b/supported_parts.md @@ -139,6 +139,8 @@ - ADIS16497-2 - ADIS16497-3 - ADIS16507 +- ADIS16545 +- ADIS16547 - ADL5240 - ADL5960 - ADMV8818 diff --git a/tasks.py b/tasks.py index 1c726842c..fe5f1cf87 100644 --- a/tasks.py +++ b/tasks.py @@ -260,10 +260,17 @@ def checkemulation(c): "adf4371", "adf5610", "adg2128", + "adis16375", "adis16460", "adis16475", + "adis16485", + "adis16488", + "adis16490", "adis16495", + "adis16497", "adis16507", + "adis16545", + "adis16547", "adl5240", "adl5960", "admv8818", diff --git a/test/test_adis16480.py b/test/test_adis16480.py index 3e4dca0cb..4049d40d8 100644 --- a/test/test_adis16480.py +++ b/test/test_adis16480.py @@ -108,3 +108,30 @@ def test_adis16480_serial_number(iio_uri): adis16480 = adi.adis16480(uri=iio_uri) assert adis16480.serial_number != "0x0000" + + +@pytest.mark.iio_hardware(hardware) +@pytest.mark.parametrize( + "classname", + [ + "adi.adis16375", + "adi.adis16480", + "adi.adis16485", + "adi.adis16488", + "adi.adis16490", + "adi.adis16495", + "adi.adis16497", + "adi.adis16545", + "adi.adis16547", + ], +) +def test_adis16XXX_create(iio_uri, classname): + # This test is a little hack to just enumerate all the classes even though + # we don't have the exact hardware + emulation_hw = "adis16480" + imu = eval(classname) + imu.compatible_parts = [emulation_hw] + imu.disable_trigger = True + + # Try to create the object + imu = imu(uri=iio_uri)