{ "cells": [ { "cell_type": "markdown", "id": "c35ea185", "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": "0ff2a81a", "metadata": {}, "source": [ "In order to connect to the SPI Rack driver:" ] }, { "cell_type": "code", "execution_count": null, "id": "8ece6549", "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": "a0482920", "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": "5ee93829", "metadata": {}, "outputs": [], "source": [ "spi.temperature()" ] }, { "cell_type": "markdown", "id": "8e074640", "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": "b7b6e720", "metadata": {}, "outputs": [], "source": [ "spi.add_spi_module(2, \"S4g\")" ] }, { "cell_type": "markdown", "id": "b619f5be", "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": "a4e1618e", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current(1e-3)" ] }, { "cell_type": "markdown", "id": "260546e3", "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": "69bf7210", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "markdown", "id": "d7f3f42c", "metadata": {}, "source": [ "Now we will change the output range." ] }, { "cell_type": "code", "execution_count": null, "id": "b215e5bc", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac1.span()" ] }, { "cell_type": "markdown", "id": "e32f6477", "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": "cc155f45", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac1.span(\"range_min_bi\")\n", "spi.module2.dac1.span()" ] }, { "cell_type": "markdown", "id": "20782161", "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": "790d94dc", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "code", "execution_count": null, "id": "b8e7e639", "metadata": {}, "outputs": [], "source": [ "spi.set_dacs_zero()" ] }, { "cell_type": "code", "execution_count": null, "id": "31ca0672", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "markdown", "id": "7de6af61", "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": "1b690a68", "metadata": {}, "outputs": [], "source": [ "spi.add_spi_module(1, \"D5a\", \"alice\")" ] }, { "cell_type": "code", "execution_count": null, "id": "9958566b", "metadata": {}, "outputs": [], "source": [ "spi.alice.dac0.voltage(1.0)\n", "spi.alice.dac0.voltage()" ] }, { "cell_type": "code", "execution_count": null, "id": "e1ed732c", "metadata": {}, "outputs": [], "source": [ "spi.set_dacs_zero()\n", "spi.alice.dac0.voltage()" ] }, { "cell_type": "markdown", "id": "7e77925b", "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": "56f60b5a", "metadata": {}, "outputs": [], "source": [ "spi.alice.dac0.span()" ] }, { "cell_type": "markdown", "id": "1e94bdec", "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": "b7bf42dc", "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": "8d8bc3b1", "metadata": {}, "source": [ "Closing the instrument\n", "---------------------------------\n", "Finally, we will close the connection to the instrument." ] }, { "cell_type": "code", "execution_count": null, "id": "55f579e4", "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 }