See also

A Jupyter notebook version of this tutorial can be downloaded here.

SPI Rack#

In this tutorial we explain basic usage of the modular SPI Rack drivers provided by the Qblox instruments package. The driver is based on the programming interface provided by SPI-rack.

In order to connect to the SPI Rack driver:

from qcodes.instrument import find_or_create_instrument

[ ]:
from qblox_instruments import SpiRack

# In our case the SPI Rack is connected to COM port 4
spi = find_or_create_instrument(SpiRack, recreate=True, name="SPI_Rack", address="COM4")

To verify everything is working correctly we can read out the temperature of the C1b module

[ ]:
spi.temperature()

Connecting to S4g#

Next, we need to add the modules to our driver. We will be using a S4g module for this tutorial.

[ ]:
spi.add_spi_module(2, "S4g")

The S4g module we added can now be accessed through spi.module2. Let’s try setting an output current:

[ ]:
spi.module2.dac0.current(1e-3)

This sets the output current of dac0 (output 1) to 1 mA. We can read this current back through:

[ ]:
spi.module2.dac0.current()

Now we will change the output range.

[ ]:
spi.module2.dac1.span()

We see that the span of DAC channel 1 is set to the default 'range_max_bi' (corresponding to -40 to +40 mA), changing this works similar to how we change the current.

[ ]:
spi.module2.dac1.span("range_min_bi")
spi.module2.dac1.span()

Now we updated the range to the smaller -20 to +20 mA range. We will now set all output values back to zero using the convenient set_dacs_zero function.

[ ]:
spi.module2.dac0.current()
[ ]:
spi.set_dacs_zero()
[ ]:
spi.module2.dac0.current()

Connecting to D5a#

Connecting to the D5a module works the same way as the S4g. Instead of the default name module1, let’s give this D5a an alias and call it alice

[ ]:
spi.add_spi_module(1, "D5a", "alice")
[ ]:
spi.alice.dac0.voltage(1.0)
spi.alice.dac0.voltage()
[ ]:
spi.set_dacs_zero()
spi.alice.dac0.voltage()

Similar to the S4g, the D5a also has a span that can be set.

Supported settings are: 'range_4V_uni', 'range_4V_bi' and 'range_2V_bi'.

[ ]:
spi.alice.dac0.span()

Extending the SPI module drivers#

It is possible to use custom drivers for the SPI modules within the SPI rack driver provided by qblox-instruments. Any class that inherits from SpiModuleBase is accepted by the spi rack driver. The driver can be added as a module by passing a reference to the class instead of the usual string.

As an example, we will add the DummySpiModule to the SPI Rack.

[ ]:
from qblox_instruments.qcodes_drivers.spi_rack_modules import DummySpiModule

spi.add_spi_module(3, DummySpiModule, "bob")

Closing the instrument#

Finally, we will close the connection to the instrument.

[ ]:
spi.close()