SPI Rack API#

The SPI rack driver is separated into two layers:

QCoDeS driver#

class qblox_instruments.SpiRack(*args: Any, **kwargs: Any)[source]#

Bases: SpiRack, Instrument

SPI rack driver class based on QCoDeS.

Example usage:

from qblox_instruments import SpiRack
from qblox_instruments.qcodes_drivers.spi_rack_modules import S4gModule

spi = SpiRack("my_spi_rack", "COM4")   # connects to an SPI rack on COM port 4
spi.add_spi_module(3, "D5a", "alice")  # adds an D5a module with address 3 named "alice"
spi.add_spi_module(2, "S4g", "bob")    # adds an S4g module with address 2 named "bob"
spi.add_spi_module(6, S4gModule)       # adds an S4g module with address 6 with the default name module6

spi.bob.dac0.current(10e-3)            # sets the current of output 1 of the S4g module named "bob" to 10 mA
spi.alice.dac6.voltage(-2)             # sets the voltage of output 7 of the D5a module named "alice" to -2 V
__init__(name: str, address: str, baud_rate: int = 9600, timeout: float = 1, is_dummy: bool = False)[source]#

Instantiates the driver object.

Parameters:
  • name (str) – Instrument name.

  • address (str) – COM port used by SPI rack controller unit (e.g. “COM4”)

  • baud_rate (int) – Baud rate

  • timeout (float) – Data receive timeout in seconds

  • is_dummy (bool) – If true, the SPI rack driver is operating in “dummy” mode for testing purposes.

add_spi_module(address: int, module_type: SpiModuleBase | str, name: str | None = None, **kwargs) None[source]#

Add a module to the driver.

Parameters:
  • address (int) – Address that the module is set to (set internally on the module itself with a jumper).

  • module_type (Union[str, SpiModuleBase]) – Either a str that is defined in _MODULES_MAP, or a reference to a class derived from SpiModuleBase.

  • name (Optional[str]) – Optional name of the module. If no name is given or is None, a default name of “module{address}” is used.

Raises:

ValueError – module_type is not a string or a subclass of SpiModuleBase

close() None[source]#

Closes connection to hardware and closes the Instrument.

connect_message(idn_param: str = 'IDN', begin_time: float | None = None) None[source]#

Print a standard message on initial connection to an instrument. Overridden from superclass to accommodate IEEE488.2 for IDN.

Parameters:
  • idn_param (str) – Name of parameter that returns ID dict. Default IDN.

  • begin_time (Optional[float]) – time.time() when init started. Default is self._t0, set at start of Instrument.__init__.

class qblox_instruments.qcodes_drivers.spi_rack_modules.SpiModuleBase(parent, name: str, address: int, **kwargs)[source]#

Bases: SpiModuleBase, InstrumentChannel

Defines an abstract base class for SPI modules. All module drivers should inherit from this class.

This class defines no actual functionality but rather serves to provide a common interface shared among all modules.

Parameters:
  • parent – Reference to the SpiRack parent object. This is handled by the add_spi_module() function.

  • name (str) – Name given to the InstrumentChannel.

  • address (int) – Module number set on the hardware (set internally on the module itself with a jumper).

__init__(parent, name: str, address: int, **kwargs)[source]#

Defines an abstract base class for SPI modules. All module drivers should inherit from this class.

This class defines no actual functionality but rather serves to provide a common interface shared among all modules.

Parameters:
  • parent – Reference to the SpiRack parent object. This is handled by the add_spi_module() function.

  • name (str) – Name given to the module.

  • address (int) – Module number set on the hardware (set internally on the module itself with a jumper).

QCoDeS instrument parameters#

QCoDeS parameters generated by SpiRack.

SPIRack.IDN()#

Please see QCoDeS for a description.

Properties:
  • value: <Anything>

SPIRack.temperature()#

Returns the temperature in the C1b module. Reads the temperature from the internal C1b temperature sensor. Accuracy is +- 0.5 degrees in 0-70 degree range.

Properties:
  • unit: C

  • value: None

SPIRack.battery_voltages()#

Calculates the battery voltages from the ADC channel values. Returns: [VbatPlus, VbatMin]

