Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minicircuits 4SPDT driver fix for .NET 4.5+ versions #4623

Merged
merged 7 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes/newsfragments/4623.improved_driver
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Minicircuits USB SPDT driver now supports running with the more modern version of the driver DLL `mcl_RF_Switch_Controller_NET45.dll`
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"change the serial number to the serial number on the sticker on the back of the device, or leave it blank if there is only one switch box connected\n",
"\n",
"The driver_path should specify the url of the dll for controlling the instrument. You can find it here:\n",
"\n",
"https://ww2.minicircuits.com/softwaredownload/rfswitchcontroller.html\n",
"https://www.minicircuits.com/softwaredownload/rfswitchcontroller.html\n",
"\n",
"Download .NET dll and save somewhere. Unblock it (right click properties) and specify the path."
"Download .NET dll and save somewhere. Unblock it (right click properties) and specify the path.\n",
"\n",
"The downloaded ZIP file contains two DLLs. We recommend using mcl_RF_Switch_Controller_NET45.dll\n",
"which supports the most recent .net versions. "
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -45,7 +49,7 @@
"source": [
"dev = USB_SPDT('test',\n",
" serial_number='11703020018',\n",
" driver_path= r'C:\\Users\\a-dovoge\\Qcodes\\qcodes\\instrument_drivers\\Minicircuits\\mcl_RF_Switch_Controller64')"
" driver_path= r'C:\\Users\\a-dovoge\\Qcodes\\qcodes\\instrument_drivers\\Minicircuits\\mcl_RF_Switch_Controller_NET45')"
]
},
{
Expand Down Expand Up @@ -117,7 +121,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "qcodespip310",
"language": "python",
"name": "python3"
},
Expand All @@ -131,10 +135,15 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.10.8 | packaged by conda-forge | (main, Nov 24 2022, 14:07:00) [MSC v.1916 64 bit (AMD64)]"
},
"nbsphinx": {
"execute": "never"
},
"vscode": {
"interpreter": {
"hash": "2643ef1ecb4e72f15331668d402315679b29a004e65b7ec963f6cfe589581b49"
}
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ module = [
"lomentum.tools",
"matplotlib.*",
"mcl_RF_Switch_Controller64",
"mcl_RF_Switch_Controller_NET45",
"opencensus.ext.azure.*",
"pythoncom",
"pyqtgraph.*",
Expand Down
22 changes: 15 additions & 7 deletions qcodes/instrument_drivers/Minicircuits/USB_SPDT.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class USB_SPDT(SPDT_Base):
"""

CHANNEL_CLASS = SwitchChannelUSB
PATH_TO_DRIVER = r'mcl_RF_Switch_Controller64'
PATH_TO_DRIVER = r"mcl_RF_Switch_Controller64"
PATH_TO_DRIVER_45 = r"mcl_RF_Switch_Controller_NET45"

def __init__(self, name: str, driver_path: Optional[str] = None,
serial_number: Optional[str] = None, **kwargs: Any):
Expand All @@ -57,19 +58,26 @@ def __init__(self, name: str, driver_path: Optional[str] = None,
raise ImportError("""This driver only works in Windows.""")
try:
if driver_path is None:
clr.AddReference(self.PATH_TO_DRIVER)
try:
clr.AddReference(self.PATH_TO_DRIVER)
except FileNotFoundError:
clr.AddReference(self.PATH_TO_DRIVER_45)
else:
clr.AddReference(driver_path)

except (ImportError, FileNotFoundException):
raise ImportError(
"""Load of mcl_RF_Switch_Controller64.dll not possible. Make sure
the dll file is not blocked by Windows. To unblock right-click
the dll to open properties and check the 'unblock' checkmark
"""Load of mcl_RF_Switch_Controller64.dll or mcl_RF_Switch_Controller_NET45.dll
not possible. Make sure the dll file is not blocked by Windows.
To unblock right-click the dll to open properties and check the 'unblock' checkmark
in the bottom. Check that your python installation is 64bit."""
)
import mcl_RF_Switch_Controller64 # pyright: ignore[reportMissingImports]
self.switch = mcl_RF_Switch_Controller64.USB_RF_SwitchBox()
try:
import mcl_RF_Switch_Controller64 as mw_driver # pyright: ignore[reportMissingImports]
except ImportError:
import mcl_RF_Switch_Controller_NET45 as mw_driver # pyright: ignore[reportMissingImports]

self.switch = mw_driver.USB_RF_SwitchBox()
jenshnielsen marked this conversation as resolved.
Show resolved Hide resolved

if not self.switch.Connect(serial_number):
raise RuntimeError('Could not connect to device')
Expand Down