{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Qcodes example for Vaunix LDA step attenuator" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2019-03-04T16:30:18.954636Z", "start_time": "2019-03-04T16:30:17.404651Z" } }, "outputs": [], "source": [ "from qcodes_contrib_drivers.drivers.Vaunix.LDA import Vaunix_LDA\n", "import qcodes as qc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initialize the instrument\n", "The DLL that comes with the instrument, `` VNX_atten64.dll`` and/or `` VNX_atten.dll``, for 64-bit Windows and 32-bit Windows, respectively, should be found in ``dll_path``." ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "ExecuteTime": { "end_time": "2019-03-04T16:30:25.194573Z", "start_time": "2019-03-04T16:30:20.054625Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to: Vaunix LDA-102 (serial:55102, firmware:529) in 0.00s\n", "LDA:\n", "\tparameter value\n", "--------------------------------------------------------------------------------\n", "IDN :\t{'vendor': 'Vaunix', 'model': 'LDA-102', 'serial': 55102,...\n", "attenuation :\t25 (dB)\n", "working_frequency :\t6300000000 (Hz)\n" ] } ], "source": [ "dll_path = r\"C:\\Vaunix\"\n", "serial_num = 55102 # Serial number that works with the test_mode=True, does not require device connection.\n", "\n", "qc.Instrument.close_all()\n", "attenuator = Vaunix_LDA(\"LDA\", serial_num, dll_path=dll_path, test_mode=True)\n", "attenuator.print_readable_snapshot(update=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Set parameters\n", "The parameters are accessible as `attenuator.attenuation` (and `attenuator.working_frequncy`, if supported by model)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "ExecuteTime": { "end_time": "2019-03-04T16:30:27.544550Z", "start_time": "2019-03-04T16:30:27.504550Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Set to 50.0 dB\n" ] } ], "source": [ "attenuator.attenuation(50)\n", "print(\"Set to\", attenuator.attenuation(), \"dB\")\n", "#attenuator.working_frequency()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Save settings\n", "Optionally, save current settings. They will be loaded when the devices is powered on." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "attenuator.save_settings()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Close instrument" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2019-03-04T16:30:36.334462Z", "start_time": "2019-03-04T16:30:35.794467Z" } }, "outputs": [], "source": [ "attenuator.close()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Model with many channels" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the device model has many channels, the parameters are accessible as `attenuator.ch1.attenuation` etc. The name `ch#` can be overridden by supplying a dict of names at initialization." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "ExecuteTime": { "end_time": "2019-03-04T16:30:25.194573Z", "start_time": "2019-03-04T16:30:20.054625Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to: Vaunix LDA-802Q (serial:23160, firmware:529) in 0.21s\n" ] } ], "source": [ "serial_num = 23160\n", "\n", "qc.Instrument.close_all()\n", "attenuator = Vaunix_LDA(\"LDA\", serial_num,\n", " channel_names={1: \"main_port\", 3: \"test_port\"}, # name channels 1 and 3\n", " test_mode=False)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "ExecuteTime": { "end_time": "2019-03-04T16:30:31.604509Z", "start_time": "2019-03-04T16:30:31.584509Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Channel 1 attenuation set to 25.0 dB\n", "Channel 1 wf set to 6300000000 Hz\n", "Channel 2 attenuation set to 25.0 dB\n" ] } ], "source": [ "attenuator.main_port.attenuation(25)\n", "attenuator.main_port.working_frequency(6.3e9)\n", "\n", "attenuator.ch2.attenuation(2.2)\n", "\n", "print(\"Channel\", attenuator.main_port.channel_number, \"attenuation set to\", attenuator.main_port.attenuation(), \"dB\")\n", "print(\"Channel\", attenuator.main_port.channel_number, \"wf set to\", attenuator.main_port.working_frequency(), \"Hz\")\n", "print(\"Channel\", attenuator.ch2.channel_number, \"attenuation set to\", attenuator.main_port.attenuation(), \"dB\")" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "ExecuteTime": { "end_time": "2019-03-04T16:30:32.514500Z", "start_time": "2019-03-04T16:30:32.484500Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "LDA:\n", "\tparameter value\n", "--------------------------------------------------------------------------------\n", "IDN :\t{'vendor': 'Vaunix', 'model': 'LDA-802Q', 'serial': 23160, 'firmware': ...\n", "LDA_main_port:\n", "\tparameter value\n", "--------------------------------------------------------------------------------\n", "attenuation :\t25 (dB)\n", "working_frequency :\t6300000000 (Hz)\n", "LDA_ch2:\n", "\tparameter value\n", "--------------------------------------------------------------------------------\n", "attenuation :\t2.2 (dB)\n", "working_frequency :\t200000000 (Hz)\n", "LDA_test_port:\n", "\tparameter value\n", "--------------------------------------------------------------------------------\n", "attenuation :\t0 (dB)\n", "working_frequency :\t200000000 (Hz)\n", "LDA_ch4:\n", "\tparameter value\n", "--------------------------------------------------------------------------------\n", "attenuation :\t30 (dB)\n", "working_frequency :\t6000000000 (Hz)\n" ] } ], "source": [ "attenuator.print_readable_snapshot(update=True)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "attenuator.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "hide_input": false, "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.3" }, "nbsphinx": { "execute": "never" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }