{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# QCoDeS Example with Ithaco" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Logging hadn't been started.\n", "Activating auto-logging. Current session state plus future input saved.\n", "Filename : C:\\Users\\Jens-Work\\.qcodes\\logs\\command_history.log\n", "Mode : append\n", "Output logging : True\n", "Raw input log : False\n", "Timestamping : True\n", "State : active\n", "Qcodes Logfile : C:\\Users\\Jens-Work\\.qcodes\\logs\\201006-17520-qcodes.log\n" ] } ], "source": [ "# %matplotlib nbagg\n", "%gui qt \n", "import matplotlib.pyplot as plt\n", "import time\n", "import numpy as np\n", "\n", "import qcodes as qc\n", "from qcodes.utils.validators import Enum, Strings\n", "import qcodes.instrument_drivers.tektronix.Keithley_2600_channels as keith\n", "import qcodes.instrument_drivers.agilent.Agilent_34400A as agi\n", "import qcodes.instrument_drivers.ithaco.Ithaco_1211 as ithaco\n", "\n", "from qcodes.instrument.parameter import Parameter\n", "\n", "from qcodes.plots.pyqtgraph import QtPlot\n", "from qcodes.loops import Loop" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import time\n", "class Timer(object):\n", " def __init__(self, name=None):\n", " self.name = name\n", "\n", " def __enter__(self):\n", " self.tstart = time.time()\n", "\n", " def __exit__(self, type, value, traceback):\n", " if self.name:\n", " print('[%s]' % self.name,)\n", " print('Elapsed: %s' % (time.time() - self.tstart))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# create Instruments\n", "k1 = keith.Keithley_2600('Keithley1', 'GPIB0::15::INSTR')\n", "\n", "a1 = agi.Agilent_34400A('Agilent1', 'GPIB0::11::INSTR')\n", "a2 = agi.Agilent_34400A('Agilent2', 'GPIB0::6::INSTR')\n", "\n", "camp = ithaco.Ithaco_1211('camp1')\n", "camp.sens.set(1e-4)\n", "\n", "curr = ithaco.CurrentParameter(a2.volt, camp)\n", "\n", "# set integration time (number of line cycles)\n", "a1.NPLC.set(1)\n", "a2.NPLC.set(1)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'functions': {},\n", " 'metadata': {'info': {'model': '1211',\n", " 'serial_number': None,\n", " 'software_revision': None,\n", " 'vendor': 'Ithaco (DL Instruments)'}},\n", " 'parameters': {'invert': {'ts': '2016-04-21 15:56:06', 'value': True},\n", " 'risetime': {'ts': '2016-04-21 15:56:06', 'value': 0.3},\n", " 'sens': {'ts': '2016-04-21 15:56:06', 'value': 0.0001},\n", " 'sens_x': {'ts': '2016-04-21 15:56:06', 'value': 1},\n", " 'suppression': {'ts': '2016-04-21 15:56:06', 'value': 1e-07}}}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "camp.snapshot()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'V'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a2.volt.units" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('V', 'A')" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "curr.units" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "DataSet: DataMode.PULL_FROM_SERVER, location='testsweep'\n", " current: current\n", " volt: volt\n", " volt_set: volt\n", "started at 2016-04-21 15:56:10\n" ] } ], "source": [ "data = Loop(k1.a.volt[-5:5:1], 0).each(curr).run(location='testsweep', overwrite=True)\n", "plotQ = QtPlot(data.current,windowTitle='YEAH')" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plotQ" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'current': DataArray[10]: current\n", " array([ -4.98941000e-04, -3.99618000e-04, -3.00370000e-04,\n", " -2.01084000e-04, -1.01763000e-04, -2.42637000e-06,\n", " 9.69014000e-05, 1.96216000e-04, 2.95535000e-04,\n", " 3.94851000e-04]), 'volt': DataArray[10]: volt\n", " array([ 4.98941 , 3.99618 , 3.0037 , 2.01084 , 1.01763 ,\n", " 0.0242637, -0.969014 , -1.96216 , -2.95535 , -3.94851 ]), 'volt_set': DataArray[10]: volt_set\n", " array([-5., -4., -3., -2., -1., 0., 1., 2., 3., 4.])}" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.sync()\n", "data.arrays" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "station1 = qc.Station(a1,a2)\n", "station1.set_measurement(a1.volt)\n", "station2 = qc.Station(a1,a2)\n", "station2.set_measurement(a1.volt, a2.volt)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Time s1]\n", "Elapsed: 0.05600309371948242\n", "[Time s2]\n", "Elapsed: 0.10500597953796387\n" ] } ], "source": [ "# Time single readings\n", "with Timer('Time s1'):\n", " station1.measure()\n", "with Timer('Time s2'):\n", " station2.measure()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Time a1]\n", "Elapsed: 0.05600309371948242\n", "[Time a2]\n", "Elapsed: 0.049002885818481445\n" ] } ], "source": [ "# Time single readings\n", "with Timer('Time a1'):\n", " a1.volt.get()\n", "with Timer('Time a2'):\n", " a2.volt.get()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "DataSet: DataMode.PUSH_TO_SERVER, location='testsweep'\n", " volt_set: volt\n", " volt: volt\n", "started at 2016-04-21 15:51:15\n", "[Time Loop 1]\n", "Elapsed: 0.5770328044891357\n", "DataSet: DataMode.PUSH_TO_SERVER, location='testsweep'\n", " volt_set: volt\n", " volt_0: volt\n", " volt_1: volt\n", "started at 2016-04-21 15:51:16\n", "[Time Loop 2]\n", "Elapsed: 1.0900623798370361\n" ] } ], "source": [ "with Timer('Time Loop 1'):\n", " data = Loop(k1.a.volt[-5:5:1], 0).each(a1.volt).run(location='testsweep', overwrite=True,background=False)\n", "\n", "with Timer('Time Loop 2'):\n", " data = Loop(k1.a.volt[-5:5:1], 0).each(a1.volt, a2.volt).run(location='testsweep', overwrite=True,background=False)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "DataSet: DataMode.PULL_FROM_SERVER, location='testsweep'\n", " volt_set: volt\n", " volt: volt\n", "started at 2016-04-21 15:51:16\n", "[Time Loop 1]\n", "Elapsed: 1.075061559677124\n" ] } ], "source": [ "with Timer('Time Loop 1'):\n", " data = Loop(k1.a.volt[-5:5:1], 0).each(a1.volt).run(location='testsweep', overwrite=True)\n", " while data.sync():\n", " time.sleep(0.1)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "DataSet: DataMode.PULL_FROM_SERVER, location='testsweep'\n", " volt_set: volt\n", " volt_0: volt\n", " volt_1: volt\n", "started at 2016-04-21 15:51:17\n", "[Time Loop 2]\n", "Elapsed: 1.569089651107788\n" ] } ], "source": [ "with Timer('Time Loop 2'):\n", " data = Loop(k1.a.volt[-5:5:1], 0).each(a1.volt, a2.volt).run(location='testsweep', overwrite=True)\n", " while data.sync():\n", " time.sleep(0.1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "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.9" }, "nbsphinx": { "execute": "never" } }, "nbformat": 4, "nbformat_minor": 1 }