diff --git a/src/spectrumdevice/devices/digitiser/digitiser_channel.py b/src/spectrumdevice/devices/digitiser/digitiser_channel.py index 71355d7..4304efc 100644 --- a/src/spectrumdevice/devices/digitiser/digitiser_channel.py +++ b/src/spectrumdevice/devices/digitiser/digitiser_channel.py @@ -13,7 +13,8 @@ ) from spectrumdevice.exceptions import SpectrumCardIsNotADigitiser from spectrumdevice.settings.card_dependent_properties import CardType -from spectrumdevice.settings.channel import VERTICAL_OFFSET_COMMANDS, VERTICAL_RANGE_COMMANDS +from spectrumdevice.settings.channel import INPUT_IMPEDANCE_COMMANDS, InputImpedance, VERTICAL_OFFSET_COMMANDS, \ + VERTICAL_RANGE_COMMANDS class SpectrumDigitiserChannel(AbstractSpectrumChannel, SpectrumDigitiserChannelInterface): @@ -79,3 +80,15 @@ def set_vertical_offset_in_percent(self, offset: int) -> None: """ self._parent_device.write_to_spectrum_device_register(VERTICAL_OFFSET_COMMANDS[self._number], offset) self._vertical_offset_in_percent = offset + + @property + def input_impedance(self) -> InputImpedance: + """The current input impedance setting of the channel (50 Ohm or 1 MOhm)""" + impedance_binary_value = self._parent_device.read_spectrum_device_register( + INPUT_IMPEDANCE_COMMANDS[self._number] + ) + return InputImpedance(impedance_binary_value) + + def set_input_impedance(self, input_impedance: InputImpedance) -> None: + self._parent_device.write_to_spectrum_device_register(INPUT_IMPEDANCE_COMMANDS[self._number], + input_impedance.value) diff --git a/src/spectrumdevice/devices/digitiser/digitiser_interface.py b/src/spectrumdevice/devices/digitiser/digitiser_interface.py index 0940427..71709f5 100644 --- a/src/spectrumdevice/devices/digitiser/digitiser_interface.py +++ b/src/spectrumdevice/devices/digitiser/digitiser_interface.py @@ -14,6 +14,7 @@ from spectrumdevice.devices.abstract_device import SpectrumChannelInterface, SpectrumDeviceInterface from spectrumdevice.settings import AcquisitionMode, AcquisitionSettings from spectrumdevice import Measurement +from spectrumdevice.settings.channel import InputImpedance class SpectrumDigitiserChannelInterface(SpectrumChannelInterface, ABC): @@ -42,6 +43,15 @@ def set_vertical_offset_in_percent(self, offset: int) -> None: def convert_raw_waveform_to_voltage_waveform(self, raw_waveform: ndarray) -> ndarray: raise NotImplementedError() + @property + @abstractmethod + def input_impedance(self) -> InputImpedance: + raise NotImplementedError() + + @abstractmethod + def set_input_impedance(self, input_impedance: InputImpedance) -> None: + raise NotImplementedError() + class SpectrumDigitiserInterface(SpectrumDeviceInterface, ABC): """Defines the public interface for control of all Spectrum digitiser devices, be they StarHub composite devices diff --git a/src/spectrumdevice/settings/__init__.py b/src/spectrumdevice/settings/__init__.py index 0ea3a68..ad36c3d 100644 --- a/src/spectrumdevice/settings/__init__.py +++ b/src/spectrumdevice/settings/__init__.py @@ -11,6 +11,7 @@ from spectrumdevice.settings.card_dependent_properties import ModelNumber from spectrumdevice.settings.card_features import CardFeature, AdvancedCardFeature +from spectrumdevice.settings.channel import InputImpedance from spectrumdevice.settings.device_modes import AcquisitionMode, ClockMode from spectrumdevice.settings.io_lines import IOLineMode, AvailableIOModes from spectrumdevice.settings.transfer_buffer import ( @@ -76,6 +77,8 @@ class AcquisitionSettings: """The voltage range to apply to each enabled channel in mW.""" vertical_offsets_in_percent: List[int] """The DC offset to apply to each enabled channel as percentages of their vertical ranges.""" + input_impedances: List[InputImpedance] + """The input impedance settings to apply to each channel""" timestamping_enabled: bool """If True, Measurements will include the time at which the acquisition was triggered. Increases latency by ~10 ms. """ diff --git a/src/spectrumdevice/settings/channel.py b/src/spectrumdevice/settings/channel.py index 3e546d4..a804191 100644 --- a/src/spectrumdevice/settings/channel.py +++ b/src/spectrumdevice/settings/channel.py @@ -13,6 +13,14 @@ SPCM_STOPLVL_HOLDLAST, SPCM_STOPLVL_LOW, SPCM_STOPLVL_ZERO, + SPC_50OHM0, SPC_50OHM1, SPC_50OHM10, SPC_50OHM11, SPC_50OHM12, SPC_50OHM13, SPC_50OHM14, SPC_50OHM15, SPC_50OHM2, + SPC_50OHM3, + SPC_50OHM4, + SPC_50OHM5, + SPC_50OHM6, + SPC_50OHM7, + SPC_50OHM8, + SPC_50OHM9, SPC_AMP0, SPC_AMP1, SPC_AMP2, @@ -219,3 +227,28 @@ class SpectrumChannelName(Enum): CHANNEL13 = CHANNEL13 CHANNEL14 = CHANNEL14 CHANNEL15 = CHANNEL15 + + +class InputImpedance(Enum): + FIFTY_OHM = 1 + ONE_MEGA_OHM = 0 + + +INPUT_IMPEDANCE_COMMANDS = ( + SPC_50OHM0, + SPC_50OHM1, + SPC_50OHM2, + SPC_50OHM3, + SPC_50OHM4, + SPC_50OHM5, + SPC_50OHM6, + SPC_50OHM7, + SPC_50OHM8, + SPC_50OHM9, + SPC_50OHM10, + SPC_50OHM11, + SPC_50OHM12, + SPC_50OHM13, + SPC_50OHM14, + SPC_50OHM15, +) \ No newline at end of file