Skip to content

Commit

Permalink
Faster qdac (#53)
Browse files Browse the repository at this point in the history
* add support for faster setting of qdac voltage

* SR830 fail early in buffered readout if butffer is not full as expected

* add option to qdac to ignore return read on voltage set

This ivery experimental and likely to break if you are not careful
  • Loading branch information
jenshnielsen committed Aug 10, 2017
1 parent 3aac785 commit ca3da36
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
32 changes: 25 additions & 7 deletions qcodes/instrument_drivers/QDev/QDac.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ def __init__(self, name, address, num_chans=48, update_currents=True):
set_cmd='ver {}',
val_mapping={True: 1, False: 0})

self.add_parameter(name='fast_voltage_set',
label='fast voltage set',
parameter_class=ManualParameter,
vals=vals.Bool(),
initial_value=False,
docstring=""""Toggles if DC voltage set should unset any ramp attached to this channel.
If you enable this you should ensure thay any function generator is unset
from the channel before setting voltage""")
self.add_parameter(name='voltage_set_dont_wait',
label='voltage set dont wait',
parameter_class=ManualParameter,
vals=vals.Bool(),
initial_value=False,
docstring=""""If enabled the voltage set does not wait for a reply from the
qdac. This is experimental and may break but has the potential to speed up
stepping the qdac""")
# Initialise the instrument, all channels DC (unbind func. generators)
for chan in self.chan_range:
# Note: this call does NOT change the voltage on the channel
Expand Down Expand Up @@ -208,18 +224,19 @@ def _set_voltage(self, chan, v_set):
self._assigned_fgs[chan] = fg
# We need .get and not get_latest in case a ramp was interrupted
v_start = self.parameters['ch{:02}_v'.format(chan)].get()
time = abs(v_set-v_start)/slope
log.info('Slope: {}, time: {}'.format(slope, time))
mytime = abs(v_set-v_start)/slope
log.info('Slope: {}, time: {}'.format(slope, mytime))
# Attenuation compensation and syncing
# happen inside _rampvoltage
self._rampvoltage(chan, fg, v_start, v_set, time)
self._rampvoltage(chan, fg, v_start, v_set, mytime)
else:
# compensate for the 0.1 multiplier, if it's on
if self.parameters['ch{:02}_vrange'.format(chan)].get_latest() == 1:
v_set = v_set*10
# set the mode back to DC in case it had been changed
self.write('wav {} 0 0 0'.format(chan))
self.write('set {} {:.6f}'.format(chan, v_set))
if not self.fast_voltage_set():
self.write('wav {} 0 0 0'.format(chan))
self.write('set {} {:.6f}'.format(chan, v_set), fast=self.voltage_set_dont_wait())

def _set_vrange(self, chan, switchint):
"""
Expand Down Expand Up @@ -535,7 +552,7 @@ def _rampvoltage(self, chan, fg, v_start, setvoltage, ramptime):
self.write(funmssg)


def write(self, cmd):
def write(self, cmd, fast=False):
"""
QDac always returns something even from set commands, even when
verbose mode is off, so we'll override write to take this out
Expand All @@ -553,7 +570,8 @@ def write(self, cmd):

nr_bytes_written, ret_code = self.visa_handle.write(cmd)
self.check_error(ret_code)
self._write_response = self.visa_handle.read()
if not fast:
self._write_response = self.visa_handle.read()

def read(self):
return self.visa_handle.read()
Expand Down
3 changes: 2 additions & 1 deletion qcodes/instrument_drivers/stanford_research/SR830.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def get(self):
# parse it
realdata = np.fromstring(rawdata, dtype='<i2')
numbers = realdata[::2]*2.0**(realdata[1::2]-124)

if self.shape[0] != N:
raise RuntimeError("SR830 got {} points in buffer expected {}".format(N, self.shape[0]))
return numbers


Expand Down

0 comments on commit ca3da36

Please sign in to comment.