{ "cells": [ { "cell_type": "markdown", "id": "c08d6367", "metadata": {}, "source": [ "# QSwitch debugging\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "85f2a1e0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to: Quantum Machines QSwitch (serial:2, firmware:0.178) in 0.11s\n" ] } ], "source": [ "import pprint\n", "pp = pprint.PrettyPrinter()\n", "from qcodes_contrib_drivers.drivers.QDevil import QSwitch\n", "qswitch_addr = '192.168.8.20'\n", "qswitch = QSwitch.QSwitch('switch', visalib='@py', address=f'TCPIP::{qswitch_addr}::5025::SOCKET')" ] }, { "cell_type": "markdown", "id": "5c6c00b2", "metadata": {}, "source": [ " You can record the underlying SCPI commands that are sent to the QSwitch:" ] }, { "cell_type": "code", "execution_count": 5, "id": "d0c7fc28", "metadata": {}, "outputs": [], "source": [ "qswitch.start_recording_scpi()" ] }, { "cell_type": "code", "execution_count": 6, "id": "64f0cbe6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'0,\"No error\"'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "qswitch.reset()\n", "qswitch.arrange(\n", " breakouts={'DMM': 5, 'VNA': 7},\n", " lines={'plunger': 23, 'sensor': 5})\n", "qswitch.connect('sensor')\n", "qswitch.breakout('sensor', 'DMM')\n", "qswitch.errors()" ] }, { "cell_type": "code", "execution_count": 7, "id": "0d8a7693", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['*rst',\n", " 'stat?',\n", " 'clos (@5!9)',\n", " '*opc?',\n", " 'open (@5!0)',\n", " '*opc?',\n", " 'clos (@5!5)',\n", " '*opc?',\n", " 'all?']\n" ] } ], "source": [ "pp.pprint(qswitch.get_recorded_scpi_commands())" ] }, { "cell_type": "code", "execution_count": 8, "id": "995394e6", "metadata": {}, "outputs": [], "source": [ "qswitch.close()" ] }, { "cell_type": "markdown", "id": "588fabac", "metadata": {}, "source": [ "## Connections" ] }, { "cell_type": "markdown", "id": "4a00d73e-88e0-439c-9b80-15aaffaf2064", "metadata": {}, "source": [ "If you are connecting via USB, then you need `pyserial` installed." ] }, { "cell_type": "code", "execution_count": 1, "id": "37ac76f2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('ASRL/dev/ttyS0::INSTR', 'ASRL/dev/ttyACM0::INSTR')" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pyvisa\n", "rm = pyvisa.ResourceManager('@py')\n", "rm.list_resources()" ] }, { "cell_type": "code", "execution_count": 4, "id": "b80a56eb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to: Quantum Machines QSwitch (serial:1, firmware:0.162) in 0.06s\n" ] } ], "source": [ "from qcodes_contrib_drivers.drivers.QDevil import QSwitch\n", "qswitch = QSwitch.QSwitch('switch', visalib='@py', address='ASRL/dev/ttyACM0::INSTR')" ] }, { "cell_type": "markdown", "id": "c3119260", "metadata": {}, "source": [ "If a python process hangs and blocks the ethernet connection to the QSwitch, you can force the QSwitch to drop the connection:" ] }, { "cell_type": "code", "execution_count": 6, "id": "33c3719f", "metadata": {}, "outputs": [], "source": [ "qswitch.write('system:comm:lan:close')" ] }, { "cell_type": "markdown", "id": "d6bdb22e", "metadata": {}, "source": [ "See https://github.com/QDevil/qdac2-tools for more debugging tools." ] }, { "cell_type": "markdown", "id": "8428f8bd", "metadata": {}, "source": [ "The QSwitch only supports a single Ethernet connection at a time. If you find yourself in a situation where you cannot connect to the instrument, then it might be because some process on your computer still has a connection to the instrument. To identify which process, do something like" ] }, { "cell_type": "markdown", "id": "06be4a1a", "metadata": {}, "source": [ "```\n", "$ netstat -ntpn | grep '192.168.8.21'\n", "tcp 0 0 192.168.8.66:43772 192.168.8.21:5025 ESTABLISHED 153450/python3\n", "```" ] }, { "cell_type": "markdown", "id": "8708065e", "metadata": {}, "source": [ "Then you can forcefully kill the process like" ] }, { "cell_type": "markdown", "id": "945dcaf4", "metadata": {}, "source": [ "```\n", "$ kill 153450\n", "```" ] }, { "cell_type": "markdown", "id": "b39d8c3c", "metadata": {}, "source": [ "and then wait for the TCP connection to let go:" ] }, { "cell_type": "markdown", "id": "8e9d32f9", "metadata": {}, "source": [ "```\n", "$ netstat -ntpn | grep '192.168.8.21'\n", "tcp 0 0 192.168.8.66:43772 192.168.8.21:5025 TIME_WAIT -\n", "```" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.12" }, "nbsphinx": { "execute": "never" } }, "nbformat": 4, "nbformat_minor": 5 }