{ "cells": [ { "cell_type": "markdown", "id": "321b94c8", "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/)." ] }, { "cell_type": "markdown", "id": "c6a6afa6", "metadata": {}, "source": [ "In order to connect to the SPI Rack driver:\n", "\n", "from qcodes.instrument import find_or_create_instrument" ] }, { "cell_type": "code", "execution_count": null, "id": "1f216984", "metadata": {}, "outputs": [], "source": [ "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": "3f3d2b70", "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": "56f10786", "metadata": {}, "outputs": [], "source": [ "spi.temperature()" ] }, { "cell_type": "markdown", "id": "91bac3d8", "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": "c913a90e", "metadata": {}, "outputs": [], "source": [ "spi.add_spi_module(2, \"S4g\")" ] }, { "cell_type": "markdown", "id": "ce8de16b", "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": "67286ae0", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current(1e-3)" ] }, { "cell_type": "markdown", "id": "0aa43198", "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": "3584e234", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "markdown", "id": "5cc16195", "metadata": {}, "source": [ "Now we will change the output range." ] }, { "cell_type": "code", "execution_count": null, "id": "627a96ba", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac1.span()" ] }, { "cell_type": "markdown", "id": "a2909509", "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": "344026db", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac1.span(\"range_min_bi\")\n", "spi.module2.dac1.span()" ] }, { "cell_type": "markdown", "id": "c6961408", "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": "41d6a1d4", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "code", "execution_count": null, "id": "a3fdd07e", "metadata": {}, "outputs": [], "source": [ "spi.set_dacs_zero()" ] }, { "cell_type": "code", "execution_count": null, "id": "d42fc01c", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "markdown", "id": "19b32fa5", "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": "c549f454", "metadata": {}, "outputs": [], "source": [ "spi.add_spi_module(1, \"D5a\", \"alice\")" ] }, { "cell_type": "code", "execution_count": null, "id": "0a8f7d9d", "metadata": {}, "outputs": [], "source": [ "spi.alice.dac0.voltage(1.0)\n", "spi.alice.dac0.voltage()" ] }, { "cell_type": "code", "execution_count": null, "id": "daa20ac1", "metadata": {}, "outputs": [], "source": [ "spi.set_dacs_zero()\n", "spi.alice.dac0.voltage()" ] }, { "cell_type": "markdown", "id": "0de352e4", "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": "d7c1ba74", "metadata": {}, "outputs": [], "source": [ "spi.alice.dac0.span()" ] }, { "cell_type": "markdown", "id": "515c06cc", "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": "825ea196", "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": "88459a56", "metadata": {}, "source": [ "Closing the instrument\n", "---------------------------------\n", "Finally, we will close the connection to the instrument." ] }, { "cell_type": "code", "execution_count": null, "id": "4f420042", "metadata": {}, "outputs": [], "source": [ "spi.close()" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent", "notebook_metadata_filter": "nbsphinx" }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "nbsphinx": { "execute": "never" } }, "nbformat": 4, "nbformat_minor": 5 }