Skip to content

Commit

Permalink
#34 - implemented channel input path settings
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbaker committed Oct 13, 2023
1 parent aed68da commit 8142231
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def configure_acquisition(self, settings: AcquisitionSettings) -> None:
for channel, coupling in zip(self.channels, settings.input_couplings):
cast(SpectrumDigitiserChannel, channel).set_input_coupling(coupling)

# Only some hardware has software programmable input paths, so it can be None
if settings.input_paths is not None:
for channel, path in zip(self.channels, settings.input_paths):
cast(SpectrumDigitiserChannel, channel).set_input_path(path)

# Write the configuration to the card
self.write_to_spectrum_device_register(SPC_M2CMD, M2CMD_CARD_WRITESETUP)

Expand Down
13 changes: 12 additions & 1 deletion src/spectrumdevice/devices/digitiser/digitiser_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
VERTICAL_RANGE_COMMANDS,
InputCoupling,
INPUT_COUPLING_COMMANDS,
InputPath,
INPUT_PATH_COMMANDS,
)


Expand Down Expand Up @@ -102,11 +104,20 @@ def set_input_impedance(self, input_impedance: InputImpedance) -> None:

@property
def input_coupling(self) -> InputCoupling:
"""The current input impedance setting of the channel (50 Ohm or 1 MOhm)"""
"""The coupling (AC or DC) setting of the channel. Only available on some hardware."""
coupling_binary_value = self._parent_device.read_spectrum_device_register(INPUT_COUPLING_COMMANDS[self._number])
return InputCoupling(coupling_binary_value)

def set_input_coupling(self, input_coupling: InputCoupling) -> None:
self._parent_device.write_to_spectrum_device_register(
INPUT_COUPLING_COMMANDS[self._number], input_coupling.value
)

@property
def input_path(self) -> InputPath:
"""The input path setting of the channel. Only available on some hardware."""
path_binary_value = self._parent_device.read_spectrum_device_register(INPUT_PATH_COMMANDS[self._number])
return InputPath(path_binary_value)

def set_input_path(self, input_path: InputPath) -> None:
self._parent_device.write_to_spectrum_device_register(INPUT_PATH_COMMANDS[self._number], input_path.value)
11 changes: 10 additions & 1 deletion src/spectrumdevice/devices/digitiser/digitiser_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +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, InputCoupling
from spectrumdevice.settings.channel import InputImpedance, InputCoupling, InputPath


class SpectrumDigitiserChannelInterface(SpectrumChannelInterface, ABC):
Expand Down Expand Up @@ -61,6 +61,15 @@ def input_coupling(self) -> InputCoupling:
def set_input_coupling(self, input_coupling: InputCoupling) -> None:
raise NotImplementedError()

@property
@abstractmethod
def input_path(self) -> InputPath:
raise NotImplementedError()

@abstractmethod
def set_input_path(self, input_path: InputPath) -> 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
4 changes: 3 additions & 1 deletion src/spectrumdevice/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from spectrumdevice.settings.card_dependent_properties import ModelNumber
from spectrumdevice.settings.card_features import CardFeature, AdvancedCardFeature
from spectrumdevice.settings.channel import InputImpedance, InputCoupling
from spectrumdevice.settings.channel import InputImpedance, InputCoupling, InputPath
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 @@ -89,6 +89,8 @@ class AcquisitionSettings:
"""If an averaging AcquisitionMode is selected, this defines the number of averages."""
input_couplings: Optional[List[InputCoupling]] = None
"""The coupling (AC or DC) to apply to each channel. Only available on some hardware, so default is None."""
input_paths: Optional[List[InputPath]] = None
"""The input path (HF or Buffered) to apply to each channel. Only available on some hardware, so default is None."""


class SpectrumRegisterLength(Enum):
Expand Down
41 changes: 41 additions & 0 deletions src/spectrumdevice/settings/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@
SPC_ACDC13,
SPC_ACDC14,
SPC_ACDC15,
SPC_PATH0,
SPC_PATH1,
SPC_PATH2,
SPC_PATH3,
SPC_PATH4,
SPC_PATH5,
SPC_PATH6,
SPC_PATH7,
SPC_PATH8,
SPC_PATH9,
SPC_PATH10,
SPC_PATH11,
SPC_PATH12,
SPC_PATH13,
SPC_PATH14,
SPC_PATH15,
)

VERTICAL_RANGE_COMMANDS = (
Expand Down Expand Up @@ -301,3 +317,28 @@ class InputCoupling(Enum):
SPC_ACDC14,
SPC_ACDC15,
)


class InputPath(Enum):
BUFFERED_INPUTS = 0
HF_INPUT_WITH_FIXED_50_OHM_TERMINATION = 1


INPUT_PATH_COMMANDS = (
SPC_PATH0,
SPC_PATH1,
SPC_PATH2,
SPC_PATH3,
SPC_PATH4,
SPC_PATH5,
SPC_PATH6,
SPC_PATH7,
SPC_PATH8,
SPC_PATH9,
SPC_PATH10,
SPC_PATH11,
SPC_PATH12,
SPC_PATH13,
SPC_PATH14,
SPC_PATH15,
)
4 changes: 2 additions & 2 deletions src/tests/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class SpectrumTestMode(Enum):

# Set to TestMode.MOCK_HARDWARE for software-only testing, even if Spectrum drivers are found on the system
# Set to TestMode.REAL_HARDWARE to run tests on a real hardware device as configured below.
SINGLE_CARD_TEST_MODE = SpectrumTestMode.REAL_HARDWARE
STAR_HUB_TEST_MODE = SpectrumTestMode.REAL_HARDWARE
SINGLE_CARD_TEST_MODE = SpectrumTestMode.MOCK_HARDWARE
STAR_HUB_TEST_MODE = SpectrumTestMode.MOCK_HARDWARE

# Set IP address of real spectrum device (for use if TestMode.REAL_HARDWARE is set above). Set to None to run tests on
# a local (PCIe) card.
Expand Down

0 comments on commit 8142231

Please sign in to comment.