Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/channelization with small cleanup #640

Merged
merged 63 commits into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
75c041a
Driver/Keysight DMM (#556)
WilliamHPNielsen Apr 4, 2017
fda0f8d
feat: Add channelization
spauka Apr 11, 2017
863fa19
feat: Add channelized Lakeshore Model336 Driver
spauka Apr 11, 2017
6914d9d
feat: Add a channelized driver for the Harvard DAC
spauka Apr 11, 2017
5827028
Merge branch 'master' into feat/channelization
spauka Apr 11, 2017
76af2a3
fix: bug in slicing and adding code
spauka Apr 11, 2017
4f36e59
style: fix formatting and make codacy fixes
spauka Apr 11, 2017
a793819
style: fix more code style issues
spauka Apr 11, 2017
db446e7
Merge remote-tracking branch 'refs/remotes/QCoDeS/master'
spauka May 30, 2017
5e1d23e
fix: flush is now handled correctly in instrument base class
spauka May 30, 2017
4ed3f4e
feat: Allow channellists to be excluded from snapshots
spauka May 30, 2017
3a728d4
fix: Allow snapshots of ChannelLists
spauka May 30, 2017
857e881
Merge branch 'master' into feat/channelization
spauka May 30, 2017
e5cda8b
style: remove force arg in snapshot_base
spauka May 30, 2017
f4172d2
style: remove unessecary import
spauka May 30, 2017
3aabf27
fix: error in type check.
spauka May 30, 2017
4a3e517
fix: submodules should be Metadatable
spauka May 30, 2017
703cc84
Start adding tests for channels
jenshnielsen May 30, 2017
1066eed
Extend tests
jenshnielsen May 30, 2017
8d5dbc8
Fix: ensure consistent dataset names regardless of chan[] or chanA re…
jenshnielsen Jun 1, 2017
f9e3b1f
More work on channels testing
jenshnielsen Jun 1, 2017
be7e8ae
Make sure that instument is closed in tests
jenshnielsen Jun 1, 2017
4a8d0ae
Depend on hypothesis for test
jenshnielsen Jun 1, 2017
8e92b27
fix improve testing of channels
jenshnielsen Jun 2, 2017
cc6622d
test more:
jenshnielsen Jun 2, 2017
8530671
fix: channels pep8
jenshnielsen Jun 6, 2017
429cf77
fix: ensure that channels can be extended from generator
jenshnielsen Jun 6, 2017
945edd3
More tests of adding channels
jenshnielsen Jun 6, 2017
347c0b2
Add missing functions and parameters to channellist
jenshnielsen Jun 6, 2017
ff8a316
fix: function testS
jenshnielsen Jun 6, 2017
2a3aa62
assert to unittest style
jenshnielsen Jun 7, 2017
bc2b4af
Revert "fix: function testS"
jenshnielsen Jun 7, 2017
d0a22c5
Revert "Add missing functions and parameters to channellist"
jenshnielsen Jun 7, 2017
6999f62
Remove docs of non existing attributes
jenshnielsen Jun 7, 2017
3fa48b7
Docs: decadac quote *IDN to remove warning
jenshnielsen Jun 7, 2017
17a3a88
Merge pull request #1 from jenshnielsen/feat/channelization
spauka Jun 7, 2017
8b6da08
Merge branch 'master' into feat/channelization
jenshnielsen Jun 7, 2017
2dbacc0
Add some channel notebooks
jenshnielsen Jun 6, 2017
cd23b07
fix: test_channels small tweeks
jenshnielsen Jun 7, 2017
4770840
Add support to array parameters in channels
jenshnielsen Jun 7, 2017
4b051cb
Mock parameters add instruments to fix names in tests
jenshnielsen Jun 8, 2017
6d11b5b
refactor tests to reduce code duplication
jenshnielsen Jun 8, 2017
e1c6a57
Revert "Add some channel notebooks"
jenshnielsen Jun 8, 2017
f05a970
feat: Add channelised QDac driver
WilliamHPNielsen Jun 8, 2017
e80de66
feat: Add a set method to MultiChannelInstrumentParameter
WilliamHPNielsen Jun 9, 2017
c90ac7c
docs: Add a driver example for the channelised Qdac
WilliamHPNielsen Jun 9, 2017
c497e65
Merge pull request #2 from WilliamHPNielsen/feat/channelization_with_…
jenshnielsen Jun 9, 2017
1793d19
feat: Make ChannelList take default paramclass
WilliamHPNielsen Jun 12, 2017
a4e4b90
feat: Add a channelised QDac driver
WilliamHPNielsen Jun 13, 2017
034fbf5
docs: Add notebook for QDac w. channels
WilliamHPNielsen Jun 13, 2017
83a32e8
style: Remove unnecessary comment
WilliamHPNielsen Jun 14, 2017
eb5e700
Merge pull request #3 from WilliamHPNielsen/feat/channelization_with_…
jenshnielsen Jun 14, 2017
2dcc932
Fix syntax/spelling errors in DAC driver
spauka Jun 15, 2017
84b663b
Fix: qdac_channels remove magic number
jenshnielsen Jun 15, 2017
8a44cd4
Doc: clarify doc string
jenshnielsen Jun 15, 2017
24f65a2
Fix: rename paramclass to be more specific
jenshnielsen Jun 15, 2017
3145c52
Merge pull request #2 from jenshnielsen/feat/channelization_with_array
spauka Jun 16, 2017
b6a1bfd
Lakeshore tab to space
jenshnielsen Jun 16, 2017
3124da5
pep8 lakeshore driver
jenshnielsen Jun 16, 2017
72f1928
Pep8 decadac driver
jenshnielsen Jun 16, 2017
df59634
Fix warnings in qdac driver
jenshnielsen Jun 16, 2017
7fc29d1
Annotate parameters that linter has problems with
jenshnielsen Jun 16, 2017
81020f3
Merge branch 'master' into feat/channelization-pep8
jenshnielsen Jun 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 296 additions & 0 deletions docs/examples/driver_examples/Qcodes example with QDac_channels.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Qcodes example with QDac_channels"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import qcodes as qc\n",
"import numpy as np\n",
"\n",
"from time import sleep\n",
"\n",
"from qcodes.instrument_drivers.QDev.QDac_channels import QDac"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Connect to the instrument\n",
"qdac = QDac('qdac', 'ASRL6::INSTR', update_currents=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basic QDac Usage\n",
"\n",
"The QCoDeS QDac driver currently supports using\n",
" * 48 Output Channels\n",
" * 3 $\\times$ 6 temperature sensors\n",
"\n",
"Each output channel has six parameters:\n",
" * DC voltage\n",
" * DC voltage range\n",
" * Current out (read-only)\n",
" * Current out range\n",
" * slope\n",
" * sync\n",
"\n",
"The slope is the (maximal) slope in V/s that the channel can allow its voltage to change by. By default, all channels have a slope of \"Inf\". The slope can be changed dynamically, but no more than 8 channels can have a finite slope at any given time (this is due to hardware limitations)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Current out is the current flowing through the channel this is read-only\n",
"print(qdac.ch01.i.get(), qdac.ch01.i.unit)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# The current range can be either 0 to 1 μA or 0 to 100 μA\n",
"print(qdac.ch01.irange.get())\n",
"# This is set with either 0 (0 to 1 μA) or 1 (0 to 100 μA) \n",
"qdac.ch01.irange.set(1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# The DC voltage may directly be set and gotten\n",
"qdac.ch01.v.set(-1)\n",
"print('Channel 1 voltage: {} {}'.format(qdac.ch01.v.get(), qdac.ch01.v.unit))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Multiple channels can be addressed simultaneously via the 'channels' list\n",
"qdac.channels[0:20].v.get()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Similarly, we may set them\n",
"qdac.channels[0:2].v.set(-1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# The maximal voltage change (in V/s) may be set for each channel\n",
"qdac.ch01.slope.set(1)\n",
"qdac.ch02.slope.set(2)\n",
"# An overview may be printed (all other channels have 'Inf' slope)\n",
"qdac.printslopes()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# now setting channel 1 and 2 voltages will cause slow ramps to happen\n",
"qdac.ch01.v.set(0)\n",
"qdac.ch02.v.set(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Note that only 8 (or fewer) channels can have finite slopes at one time\n",
"# To make space for other channels, set the slope to inifite\n",
"qdac.ch01.slope('Inf')\n",
"qdac.printslopes()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# To each channel one may assign a sync channel:\n",
"qdac.ch02.sync(2) # sync output 2 will fire a 10 ms 5 V pulse when ch02 ramps\n",
"# note that even if no visible ramp is performed (i.e. ramping from 1 V to 1 V), a pulse is still fired.\n",
"\n",
"# The sync pulse settings can be modified\n",
"qdac.ch02.sync_delay(0) # The sync pulse delay (s)\n",
"qdac.ch02.sync_duration(25e-3) # The sync pulse duration (s). Default is 10 ms."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"qdac.ch02.v.set(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# syncs are unassigned by assigning sync 0\n",
"qdac.ch02.sync(0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Attention!\n",
"\n",
"The v_range parameter is really controlling a 20 dB (amplitude factor 10) attenuator. Upon changing the vrange, the attenuator is **immediately** applied (or revoked). This will --irrespective of any slope set-- cause an instantaneous voltage change unless the channel voltage is zero. By default, all attenuators are off, and the voltage range is from -10 V to 10 V for all channels."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Here is a small example showing what to look out for\n",
"#\n",
"qdac.ch01.vrange.set(0) # Attenuation OFF (the default)\n",
"qdac.ch01.v.set(1.5)\n",
"qdac.ch01.vrange.set(1) # Attenuation ON\n",
"print(qdac.ch01.v.get()) # Returns 0.15 V\n",
"qdac.ch01.v.set(0.1)\n",
"qdac.ch01.vrange.set(0) # Attenuation OFF\n",
"print(qdac.ch01.v.get()) # returns 1 V"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview of channel settings\n",
"\n",
"The driver provides a method for pretty-printing the state of all channels. On startup, all channels are queried for voltage and current across them, but the current query is very slow (blame the hardware).\n",
"\n",
"The pretty-print method may or may not **update** the values for the currents, depending on the value of the `update_currents` flag. Each current reading takes some 200 ms, so updating all current values takes about 10 s."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"qdac.print_overview(update_currents=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Temperature sensors\n",
"\n",
"Physically, the QDac consists of six boards each hosting eight channels. On three locations on each board, a temperature sensors is placed. These provide read-only parameters, named `tempX_Y` where `X` is the board number and `Y` the sensor number."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(qdac.temp0_0.get(), qdac.temp0_0.unit)\n",
"print(qdac.temp2_1.get(), qdac.temp0_0.unit)\n",
"print(qdac.temp5_2.get(), qdac.temp0_0.unit)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"qdac.close()"
]
},
{
"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": 1
}
1 change: 1 addition & 0 deletions qcodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from qcodes.instrument.base import Instrument
from qcodes.instrument.ip import IPInstrument
from qcodes.instrument.visa import VisaInstrument
from qcodes.instrument.channel import InstrumentChannel, ChannelList