Properties:
  • unit: V

  • value: None

SPIRack.add_spi_module(address: int, module_type: qblox_instruments.qcodes_drivers.spi_rack_modules.spi_module_base.SpiModuleBase | str, name: str | None = None, **kwargs) None#

Add a module to the driver.

Parameters:
  • address (int) – Address that the module is set to (set internally on the module itself with a jumper).

  • module_type (Union[str, SpiModuleBase]) – Either a str that is defined in _MODULES_MAP, or a reference to a class derived from SpiModuleBase.

  • name (Optional[str]) – Optional name of the module. If no name is given or is None, a default name of “module{address}” is used.

Raises:

ValueError – module_type is not a string or a subclass of SpiModuleBase

SPIRack.set_dacs_zero() None#

Calls the set_dacs_zero function on all the modules, which in turn should cause all output values to be set to 0.

Native interface#

class qblox_instruments.native.SpiRack(address: str, baud_rate: int = 9600, timeout: float = 1, is_dummy: bool = False)[source]#

Bases: object

SPI rack native interface class. This class relies on the spirack API.

__init__(address: str, baud_rate: int = 9600, timeout: float = 1, is_dummy: bool = False)[source]#

Instantiates the driver object.

Parameters:
  • address (str) – COM port used by SPI rack controller unit (e.g. “COM4”)

  • baud_rate (int) – Baud rate

  • timeout (float) – Data receive timeout in seconds

  • is_dummy (bool) – If true, the SPI rack driver is operating in “dummy” mode for testing purposes.

add_spi_module(address: int, module_type: SpiModuleBase | str, name: str | None = None, **kwargs) Tuple[str, SpiModuleBase][source]#

Add a module to the driver and return module object.

Parameters:
  • address (int) – Address that the module is set to (set internally on the module itself with a jumper).

  • module_type (Union[str, SpiModuleBase]) – Either a str that is defined in _MODULES_MAP, or a reference to a class derived from SpiModuleBase.

  • name (Optional[str]) – Optional name of the module. If no name is given or is None, a default name of “module{address}” is used.

Returns:

  • str – Name

  • SpiModuleBase – SPI module object

Raises:

ValueError – module_type is not a string or a subclass of SpiModuleBase

get_idn() Dict[source]#

Generates the IDN dict.

Returns:

The QCoDeS style IDN dictionary. Currently only the firmware version is actually read from hardware.

Return type:

dict

close() None[source]#

Closes connection to hardware and closes the Instrument.

set_dacs_zero() None[source]#

Calls the set_dacs_zero function on all the modules, which in turn should cause all output values to be set to 0.

class qblox_instruments.native.spi_rack_modules.SpiModuleBase(parent, name: str, address: int, **kwargs)[source]#

Bases: object

Abstract SPI module base class.

__init__(parent, name: str, address: int, **kwargs)[source]#

Defines an abstract base class for SPI modules. All module drivers should inherit from this class.

This class defines no actual functionality but rather serves to provide a common interface shared among all modules.

Parameters:
  • parent – Reference to the SpiRack parent object. This is handled by the add_spi_module() function.

  • name (str) – Name given to the module.

  • address (int) – Module number set on the hardware (set internally on the module itself with a jumper).

abstract set_dacs_zero() None[source]#

” Base method for set_dacs_zero. Should be overridden by subclass.

S4g QCoDeS driver#

QCoDeS parameters generated by S4gModule.

class qblox_instruments.qcodes_drivers.spi_rack_modules.S4gModule(parent, name: str, address: int, reset_currents: bool = False, dac_names: List[str] | None = None, is_dummy: bool = False)[source]#

Bases: S4gModule, InstrumentChannel

QCoDeS style instrument channel driver for the S4g SPI module.

NUMBER_OF_DACS = 4#
__init__(parent, name: str, address: int, reset_currents: bool = False, dac_names: List[str] | None = None, is_dummy: bool = False)[source]#

Instantiates the driver object. This is the object that should be instantiated by the add_spi_module() function.

