Spectrum-Instrumentation Control#

See also

User guide on the spectrum devices.

Transmit and Receive Devices#

Device interface class.

class console.spcm_control.abstract_device.SpectrumDevice(path: str, log: Logger)[source]#

Bases: ABC

Spectrum device abstract base class.

card: c_char_p | None#
card_type: console.spcm_control.spcm.pyspcm.int32#
connect() bool[source]#

Establish card connection.

Raises:
  • ConnectionError – Connection to card already exists

  • ConnectionError – Connection could not be established

dict() dict[source]#

Abstract method which returns variables for logging in dictionary.

disconnect() None[source]#

Disconnect card.

get_status() int[source]#

Get and log current card status.

The status is represented by a list. Each entry represents a possible card status in form of a (sub-)list. It contains the status code, name and (optional) description of the spectrum instrumentation manual.

Return type:

String with status description.

handle_error(error: int) None[source]#

General error handling function.

log: Logger#
name: str | None#
path: str#
abstract setup_card() None[source]#

Abstract method to setup the card.

abstract start_operation() None[source]#

Abstract method to start card operation.

Parameters:
  • data – Replay data in correct spcm format as numpy array, by default None

  • optional – Replay data in correct spcm format as numpy array, by default None

abstract stop_operation() None[source]#

Abstract method to stop card operation.

Implementation of receive card.

class console.spcm_control.rx_device.RxCard(path: str, sample_rate: int, channel_enable: list[int], max_amplitude: list[int], impedance_50_ohms: list[int])[source]#

Bases: SpectrumDevice

Implementation of RX device.

setup_card()[source]#

Set up spectrum card in transmit (Rx) mode.

At the very beginning, a card reset is performed. The clock mode is set according to the sample rate, defined by the class attribute. Two receive channels are enables and configured by max. amplitude according to class variables and impedance.

Raises:

Warning – The actual set sample rate deviates from the corresponding class attribute to be set, class attribute is overwritten.

start_operation()[source]#

Start card operation.

stop_operation()[source]#

Stop card thread.

Implementation of transmit card.

class console.spcm_control.tx_device.TxCard(path: str, max_amplitude: list[int], filter_type: list[int], sample_rate: int, notify_rate: int = 16)[source]#

Bases: SpectrumDevice

Implementation of TX device.

Implements abstract base class SpectrumDevice, which requires the abstract methods get_status(), setup_card() and operate(). The TxCard is automatically instantiated by a yaml-loader when loading the configuration file.

The implementation was done and tested with card M2p6546-x4, which has an onboard memory size of 512 MSample, 2 Bytes/sample => 1024 MB.

Overview:#

The TX card operates with a ring buffer on the spectrum card, defined by ring_buffer_size. The ring buffer is filled in fractions of notify_size.

set_gradient_offsets(offsets: Dimensions, high_impedance: list[bool] = [True, True, True]) None[source]#

Set offset values of the gradient output channels.

Parameters:

offsets – Offset values as Dimension datatype as defined in acquisition parameter

Return type:

List of integer values read from card for x, y and z offset values

setup_card() None[source]#

Set up spectrum card in transmit (TX) mode.

At the very beginning, a card reset is performed. The clock mode is set according to the sample rate, defined by the class attribute. All 4 channels are enables and configured by max. amplitude and filter values from class attributes. Digital outputs X0, X1 and X2 are defined which are controlled by the 15th bit of analog outputs 1, 2 and 3.

Raises:

Warning – The actual set sample rate deviates from the corresponding class attribute to be set, class attribute is overwritten.

start_operation(data: UnrolledSequence | None = None) None[source]#

Start transmit (TX) card operation.

Steps: (1) Setup the transmit card (2) Clear emergency stop flag, reset to False (3) Start worker thread (card streaming mode), with provided replay data

Parameters:

data – Sequence replay data as int16 numpy array in correct order. Checkout prepare_sequence function for reference of correct replay data format. This value is None per default

Raises:

ValueError – Raised if replay data is not provided as numpy int16 values

stop_operation() None[source]#

Stop card operation by thread event and stop card.