from qcodes.instrument.function import Function
from qcodes.instrument.parameter import (
Expand Down
39 changes: 38 additions & 1 deletion qcodes/instrument/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class Instrument(Metadatable, DelegateAttributes):

functions (Dict[Function]): All the functions supported by this
instrument. Usually populated via ``add_function``

submodules (Dict[Metadatable]): All the submodules of this instrument
such as channel lists or logical groupings of parameters.
Usually populated via ``add_submodule``
"""

shared_kwargs = ()
Expand All @@ -48,6 +52,7 @@ def __init__(self, name, **kwargs):
super().__init__(**kwargs)
self.parameters = {}
self.functions = {}
self.submodules = {}

self.name = str(name)

Expand Down Expand Up @@ -306,6 +311,36 @@ def add_function(self, name, **kwargs):
func = Function(name=name, instrument=self, **kwargs)
self.functions[name] = func

def add_submodule(self, name, submodule):
"""
Bind one submodule to this instrument.

Instrument subclasses can call this repeatedly in their ``__init__``
method for every submodule of the instrument.

Submodules can effectively be considered as instruments within the main
instrument, and should at minimum be snapshottable. For example, they can
be used to either store logical groupings of parameters, which may or may
not be repeated, or channel lists.

Args:
name (str): how the submodule will be stored within ``instrument.submodules``
and also how it can be addressed.

submodule (Metadatable): The submodule to be stored.

Raises:
KeyError: if this instrument already contains a submodule with this
name.
TypeError: if the submodule that we are trying to add is not an instance
of an Metadatable object.
"""
if name in self.submodules:
raise KeyError('Duplicate submodule name {}'.format(name))
if not isinstance(submodule, Metadatable):
raise TypeError('Submodules must be metadatable.')
self.submodules[name] = submodule

def snapshot_base(self, update=False):
"""
State of the instrument as a JSON-compatible dict.
Expand All @@ -321,6 +356,8 @@ def snapshot_base(self, update=False):
for name, param in self.parameters.items()),
'functions': dict((name, func.snapshot(update=update))
for name, func in self.functions.items()),
'submodules': dict((name, subm.snapshot(update=update))
for name, subm in self.submodules.items()),
'__class__': full_class(self),
}
for attr in set(self._meta_attrs):
Expand Down Expand Up @@ -459,7 +496,7 @@ def ask_raw(self, cmd):
# etc... #
#

delegate_attr_dicts = ['parameters', 'functions']
delegate_attr_dicts = ['parameters', 'functions', 'submodules']

def __getitem__(self, key):
"""Delegate instrument['name'] to parameter or function 'name'."""
Expand Down
Loading