{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "8cadf67a", "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/)." ] }, { "attachments": {}, "cell_type": "markdown", "id": "e92f9d99", "metadata": {}, "source": [ "In order to connect to the SPI Rack driver:" ] }, { "cell_type": "code", "execution_count": 1, "id": "52ddc048", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to: Qblox SPI Rack (serial:None, firmware:{'device': 'v1.6 - May 10 2019 - mt', 'driver': {'version': '0.3.2', 'date': '21/04/2021-16:38:33', 'hash': '0x94E811E5', 'dirty': False}}) in 0.00s\n" ] } ], "source": [ "from qblox_instruments import SpiRack\n", "\n", "# In our case the SPI Rack is connected to COM port 4\n", "spi = SpiRack(\"SPI Rack\", \"COM4\")" ] }, { "attachments": {}, "cell_type": "markdown", "id": "61f3539e", "metadata": {}, "source": [ "To verify everything is working correctly we can read out the temperature of the C1b module" ] }, { "cell_type": "code", "execution_count": 2, "id": "8c7445e3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "23.75" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.temperature()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "150795b2", "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": 3, "id": "ba3778b9", "metadata": {}, "outputs": [], "source": [ "spi.add_spi_module(2, \"S4g\")" ] }, { "attachments": {}, "cell_type": "markdown", "id": "ad8346d3", "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": 4, "id": "cba0e25c", "metadata": {}, "outputs": [], "source": [ "spi.module2.dac0.current(1e-3)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "8906b242", "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": 5, "id": "82e537fa", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.0009998321533203139" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.module2.dac0.current()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "20f202eb", "metadata": {}, "source": [ "Now we will change the output range." ] }, { "cell_type": "code", "execution_count": 6, "id": "de9be97c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'range_max_bi'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.module2.dac1.span()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "523be946", "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": 7, "id": "6ffdc7c4", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'range_min_bi'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.module2.dac1.span(\"range_min_bi\")\n", "spi.module2.dac1.span()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "11e13afc", "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": 8, "id": "f30fb644", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.0009998321533203139" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.module2.dac0.current()" ] }, { "cell_type": "code", "execution_count": 9, "id": "0c0f0d88", "metadata": {}, "outputs": [], "source": [ "spi.set_dacs_zero()" ] }, { "cell_type": "code", "execution_count": 10, "id": "94313a53", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.0" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.module2.dac0.current()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "feb6c74b", "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": 11, "id": "1493eb0b", "metadata": {}, "outputs": [], "source": [ "spi.add_spi_module(1, \"D5a\", \"alice\")" ] }, { "cell_type": "code", "execution_count": 12, "id": "c0ad3fd2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.0" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.alice.dac0.voltage(1.0)\n", "spi.alice.dac0.voltage()" ] }, { "cell_type": "code", "execution_count": 13, "id": "2049dbd0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.0" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.set_dacs_zero()\n", "spi.alice.dac0.voltage()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "62dcd8d3", "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": 14, "id": "db5b7031", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'range_4V_bi'" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "spi.alice.dac0.span()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "162ad50a", "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": 15, "id": "94d87496", "metadata": {}, "outputs": [], "source": [ "from qblox_instruments.qcodes_drivers.spi_rack_modules import DummySpiModule\n", "\n", "spi.add_spi_module(3, DummySpiModule, \"bob\")" ] }, { "attachments": {}, "cell_type": "markdown", "id": "41465189", "metadata": {}, "source": [ "Closing the instrument\n", "---------------------------------\n", "Finally, we will close the connection to the instrument." ] }, { "cell_type": "code", "execution_count": 16, "id": "3489b6ba", "metadata": {}, "outputs": [], "source": [ "spi.close()" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent" }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }