Skip to content

Commit

Permalink
#34 - implementing input impedance setting
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbaker committed Oct 13, 2023
1 parent 61b2089 commit ebc55cd
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/spectrumdevice/devices/digitiser/digitiser_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
10 changes: 10 additions & 0 deletions src/spectrumdevice/devices/digitiser/digitiser_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/spectrumdevice/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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.
"""
Expand Down
33 changes: 33 additions & 0 deletions src/spectrumdevice/settings/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)

0 comments on commit ebc55cd

Please sign in to comment.