forked from microsoft/Qcodes
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Benchmark - Keysight DMM software trigger (#729)
* feat: add error parameter to DMM * feat: add flush_error_queue function * feat: add working flush error queue function * docs: Add a benchmark for the Keysight 34465A
- Loading branch information
1 parent
06fdbae
commit 0782c6f
Showing
2 changed files
with
350 additions
and
0 deletions.
There are no files selected for viewing
303 changes: 303 additions & 0 deletions
303
docs/examples/benchmarking/Benchmark of Keysight DMM software trigger vs set-get.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,303 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Benchmark of Keysight 34465A\n", | ||
"\n", | ||
"We benchmark the acquisition of N voltages from a QDac on a Keysight DMM. Two acquisition modes are tested; the \"classical\" set voltage/get voltage and a set voltage / send software trigger method.\n", | ||
"\n", | ||
"The former method is cast as a standard QCoDeS measurement, whereas the latter is just the raw commands. If anything, this should add a bit of extra overhead to the first method.\n", | ||
"\n", | ||
"The QDac sweeps a voltage from 0 V to 1 V.\n", | ||
"\n", | ||
"Conclusion: <span style=\"color:red\">there is **no** speed-up</span>." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import qcodes as qc\n", | ||
"import numpy as np\n", | ||
"import time\n", | ||
"from qcodes.instrument_drivers.Keysight.Keysight_34465A import Keysight_34465A\n", | ||
"from qcodes.instrument_drivers.QDev.QDac import QDac" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Connected to: Keysight Technologies 34465A (serial:MY54505281, firmware:A.02.14-02.40-02.14-00.49-02-01) in 7.14s\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"dmm = Keysight_34465A('dmm', 'TCPIP0::K-000000-00000.local::hislip0::INSTR')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"qdac = QDac('qdac', 'ASRL7::INSTR')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Pre-benchmark setting" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ap_time = 1e-3\n", | ||
"dmm.NPLC(0.06) # aperture time of 1 ms\n", | ||
"dmm.range(1) # Voltage range of 1 V\n", | ||
"qdac.ch01_v(0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## N = 1000, set-get" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# prepare the DMM for get-set mode\n", | ||
"dmm.trigger_source('IMM')\n", | ||
"dmm.sample_count(1)\n", | ||
"dmm.trigger_count(1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Started at 2017-09-08 11:33:51\n", | ||
"DataSet:\n", | ||
" location = 'data/2017-09-08/#013_N_1000_setget_11-33-51'\n", | ||
" <Type> | <array_id> | <array.name> | <array.shape>\n", | ||
" Setpoint | qdac_ch01_v_set | ch01_v | (1000,)\n", | ||
" Measured | dmm_volt | volt | (1000,)\n", | ||
"Finished at 2017-09-08 11:34:23\n", | ||
"Started at 2017-09-08 11:34:23\n", | ||
"DataSet:\n", | ||
" location = 'data/2017-09-08/#014_N_1000_setget_11-34-23'\n", | ||
" <Type> | <array_id> | <array.name> | <array.shape>\n", | ||
" Setpoint | qdac_ch01_v_set | ch01_v | (1000,)\n", | ||
" Measured | dmm_volt | volt | (1000,)\n", | ||
"Finished at 2017-09-08 11:34:55\n", | ||
"Started at 2017-09-08 11:34:55\n", | ||
"DataSet:\n", | ||
" location = 'data/2017-09-08/#015_N_1000_setget_11-34-55'\n", | ||
" <Type> | <array_id> | <array.name> | <array.shape>\n", | ||
" Setpoint | qdac_ch01_v_set | ch01_v | (1000,)\n", | ||
" Measured | dmm_volt | volt | (1000,)\n", | ||
"Finished at 2017-09-08 11:35:27\n", | ||
"Started at 2017-09-08 11:35:27\n", | ||
"DataSet:\n", | ||
" location = 'data/2017-09-08/#016_N_1000_setget_11-35-27'\n", | ||
" <Type> | <array_id> | <array.name> | <array.shape>\n", | ||
" Setpoint | qdac_ch01_v_set | ch01_v | (1000,)\n", | ||
" Measured | dmm_volt | volt | (1000,)\n", | ||
"Finished at 2017-09-08 11:35:59\n", | ||
"Started at 2017-09-08 11:35:59\n", | ||
"DataSet:\n", | ||
" location = 'data/2017-09-08/#017_N_1000_setget_11-35-59'\n", | ||
" <Type> | <array_id> | <array.name> | <array.shape>\n", | ||
" Setpoint | qdac_ch01_v_set | ch01_v | (1000,)\n", | ||
" Measured | dmm_volt | volt | (1000,)\n", | ||
"Finished at 2017-09-08 11:36:32\n", | ||
"Started at 2017-09-08 11:36:32\n", | ||
"DataSet:\n", | ||
" location = 'data/2017-09-08/#018_N_1000_setget_11-36-32'\n", | ||
" <Type> | <array_id> | <array.name> | <array.shape>\n", | ||
" Setpoint | qdac_ch01_v_set | ch01_v | (1000,)\n", | ||
" Measured | dmm_volt | volt | (1000,)\n", | ||
"Finished at 2017-09-08 11:37:04\n", | ||
"Started at 2017-09-08 11:37:04\n", | ||
"DataSet:\n", | ||
" location = 'data/2017-09-08/#019_N_1000_setget_11-37-04'\n", | ||
" <Type> | <array_id> | <array.name> | <array.shape>\n", | ||
" Setpoint | qdac_ch01_v_set | ch01_v | (1000,)\n", | ||
" Measured | dmm_volt | volt | (1000,)\n", | ||
"Finished at 2017-09-08 11:37:36\n", | ||
"Started at 2017-09-08 11:37:36\n", | ||
"DataSet:\n", | ||
" location = 'data/2017-09-08/#020_N_1000_setget_11-37-36'\n", | ||
" <Type> | <array_id> | <array.name> | <array.shape>\n", | ||
" Setpoint | qdac_ch01_v_set | ch01_v | (1000,)\n", | ||
" Measured | dmm_volt | volt | (1000,)\n", | ||
"Finished at 2017-09-08 11:38:08\n", | ||
"32.2 s ± 110 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%%timeit\n", | ||
"\n", | ||
"N = 1000\n", | ||
"\n", | ||
"# remember to turn off the display for better speed\n", | ||
"dmm.display_text('Running set-get for {} points'.format(N))\n", | ||
"\n", | ||
"loop = qc.Loop(qdac.ch01_v.sweep(0, 1, num=N)).each(dmm.volt)\n", | ||
"data = loop.get_data_set(name='N_{}_setget'.format(N))\n", | ||
"_ = loop.run() # run the loop\n", | ||
"\n", | ||
"dmm.display_clear()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## N = 1000, set-software triggered" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"def software_triggered_readings(N: int) -> np.array:\n", | ||
" \"\"\"\n", | ||
" Try to get N measurement points\n", | ||
" \"\"\"\n", | ||
" \n", | ||
" dmm.display_text('Sending {} software triggers'.format(N))\n", | ||
" \n", | ||
" dmm.trigger_source('BUS')\n", | ||
" dmm.sample_count(1) # samples per trigger\n", | ||
" dmm.trigger_count(N) # number of triggers to wait for\n", | ||
" dmm.init_measurement()\n", | ||
" \n", | ||
" qdac_setpoints = np.linspace(0, 1, N)\n", | ||
" \n", | ||
" for n in range(N):\n", | ||
" qdac.ch01_v(qdac_setpoints[n])\n", | ||
" dmm.write('*TRG')\n", | ||
" time.sleep(dmm.sample_timer_minimum()) # Wait to avoid losing triggers\n", | ||
" \n", | ||
" # even if we are losing triggers, can ABORt the measurement\n", | ||
" # and then fetch whatever data the DMM holds\n", | ||
" dmm.abort_measurement() \n", | ||
" raw_vals = dmm.ask('FETCH?')\n", | ||
" dmm.display_clear()\n", | ||
"\n", | ||
" numvals = np.array(list(map(float, raw_vals.split(','))))\n", | ||
" \n", | ||
" print('Requested {} samples, got {}.'.format(N, len(numvals)))\n", | ||
" \n", | ||
" return numvals" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Requested 1000 samples, got 1000.\n", | ||
"Requested 1000 samples, got 1000.\n", | ||
"Requested 1000 samples, got 1000.\n", | ||
"Requested 1000 samples, got 1000.\n", | ||
"Requested 1000 samples, got 1000.\n", | ||
"Requested 1000 samples, got 1000.\n", | ||
"Requested 1000 samples, got 1000.\n", | ||
"Requested 1000 samples, got 1000.\n", | ||
"32.2 s ± 387 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"%%timeit\n", | ||
"\n", | ||
"data = software_triggered_readings(1000)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Results summary\n", | ||
"\n", | ||
"**N = 1000**\n", | ||
"\n", | ||
"Standard set-get: 32.2 s\n", | ||
"\n", | ||
"Software triggered: 32.2 s" | ||
] | ||
}, | ||
{ | ||
"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.5.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters