{ "cells": [ { "cell_type": "markdown", "id": "656c1c4a", "metadata": {}, "source": [ "SPI Rack\n", "========\n", "\n", "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](https://github.com/mtiggelman/SPI-rack/).\n", "[![spi rack image](spi_19inch_c1b_d5a_ppt_middle.jpg)](spi_19inch_c1b_d5a_ppt_middle.jpg)" ] }, { "cell_type": "markdown", "id": "a38de36d", "metadata": {}, "source": [ "In order to connect to the SPI Rack driver:" ] }, { "cell_type": "code", "execution_count": null, "id": "2fc52feb", "metadata": {}, "outputs": [], "source": [ "from qcodes.instrument import find_or_create_instrument\n", "\n", "from qblox_instruments import SpiRack\n", "\n", "# In our case the SPI Rack is connected to COM port 4\n", "spi = find_or_create_instrument(SpiRack, recreate=True, name=\"SPI_Rack\", address=\"COM4\")" ] }, { "cell_type": "markdown", "id": "9050c2e3", "metadata": {}, "source": [ "To verify everything is working correctly we can read out the temperature of the C1b module" ] }, { "cell_type": "code", "execution_count": null, "id": "f3a721e4", "metadata": {}, "outputs": [], "source": [ "spi.temperature()" ] }, { "cell_type": "markdown", "id": "15fb04cf", "metadata": {}, "source": [ "Connecting to S4g\n", "--------------------------\n", "Next, we need to add the modules to our driver. We will be using a S4g module for this tutorial." ] }, { "cell_type": "code", "execution_count": null, "id": "d5804d1b", "metadata": {}, "outputs": [], "source": [ "spi.add_spi_module(2, \"S4g\")" ] }, { "cell_type": "markdown", "id": "9c7318a6", "metadata": {}, "source": [ "The S4g module we added can now be accessed through `spi.module2`. Let's try setting an output current:" ] }, { "cell_type": "code", "execution_count": null, "id": "27198673", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current(1e-3)" ] }, { "cell_type": "markdown", "id": "6066ee81", "metadata": {}, "source": [ "This sets the output current of dac0 (output 1) to 1 mA. We can read this current back through:" ] }, { "cell_type": "code", "execution_count": null, "id": "cd49849f", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "markdown", "id": "437bf760", "metadata": {}, "source": [ "Now we will change the output range." ] }, { "cell_type": "code", "execution_count": null, "id": "ed49ad2d", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac1.span()" ] }, { "cell_type": "markdown", "id": "07148b97", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": null, "id": "2b611df7", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac1.span(\"range_min_bi\")\n", "spi.module2.dac1.span()" ] }, { "cell_type": "markdown", "id": "60d6637c", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": null, "id": "10026383", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "code", "execution_count": null, "id": "975c7227", "metadata": {}, "outputs": [], "source": [ "spi.set_dacs_zero()" ] }, { "cell_type": "code", "execution_count": null, "id": "1335e8a9", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "markdown", "id": "9e7c75b0", "metadata": {}, "source": [ "Connecting to D5a\n", "--------------------------\n", "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`" ] }, { "cell_type": "code", "execution_count": null, "id": "bcdc3ec1", "metadata": {}, "outputs": [], "source": [ "spi.add_spi_module(1, \"D5a\", \"alice\")" ] }, { "cell_type": "code", "execution_count": null, "id": "07e0c3ad", "metadata": {}, "outputs": [], "source": [ "spi.alice.dac0.voltage(1.0)\n", "spi.alice.dac0.voltage()" ] }, { "cell_type": "code", "execution_count": null, "id": "6edaeea0", "metadata": {}, "outputs": [], "source": [ "spi.set_dacs_zero()\n", "spi.alice.dac0.voltage()" ] }, { "cell_type": "markdown", "id": "99faf546", "metadata": {}, "source": [ "Similar to the S4g, the D5a also has a span that can be set.\n", "\n", "Supported settings are: `'range_4V_uni'`, `'range_4V_bi'` and `'range_2V_bi'`." ] }, { "cell_type": "code", "execution_count": null, "id": "46b34aa1", "metadata": {}, "outputs": [], "source": [ "spi.alice.dac0.span()" ] }, { "cell_type": "markdown", "id": "fcad2fc7", "metadata": {}, "source": [ "Extending the SPI module drivers\n", "------------------------------------------------\n", "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.\n", "\n", "As an example, we will add the `DummySpiModule` to the SPI Rack." ] }, { "cell_type": "code", "execution_count": null, "id": "6e1b9a3c", "metadata": {}, "outputs": [], "source": [ "from qblox_instruments.qcodes_drivers.spi_rack_modules import DummySpiModule\n", "\n", "spi.add_spi_module(3, DummySpiModule, \"bob\")" ] }, { "cell_type": "markdown", "id": "8e697ee0", "metadata": {}, "source": [ "Closing the instrument\n", "---------------------------------\n", "Finally, we will close the connection to the instrument." ] }, { "cell_type": "code", "execution_count": null, "id": "4c97e7f7", "metadata": {}, "outputs": [], "source": [ "spi.close()" ] } ], "metadata": { "files_to_bundle_in_zip_file": [ "spi_19inch_c1b_d5a_ppt_middle.jpg" ], "jupytext": { "main_language": "python", "notebook_metadata_filter": "files_to_bundle_in_zip_file" } }, "nbformat": 4, "nbformat_minor": 5 }