diff --git a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb
index 02c96877115..472c31a512d 100644
--- a/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb
+++ b/docs/examples/driver_examples/Qcodes example with ZI UHF-LI.ipynb
@@ -51,11 +51,20 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 2,
"metadata": {
"scrolled": false
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "c:\\users\\qcodes-jhn\\src\\qcodes\\qcodes\\instrument\\parameter.py:207: UserWarning: Wrapping get method, original get method will not be directly accessible. It is recommended to define get_raw in your subclass instead.\n",
+ " warnings.warn('Wrapping get method, original get method will not '\n"
+ ]
+ }
+ ],
"source": [
"# Instantiate the QCoDeS instrument\n",
"zi = ZIUHFLI('ZIUHFLI', 'dev2235')\n",
@@ -75,7 +84,7 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -102,7 +111,7 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -111,11 +120,11 @@
"text": [
"Available signal input settings:\n",
"\n",
+ " signal_input1_range, Input range (V)\n",
+ " signal_input1_scaling, Input scaling ()\n",
" signal_input1_AC, AC coupling ()\n",
" signal_input1_impedance, Input impedance ()\n",
- " signal_input1_scaling, Input scaling ()\n",
- " signal_input1_diff, Input signal subtraction ()\n",
- " signal_input1_range, Input range (V)\n"
+ " signal_input1_diff, Input signal subtraction ()\n"
]
}
],
@@ -143,15 +152,20 @@
"text": [
"Available demodulator settings:\n",
"\n",
- " demod1_streaming, Data streaming ()\n",
+ " demod1_order, Filter order ()\n",
+ " demod1_harmonic, Reference frequency multiplication factor ()\n",
" demod1_timeconstant, Filter time constant (s)\n",
" demod1_samplerate, Sample rate (Sa/s)\n",
" demod1_phaseshift, Phase shift (degrees)\n",
- " demod1_sinc, Sinc filter ()\n",
- " demod1_harmonic, Reference frequency multiplication factor ()\n",
" demod1_signalin, Signal input ()\n",
- " demod1_order, Filter order ()\n",
- " demod1_trigger, Trigger ()\n"
+ " demod1_sinc, Sinc filter ()\n",
+ " demod1_streaming, Data streaming ()\n",
+ " demod1_trigger, Trigger ()\n",
+ " demod1_sample, Demod sample ()\n",
+ " demod1_x, Demod 1 x (v)\n",
+ " demod1_y, Demod 1 y (v)\n",
+ " demod1_R, Demod 1 R (v)\n",
+ " demod1_phi, Demod 1 phi (deg)\n"
]
}
],
@@ -179,14 +193,14 @@
"text": [
"Available signal output settings:\n",
"\n",
- " signal_output1_enable, Enable signal output's amplitude. ()\n",
- " signal_output1_offset, Signal output offset (V)\n",
- " signal_output1_imp50, Switch to turn on 50 Ohm impedance ()\n",
" signal_output1_on, Turn signal output on and off. ()\n",
+ " signal_output1_imp50, Switch to turn on 50 Ohm impedance ()\n",
+ " signal_output1_amplitude, Signal output amplitude (V)\n",
+ " signal_output1_ampdef, Signal output amplitude's definition (V)\n",
" signal_output1_range, Signal output range ()\n",
+ " signal_output1_offset, Signal output offset (V)\n",
" signal_output1_autorange, Enable signal output range. ()\n",
- " signal_output1_ampdef, Signal output amplitude's definition (V)\n",
- " signal_output1_amplitude, Signal output amplitude (V)\n"
+ " signal_output1_enable, Enable signal output's amplitude. ()\n"
]
}
],
@@ -269,9 +283,7 @@
{
"cell_type": "code",
"execution_count": 9,
- "metadata": {
- "collapsed": true
- },
+ "metadata": {},
"outputs": [],
"source": [
"# Add three signals to the sweep, all measured on demodulator 1\n",
@@ -307,7 +319,7 @@
" Minimal no. of samples to average at each sweep point: 25 ()\n",
" Minimal averaging time: 0.1 (s)\n",
" Minimal settling time for the sweeper: 1e-06 (s)\n",
- " Sweep filter settling time: 4.605170185988091 (dim. less.)\n",
+ " Sweep filter settling time: 4.605170185988091 ()\n",
"HORISONTAL\n",
" Start value of the sweep: 1000000.0\n",
" Stop value of the sweep: 10000000.0\n",
@@ -321,11 +333,11 @@
" Signal 2: Demodulator 1: Yrms\n",
" Signal 3: Demodulator 1: Rrms\n",
"DEMODULATORS\n",
- " Demodulator 1: Filter time constant: 0.000311 (s)\n",
+ " Demodulator 1: Filter time constant: 0.000981 (s)\n",
" Demodulator 1: Filter order: 4.000000 ()\n",
- " Demodulator 1: Sample rate: 1716.613770 (Sa/s)\n",
+ " Demodulator 1: Sample rate: 858.306885 (Sa/s)\n",
"META\n",
- " Expected sweep time: 0.9 (s)\n",
+ " Expected sweep time: 1.3 (s)\n",
" Sweep timeout: 600 (s)\n",
" Sweep built and ready to execute: False\n"
]
@@ -347,12 +359,12 @@
"text": [
"ACQUISITION\n",
" Sweeper bandwidth control mode: fixed ()\n",
- " Fixed bandwidth sweeper bandwidth (NEP): 250.0 ()\n",
+ " Fixed bandwidth sweeper bandwidth (NEP): 78.12499999999996 ()\n",
" Sweeper filter order: 4 ()\n",
" Minimal no. of samples to average at each sweep point: 25 ()\n",
" Minimal averaging time: 0.1 (s)\n",
" Minimal settling time for the sweeper: 1e-06 (s)\n",
- " Sweep filter settling time: 9.998049677807453 (dim. less.)\n",
+ " Sweep filter settling time: 9.998049677807453 ()\n",
"HORISONTAL\n",
" Start value of the sweep: 1000000.0\n",
" Stop value of the sweep: 10000000.0\n",
@@ -366,11 +378,11 @@
" Signal 2: Demodulator 1: Yrms\n",
" Signal 3: Demodulator 1: Rrms\n",
"DEMODULATORS\n",
- " Demodulator 1: Filter time constant: 0.000311 (s)\n",
+ " Demodulator 1: Filter time constant: 0.000981 (s)\n",
" Demodulator 1: Filter order: 4.000000 ()\n",
- " Demodulator 1: Sample rate: 1716.613770 (Sa/s)\n",
+ " Demodulator 1: Sample rate: 858.306885 (Sa/s)\n",
"META\n",
- " Expected sweep time: 1.8 (s)\n",
+ " Expected sweep time: 3.9 (s)\n",
" Sweep timeout: 600 (s)\n",
" Sweep built and ready to execute: True\n"
]
@@ -481,7 +493,7 @@
" };\n",
"\n",
" this.imageObj.onunload = function() {\n",
- " this.ws.close();\n",
+ " fig.ws.close();\n",
" }\n",
"\n",
" this.ws.onmessage = this._make_on_message_function(this);\n",
@@ -1128,9 +1140,12 @@
" // Check for shift+enter\n",
" if (event.shiftKey && event.which == 13) {\n",
" this.canvas_div.blur();\n",
- " // select the cell after this one\n",
- " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
- " IPython.notebook.select(index + 1);\n",
+ " event.shiftKey = false;\n",
+ " // Send a \"J\" for go to next cell\n",
+ " event.which = 74;\n",
+ " event.keyCode = 74;\n",
+ " manager.command_mode();\n",
+ " manager.handle_keydown(event);\n",
" }\n",
"}\n",
"\n",
@@ -1179,7 +1194,7 @@
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -1191,7 +1206,7 @@
{
"data": {
"text/plain": [
- "[]"
+ "[]"
]
},
"execution_count": 14,
@@ -1259,7 +1274,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 15,
"metadata": {},
"outputs": [
{
@@ -1307,7 +1322,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
@@ -1329,9 +1344,9 @@
"zi.scope_trig_enable.set('ON')\n",
"zi.scope_trig_signal.set('Signal Input 2')\n",
"zi.scope_trig_slope.set('Rise')\n",
- "zi.scope_trig_level.set(20e-3) # Volts if the input is volts\n",
+ "zi.scope_trig_level.set(20e-6) # Volts if the input is volts\n",
"zi.scope_trig_hystmode.set('absolute')\n",
- "zi.scope_trig_hystabsolute.set(3e-3) # Volts if the input is volts\n",
+ "zi.scope_trig_hystabsolute.set(3e-6) # Volts if the input is volts\n",
"zi.scope_trig_gating_enable.set('OFF')\n",
"zi.scope_trig_gating_source.set('Trigger In 4 Low')\n",
"zi.scope_trig_holdoffmode.set('s') # QCoDeS currently does not support a holdoff in events. Ask William why. \n",
@@ -1345,7 +1360,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 19,
"metadata": {},
"outputs": [
{
@@ -1373,7 +1388,7 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 20,
"metadata": {},
"outputs": [
{
@@ -1458,7 +1473,7 @@
" };\n",
"\n",
" this.imageObj.onunload = function() {\n",
- " this.ws.close();\n",
+ " fig.ws.close();\n",
" }\n",
"\n",
" this.ws.onmessage = this._make_on_message_function(this);\n",
@@ -2105,9 +2120,12 @@
" // Check for shift+enter\n",
" if (event.shiftKey && event.which == 13) {\n",
" this.canvas_div.blur();\n",
- " // select the cell after this one\n",
- " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
- " IPython.notebook.select(index + 1);\n",
+ " event.shiftKey = false;\n",
+ " // Send a \"J\" for go to next cell\n",
+ " event.which = 74;\n",
+ " event.keyCode = 74;\n",
+ " manager.command_mode();\n",
+ " manager.handle_keydown(event);\n",
" }\n",
"}\n",
"\n",
@@ -2156,7 +2174,7 @@
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -2247,7 +2265,7 @@
" };\n",
"\n",
" this.imageObj.onunload = function() {\n",
- " this.ws.close();\n",
+ " fig.ws.close();\n",
" }\n",
"\n",
" this.ws.onmessage = this._make_on_message_function(this);\n",
@@ -2894,9 +2912,12 @@
" // Check for shift+enter\n",
" if (event.shiftKey && event.which == 13) {\n",
" this.canvas_div.blur();\n",
- " // select the cell after this one\n",
- " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
- " IPython.notebook.select(index + 1);\n",
+ " event.shiftKey = false;\n",
+ " // Send a \"J\" for go to next cell\n",
+ " event.which = 74;\n",
+ " event.keyCode = 74;\n",
+ " manager.command_mode();\n",
+ " manager.handle_keydown(event);\n",
" }\n",
"}\n",
"\n",
@@ -2945,7 +2966,7 @@
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
""
@@ -2995,25 +3016,100 @@
"scopedata = qc.Measure(zi.Scope).run()"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Individual demodulated samples"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "It is also possible to get individual demodulated samples. This is useful as it can be wrapped in a loop. \n",
+ "It's unlikely to be the fastest way but it is very flexible.\n",
+ "These samples can be acquired from all 8 demodulators"
+ ]
+ },
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 21,
"metadata": {},
"outputs": [
{
- "ename": "RuntimeError",
- "evalue": "ZIAPINotFoundException with status code: 16387. Value or Node not found",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mzi\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdaq\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetDouble\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'/dev2235/demods/0/value'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;31mRuntimeError\u001b[0m: ZIAPINotFoundException with status code: 16387. Value or Node not found"
- ]
+ "data": {
+ "text/plain": [
+ "array([ 9.23160746e-07])"
+ ]
+ },
+ "execution_count": 21,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "zi.demod1_x()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([ 1.24196735e-06])"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "zi.demod1_y()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([ 1.39759855e-06])"
+ ]
+ },
+ "execution_count": 22,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "zi.demod1_R()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([ 116.36020379])"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
- "zi.daq.getDouble('/dev2235/demods/0/value')"
+ "zi.demod1_phi()"
]
},
{
@@ -3045,7 +3141,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.5.3"
+ "version": "3.6.3"
}
},
"nbformat": 4,
diff --git a/qcodes/instrument_drivers/ZI/ZIUHFLI.py b/qcodes/instrument_drivers/ZI/ZIUHFLI.py
index 1be926bda8d..9312c1c87c7 100644
--- a/qcodes/instrument_drivers/ZI/ZIUHFLI.py
+++ b/qcodes/instrument_drivers/ZI/ZIUHFLI.py
@@ -2,6 +2,7 @@
import logging
import numpy as np
from functools import partial
+from typing import Union
try:
import zhinst.utils
except ImportError:
@@ -548,15 +549,13 @@ class ZIUHFLI(Instrument):
* Add zoom-FFT
"""
- def __init__(self, name, device_ID, **kwargs):
+ def __init__(self, name: str, device_ID: str, **kwargs) -> None:
"""
Create an instance of the instrument.
Args:
name (str): The internal QCoDeS name of the instrument
device_ID (str): The device name as listed in the web server.
- api_level (int): Compatibility mode of the API interface. Must be 5
- for the UHF.
"""
super().__init__(name, **kwargs)
@@ -711,6 +710,26 @@ def __init__(self, name, device_ID, **kwargs):
vals=vals.Enum(*list(dmtrigs.keys()))
)
+ self.add_parameter('demod{}_sample'.format(demod),
+ label='Demod sample',
+ get_cmd=partial(self._getter, 'demods',
+ demod - 1, 2, 'sample'),
+ snapshot_value=False
+ )
+
+ for demod_param in ['x', 'y', 'R', 'phi']:
+ if demod_param in ('x', 'y', 'R'):
+ unit = 'V'
+ else:
+ unit = 'deg'
+ self.add_parameter('demod{}_{}'.format(demod, demod_param),
+ label='Demod {} {}'.format(demod, demod_param),
+ get_cmd=partial(self._get_demod_sample,
+ demod - 1, demod_param),
+ snapshot_value=False,
+ unit=unit
+ )
+
########################################
# SIGNAL INPUTS
@@ -1440,7 +1459,8 @@ def _setter(self, module, number, mode, setting, value):
if mode == 1:
self.daq.setDouble(setstr, value)
- def _getter(self, module, number, mode, setting):
+ def _getter(self, module: str, number: int,
+ mode: int, setting: str) -> Union[float, int, str, dict]:
"""
General get function for generic parameters. Note that some parameters
use more specialised setter/getters.
@@ -1453,7 +1473,7 @@ def _getter(self, module, number, mode, setting):
we want to know the value of.
number (int): Module's index
mode (int): Indicating whether we are asking for an int or double.
- 0: Int, 1: double.
+ 0: Int, 1: double, 2: Sample
setting (str): The module's setting to set.
returns:
inquered value
@@ -1461,14 +1481,30 @@ def _getter(self, module, number, mode, setting):
"""
querystr = '/{}/{}/{}/{}'.format(self.device, module, number, setting)
+ log.debug("getting %s", querystr)
if mode == 0:
value = self.daq.getInt(querystr)
- if mode == 1:
+ elif mode == 1:
value = self.daq.getDouble(querystr)
-
+ elif mode == 2:
+ value = self.daq.getSample(querystr)
+ else:
+ raise RuntimeError("Invalid mode supplied")
# Weird exception, samplingrate returns a string
return value
+ def _get_demod_sample(self, number: int, demod_param: str) -> float:
+ log.debug("getting demod %s param %s", number, demod_param)
+ mode = 2
+ module = 'demods'
+ setting = 'sample'
+ if demod_param not in ['x', 'y', 'R', 'phi']:
+ raise RuntimeError("Invalid demodulator parameter")
+ datadict = self._getter(module, number, mode, setting)
+ datadict['R'] = np.abs(datadict['x'] + 1j * datadict['y'])
+ datadict['phi'] = np.angle(datadict['x'] + 1j * datadict['y'], deg=True)
+ return datadict[demod_param]
+
def _sigout_setter(self, number, mode, setting, value):
"""
Function to set signal output's settings. A specific setter function is
@@ -1787,7 +1823,7 @@ def add_signal_to_sweeper(self, demodulator, attribute):
raise ValueError('Can not select attribute:'+
'{}. Only the following attributes are' +
' available: ' +
- ('{}, '*len(attributes)).format(*attributes))
+ ('{}, '*len(valid_attributes)).format(*valid_attributes))
# internally, we use strings very similar to the ones used by the
# instrument, but with the attribute added, e.g.