Skip to content

Commit

Permalink
fix: Make do1d pre-flush VISA buffers (#32)
Browse files Browse the repository at this point in the history
Make do1d flush the buffers of the involved instruments. This is to avoid instruments getting out of sync with their messages and consequently delivering garbage data.
  • Loading branch information
WilliamHPNielsen authored and jenshnielsen committed Jun 1, 2017
1 parent 2a5d47c commit 88ce106
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions qcodes/utils/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ def _create_plot(i, name, data, counter_two):
counter_two += 1


def _flush_buffers(*insts):
"""
Flush the VISA buffer of the provided insts.
Supposed to be called inside doNd like so:
_flush_buffers(inst_set, *inst_meas)
"""
for inst in insts:
if hasattr(inst, 'visa_handle'):
inst.visa_handle.clear()


def save_device_image(sweeptparameters):
counter = CURRENT_EXPERIMENT['provider'].counter
Expand Down Expand Up @@ -250,6 +261,10 @@ def do1d(inst_set, start, stop, num_points, delay, *inst_meas):
plot, data : returns the plot and the dataset
"""

# try to flush VISA buffers at the beginning of a measurement
_flush_buffers(inst_set, *inst_meas)

loop = qc.Loop(inst_set.sweep(start,
stop, num=num_points), delay).each(*inst_meas)
data = loop.get_data_set()
Expand Down

0 comments on commit 88ce106

Please sign in to comment.