Skip to content

Commit

Permalink
Merge pull request #283 from QDevil/qswitch
Browse files Browse the repository at this point in the history
QSwitch: Use *OPC? instead of delays
  • Loading branch information
astafan8 authored Jan 4, 2024
2 parents 27abe4e + 2fafb9a commit 89db840
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 48 deletions.
90 changes: 82 additions & 8 deletions docs/examples/QDevil/QSwitch/Debugging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"id": "85f2a1e0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Connected to: Quantum Machines QSwitch (serial:5, firmware:0.160) in 0.11s\n"
"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.18'\n",
"qswitch_addr = '192.168.8.20'\n",
"qswitch = QSwitch.QSwitch('switch', visalib='@py', address=f'TCPIP::{qswitch_addr}::5025::SOCKET')"
]
},
Expand All @@ -40,7 +40,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"id": "d0c7fc28",
"metadata": {},
"outputs": [],
Expand All @@ -50,7 +50,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"id": "64f0cbe6",
"metadata": {},
"outputs": [
Expand All @@ -60,7 +60,7 @@
"'0,\"No error\"'"
]
},
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -77,22 +77,40 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"id": "0d8a7693",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['*rst', 'stat?', 'clos (@5!9)', 'open (@5!0)', 'clos (@5!5)', 'all?']\n"
"['*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",
Expand Down Expand Up @@ -176,6 +194,62 @@
"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": {
Expand Down
113 changes: 96 additions & 17 deletions docs/examples/QDevil/QSwitch/Usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"source": [
"import pprint\n",
"pp = pprint.PrettyPrinter()\n",
"import numpy as np\n",
"import qcodes\n",
"from qcodes_contrib_drivers.drivers.QDevil import QSwitch"
]
Expand All @@ -32,15 +31,15 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "5787c333-0d69-47db-bfe3-37bead44a7c5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Connected to: Quantum Machines QSwitch (serial:4, firmware:0.160) in 0.07s\n"
"Connected to: Quantum Machines QSwitch (serial:2, firmware:0.178) in 0.05s\n"
]
}
],
Expand All @@ -67,12 +66,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Connected to: Quantum Machines QSwitch (serial:5, firmware:0.160) in 0.13s\n"
"Connected to: Quantum Machines QSwitch (serial:2, firmware:0.178) in 0.12s\n"
]
}
],
"source": [
"qswitch_addr = '192.168.8.16'\n",
"qswitch_addr = '192.168.8.21'\n",
"qswitch = QSwitch.QSwitch('switch', visalib='@py', address=f'TCPIP::{qswitch_addr}::5025::SOCKET')"
]
},
Expand Down Expand Up @@ -110,6 +109,35 @@
"cell_type": "markdown",
"id": "2fc0260b-8052-457a-b820-15edd7a699d3",
"metadata": {},
"source": [
"Or in expanded form:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c592efa5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'(@1!0,2!0,3!0,4!0,5!0,6!0,7!0,8!0,9!0,10!0,11!0,12!0,13!0,14!0,15!0,16!0,17!0,18!0,19!0,20!0,21!0,22!0,23!0,24!0)'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"QSwitch.expand_channel_list(qswitch.state())"
]
},
{
"cell_type": "markdown",
"id": "f20fa87f",
"metadata": {},
"source": [
"Or expressed as a Python array:"
]
Expand Down Expand Up @@ -293,7 +321,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 10,
"id": "9d3d65c5",
"metadata": {},
"outputs": [],
Expand All @@ -313,7 +341,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"id": "3f7f92ca",
"metadata": {},
"outputs": [],
Expand All @@ -331,7 +359,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"id": "45ae7eea",
"metadata": {},
"outputs": [],
Expand All @@ -358,7 +386,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 13,
"id": "ac31add0",
"metadata": {},
"outputs": [],
Expand All @@ -376,7 +404,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"id": "86cfd2da",
"metadata": {},
"outputs": [],
Expand All @@ -403,7 +431,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 15,
"id": "e0ad0e89",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -440,7 +468,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"id": "245cd62c",
"metadata": {},
"outputs": [],
Expand All @@ -458,7 +486,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"id": "54374fb6",
"metadata": {},
"outputs": [],
Expand All @@ -485,17 +513,50 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"id": "f48f9830",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"{'1': ['grounded'],\n",
" '2': ['grounded'],\n",
" '3': ['grounded'],\n",
" '4': ['grounded'],\n",
" 'sensor': ['grounded'],\n",
" '6': ['grounded'],\n",
" '7': ['grounded'],\n",
" '8': ['grounded'],\n",
" '9': ['grounded'],\n",
" '10': ['grounded'],\n",
" '11': ['grounded'],\n",
" '12': ['grounded'],\n",
" '13': ['grounded'],\n",
" '14': ['grounded'],\n",
" '15': ['grounded'],\n",
" '16': ['grounded'],\n",
" '17': ['grounded'],\n",
" '18': ['grounded'],\n",
" '19': ['grounded'],\n",
" '20': ['grounded'],\n",
" '21': ['grounded'],\n",
" 'plunger': ['connected', 'breakout DMM'],\n",
" '24': ['breakout 1']}"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"qswitch.overview()"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"id": "b5030c09",
"metadata": {},
"outputs": [],
Expand All @@ -521,14 +582,32 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"id": "dfdba65e",
"metadata": {},
"outputs": [],
"source": [
"qswitch.auto_save('on')\n",
"qswitch.auto_save('off')"
]
},
{
"cell_type": "markdown",
"id": "bff23cac",
"metadata": {},
"source": [
"The QSwitch only supports a single Ethernet connection at a time, so you can explicitly tell Python to let go of the connection:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "44bac656",
"metadata": {},
"outputs": [],
"source": [
"qswitch.close()"
]
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 89db840

Please sign in to comment.