SPI Rack¶
QCoDeS driver¶
- class spi_rack.spi_rack.dummy_spi_api(address, baud_rate, timeout=1.0)[source]¶
Bases:
object
” A dummy API that can be used to test the SPI rack driver.
- TEMPERATURE = 25.0¶
- BATTERY_LVLS = [6.0, -6.0]¶
- FIRMWARE_VERSION = 'v1.0'¶
- __init__(address, baud_rate, timeout=1.0)[source]¶
Instantiates the dummy API object.
- Parameters
address – Mock value for the address on which the spi_rack is connected. This value is assigned to a member variable, but is not actually used.
address – Mock value for the baud_rate for the serial connection. This value is assigned to a member variable, but is not actually used.
timeout – Mock value for the timeout for the serial connection. This value is assigned to a member variable, but is not actually used.
- get_temperature() float [source]¶
Return a mock temperature.
- Returns
returns dummy_spi_api.TEMPERATURE
- Return type
float
- get_battery() List[float] [source]¶
Return a mock battery level list. In the actual API these are two values read from the battery ADCs. For the mock API simply constant values are returned. The expected values to be returned can also be gotten through dummy_spi_api.BATTERY_LVLS.
- Returns
returns dummy_spi_api.BATTERY_LVLS
- Return type
List[float]
- class spi_rack.spi_rack.spi_rack(name: str, address: str, baud_rate: int = 9600, timeout: float = 1, dummy_api: Optional[Type[spi_rack.spi_rack.dummy_spi_api]] = None)[source]¶
Bases:
qcodes.instrument.base.Instrument
SPI rack driver class based on QCoDeS <https://qcodes.github.io/Qcodes/>. This class relies on the spirack API <https://github.com/mtiggelman/SPI-rack/>.
Example usage:
from spi_rack.spi_rack import spi_rack from spi_rack.S4g_module import S4g_module spi = spi_rack("my_spi_rack", "COM4") spi.add_spi_module(2, "S4g", "bob") # adds an S4g module with address 2 named "bob" spi.add_spi_module(6, S4g_module) # adds an S4g module with address 6 with the default name module6 spi.bob.dac0.current(10e-3) # sets the current of output 0 of the S4g module named "bob" to 10 mA
- __init__(name: str, address: str, baud_rate: int = 9600, timeout: float = 1, dummy_api: Optional[Type[spi_rack.spi_rack.dummy_spi_api]] = None)[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
dummy_api (Type[dummy_spi_api]) – If the dummy API is passed instead of None, the SPI rack driver is operating in “dummy” mode for testing purposes.
- add_spi_module(address: int, module_type: Union[spi_rack.spi_module_base.spi_module_base, str], name: Optional[str] = None, **kwargs)[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, spi_module_base]) – Either a str that is defined in _MODULES_MAP, or a reference to a class derived from SPI_Module_Base.
name (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 SPI_Module_Base
- get_idn()[source]¶
Generates the IDN dict.
- Returns
The QCoDeS style IDN dictionary. Currently only the firmware version is actually read from hardware.
- Return type
dict
- set_dacs_zero()[source]¶
Calls the
set_dacs_zero()
function on all the modules, which in turn should cause all output values to be set to 0.
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = 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 isself._t0
, set at start ofInstrument.__init__
.
- class spi_rack.spi_module_base.spi_module_base(parent, name: str, address: int, **kwargs)[source]¶
Bases:
qcodes.instrument.channel.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 spi_rack 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).
- class spi_rack.spi_module_base.dummy_spi_module(parent, name: str, address: int)[source]¶
Bases:
spi_rack.spi_module_base.spi_module_base
A dummy implementation of module driver, used for mock implementations.
QCoDeS parameters¶
spi_rack.IDN
¶
Please see QCoDeS for a description.
- Properties
value: Anything
spi_rack.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: on
spi_rack.battery_voltages
¶
Calculates the battery voltages from the ADC channel values. Returns: [VbatPlus, VbatMin]
- Properties
unit: V
value: on
S4g module¶
- class spi_rack.s4g_module.s4g_module(parent, name: str, address: int, reset_currents: bool = True, dac_names: Optional[List[str]] = None)[source]¶
Bases:
spi_rack.spi_module_base.spi_module_base
QCoDeS <https://qcodes.github.io/Qcodes/>- style instrument channel driver for the S4g SPI module.
- NUMBER_OF_DACS = 4¶
- __init__(parent, name: str, address: int, reset_currents: bool = True, dac_names: Optional[List[str]] = None)[source]¶
Instantiates the driver object. This is the object that should be instantiated by the add_spi_module function.
- Parameters
parent – Reference to the spi_rack 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 (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.
- Raises
ValueError – Length of the dac names list does not match the number of dacs.
- class spi_rack.s4g_module.s4g_dac_channel(parent: spi_rack.s4g_module.s4g_module, name: str, dac: int)[source]¶
Bases:
qcodes.instrument.channel.InstrumentChannel
QCoDeS <https://qcodes.github.io/Qcodes/>- style instrument channel driver for the dac channels of the S4g module. This class is used by the S4g_module to define the individual dac channels and should not be used directly.
- __init__(parent: spi_rack.s4g_module.s4g_module, name: str, dac: int)[source]¶
Constructor for the dac channel instrument channel.
- Parameters
parent (s4g_module) – Reference to the parent s4g_module
name (str) – Name for the instrument channel
dac (int) – Number of the dac that this channel corresponds to