Parameters:
  • parent – Reference to the SpiRack parent object. This is handled by the add_spi_module() function.

  • name (str) – Name given to the InstrumentChannel.

  • address (int) – Module number set on the hardware.

  • reset_currents (bool) – If True, then reset all currents to zero and change the span to range_max_bi.

  • dac_names (Optional[List[str]]) – List of all the names to use for the dac channels. If no list is given or is None, the default name “dac{i}” is used for the i-th dac channel.

  • is_dummy (bool) – If true, do not connect to physical hardware, but use a dummy module.

Raises:

ValueError – Length of the dac names list does not match the number of dacs.

set_dacs_zero() None[source]#

Sets all currents of all outputs to 0.

S4g QCoDeS parameters#

S4g.current()#

Sets the output current of the dac channel. Depending on the value of ramping_enabled, the output value is either achieved through slowly ramping, or instantaneously set.

Properties:
  • unit: A

  • value: <Numbers -0.04<=v<=0.04>

S4g.span()#

Sets the max range of the DACs. Possible values: ‘range_max_uni’: 0 - 40 mA, ‘range_max_bi’: -40 - 40 mA, ‘range_min_bi’: -20 - 20 mA.

Properties:
  • value: <Enum: {‘range_min_bi’, ‘range_max_bi’, ‘range_max_uni’}>

S4g.ramp_rate()#

Limits the rate at which currents can be changed. The size of of steps is still limited by ramp_max_step.

Properties:
  • unit: A/s

  • value: None

S4g.ramp_max_step()#

Sets the maximum step size for current ramping. The rate at which it ramps is set by ramp_rate.

Properties:
  • unit: A

  • value: None

S4g.ramping_enabled()#

Turns ramping on or off. Toggling ramping_enabled changed the behavior of the setter for the current parameter. If enabled, ramping is done at a rate set by ramp_rate and in steps specified by ramp_max_step.

Properties:
  • value: <Boolean>

S4g.is_ramping()#

Returns whether the dac is currently in the process of ramping.

Properties:
  • value: None

S4g.stepsize()#

Returns the smallest current step allowed by the dac for the current settings.

Properties:
  • unit: A

  • value: None

S4g.dac_channel()#

Returns the dac number of this channel.

Properties:
  • value: None

S4g.set_current_instant(dac, val) None#

Wrapper function around the set_current API call. Instantaneously sets the current.

Parameters:
  • dac (int) – the dac of which to set the current

  • val (float) – The new value of the current

S4g native interface#

class qblox_instruments.native.spi_rack_modules.S4gModule(parent, name: str, address: int, reset_currents: bool = False, dac_names: List[str] | None = None, is_dummy: bool = False)[source]#

Bases: SpiModuleBase

Native driver for the S4g SPI module.

NUMBER_OF_DACS = 4#
__init__(parent, name: str, address: int, reset_currents: bool = False, dac_names: List[str] | None = None, is_dummy: bool = False)[source]#

Instantiates the driver object. This is the object that should be instantiated by the add_spi_module() function.

Parameters:
  • parent – Reference to the SpiRack parent object. This is handled by the add_spi_module() function.

  • name (str) – Name given to the InstrumentChannel.

  • address (int) – Module number set on the hardware.

  • reset_currents (bool) – If True, then reset all currents to zero and change the span to range_max_bi.

  • dac_names (Optional[List[str]]) – List of all the names to use for the dac channels. If no list is given or is None, the default name “dac{i}” is used for the i-th dac channel.

  • is_dummy (bool) – If true, do not connect to physical hardware, but use dummy module.

Raises:

ValueError – Length of the dac names list does not match the number of dacs.

set_dacs_zero() None[source]#

Sets all currents of all outputs to 0.

D5a QCoDeS driver#

QCoDeS parameters generated by D5aModule.

class qblox_instruments.qcodes_drivers.spi_rack_modules.D5aModule(parent, name: str, address: int, reset_voltages: bool = False, dac_names: List[str] | None = None, is_dummy: bool = False)[source]#

Bases: D5aModule, InstrumentChannel

QCoDeS style instrument channel driver for the D5a SPI module.

NUMBER_OF_DACS = 16#
__init__(parent, name: str, address: int, reset_voltages: bool = False, dac_names: List[str] | None = None, is_dummy: bool = False)[source]#

Instantiates the driver object. This is the object that should be instantiated by the add_spi_module() function.

Parameters:
  • parent – Reference to the SpiRack parent object. This is handled by the add_spi_module() function.

  • name (str) – Name given to the InstrumentChannel.

  • address (int) – Module number set on the hardware.

  • reset_voltages (bool) – If True, then reset all voltages to zero and change the span to range_max_bi.

  • dac_names (Optional[List[str]]) – List of all the names to use for the dac channels. If no list is given or is None, the default name “dac{i}” is used for the i-th dac channel.

  • is_dummy (bool) – If true, do not connect to physical hardware, but use a dummy module.

Raises:

ValueError – Length of the dac names list does not match the number of dacs.

D5a QCoDeS parameters#

D5a.voltage()#

Sets the output voltage of the dac channel. Depending on the value of ramping_enabled, the output value is either achieved through slowly ramping, or instantaneously set.

Properties:
  • unit: V

  • value: <Numbers -8.0<=v<=8.0>

D5a.span()#

Sets the max range of the DACs. Possible values: ‘range_4V_uni’: 0 - 4 V, ‘range_8V_uni’: 0 - 8 V (only if non-standard 12 V power supply is present), ‘range_4V_bi’: -4 - 4 V, ‘range_8V_bi’: -8 - 8 V (only if non-standard 12 V power supply is present), ‘range_2V_bi’: -2 - 2 V.

Properties:
  • value: <Enum: {‘range_8V_uni’, ‘range_4V_bi’, ‘range_2V_bi’, ‘range_8V_bi’, ‘range_4V_uni’}>

D5a.ramp_rate()#

Limits the rate at which currents can be changed. The size of of steps is still limited by ramp_max_step.

Properties:
  • unit: V/s

  • value: None

D5a.ramp_max_step()#

Sets the maximum step size for voltage ramping. The rate at which it ramps is set by ramp_rate.

Properties:
  • unit: V

  • value: None

D5a.ramping_enabled()#

Turns ramping on or off. Toggling ramping_enabled changed the behavior of the setter for the current parameter. If enabled, ramping is done at a rate set by ramp_rate and in steps specified by ramp_max_step.

Properties:
  • value: <Boolean>

D5a.is_ramping()#

Returns whether the dac is currently in the process of ramping.

Properties:
  • value: None

D5a.stepsize()#

Returns the smallest current step allowed by the dac for the current settings.

Properties:
  • unit: V

  • value: None

D5a.dac_channel()#

Returns the dac number of this channel.

Properties:
  • value: None

D5a.set_voltage_instant(dac: int, val: float) None#

” Wrapper function around the set_voltage API call. Instantaneously sets the voltage.

Parameters:
  • dac (int) – the dac of which to set the voltage

  • val (float) – The new value of the voltage

D5a native interface#

class qblox_instruments.native.spi_rack_modules.D5aModule(parent, name: str, address: int, reset_voltages: bool = False, dac_names: List[str] | None = None, is_dummy: bool = False)[source]#

Bases: SpiModuleBase

Native driver for the D5a SPI module.

NUMBER_OF_DACS = 16#
__init__(parent, name: str, address: int, reset_voltages: bool = False, dac_names: List[str] | None = None, is_dummy: bool = False)[source]#

Instantiates the driver object. This is the object that should be instantiated by the add_spi_module() function.

Parameters:
  • parent – Reference to the SpiRack parent object. This is handled by the add_spi_module() function.

  • name (str) – Name given to the InstrumentChannel.

  • address (int) – Module number set on the hardware.

  • reset_voltages (bool) – If True, then reset all voltages to zero and change the span to range_max_bi.

  • dac_names (Optional[List[str]]) – List of all the names to use for the dac channels. If no list is given or is None, the default name “dac{i}” is used for the i-th dac channel.

  • is_dummy (bool) – If true, do not connect to physical hardware, but use dummy module.

Raises:

ValueError – Length of the dac names list does not match the number of dacs.

set_dacs_zero() None[source]#

Sets all voltages of all outputs to 0.