{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ScaledParameter\n", "Sometimes the values that we set/get on the computer are not the physical value that reach/originate from the sample. The ScaledParameter can be used to convert quantities with a simple linear relationship without offset." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from qcodes.parameters import ManualParameter, ScaledParameter" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "dac0 = ManualParameter('dac0', unit = 'V')\n", "dac1 = ManualParameter('dac1', unit = 'V')\n", "amplitude = ManualParameter('amplitude', initial_value=3.14, unit = 'V')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Resistive voltage divider\n", "The simplest case is a resistive divider, where the set voltage is divided by a fixed amount." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "vd = ScaledParameter(dac0, division = 10)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "vd(10)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Vd = 10.0 V , real setted value = 100 V\n" ] } ], "source": [ "print('Vd =',vd(), vd.unit,', real setted value =', dac0(), dac0.unit)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Voltage multiplier\n", "If the voltage is amplified, we can specify a `gain` value instead of `division`." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "vb = ScaledParameter(dac1, gain = 30, name = 'Vb')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "vb(5)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Vb = 10.0 V , Original_value = 0.16666666666666666 V\n" ] } ], "source": [ "print('Vb =',vd(), vb.unit,', Original_value =', dac1(), dac1.unit)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Transimpedance amplifier\n", "The ScaledParameter can be used also for quantities that are read, like a current read by a transimpedance amplifier, digitized by a multimeter.\n", "We can also specify a different unit from the wrapped parameter. The semantic of gain/division is inverted compared to the previous cases, since it is a value that we read." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "Id = ScaledParameter(amplitude, division = 1e6, name = 'Id', unit = 'A')" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Id = 3.14e-06 A , Read_value = 3.14 V\n" ] } ], "source": [ "print('Id =',Id(), Id.unit,', Read_value =', amplitude(), amplitude.unit)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The gain can be manually changed at any time" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Id = 3.14e-08 A , Read_value = 3.14 V\n" ] } ], "source": [ "Id.division = 1e8\n", "print('Id =',Id(), Id.unit,', Read_value =', amplitude(), amplitude.unit)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The gain/division can be itself a Qcodes paramter, for example if is a gain set by a remote instrument" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "remote_gain = ManualParameter('remote_gain', initial_value=1e6, unit = 'V/A')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Id = 3.14e-06 A , Read_value = 3.14 V\n" ] } ], "source": [ "Id.division = remote_gain\n", "print('Id =',Id(), Id.unit,', Read_value =', amplitude(), amplitude.unit)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Id = 3.14e-08 A , Read_value = 3.14 V\n" ] } ], "source": [ "remote_gain(1e8)\n", "print('Id =',Id(), Id.unit,', Read_value =', amplitude(), amplitude.unit)" ] } ], "metadata": { "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.4" }, "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": 2 }