In [1]:
    
%config IPCompleter.greedy=True
    
In [2]:
    
from pymeasure import pym
import visa
rm = visa.ResourceManager()
    
In [3]:
    
rm.list_resources()
    
    Out[3]:
In [4]:
    
k20 = pym.instruments.Keithley2000Multimeter(rm, 'GPIB0::2::INSTR', reset=True)
k20
    
    Out[4]:
In [5]:
    
dac = pym.instruments.Ad5791Dac(rm,  'ASRL5::INSTR', reset=True)
dac
    
    Out[5]:
In [6]:
    
k20['voltage_dc']()
    
    Out[6]:
In [7]:
    
dac['1a']()
    
    Out[7]:
In [8]:
    
dac['1a'](-0.2)
dac['1a']()
    
    Out[8]:
Sweeping
In [9]:
    
sweep = pym.SweepLinear(dac['1a'], start=0, stop=10, points=11)
    
Run it in a for loop
In [10]:
    
data = []
for step in sweep:
    datapoint = k20['voltage_dc']()
    data.append(datapoint)
    
Using list comprehension
In [11]:
    
sweep = pym.SweepLinear(dac['1a'], start=0, stop=10, points=51)
data = [k20['voltage_dc']() for _ in sweep]
    
Plot the Data
In [12]:
    
from matplotlib import pyplot as plt
%matplotlib inline
    
In [13]:
    
plt.plot(data, marker='o')
    
    Out[13]:
    
Sweep something else
In [14]:
    
import numpy as np
x = np.linspace(0, 4*np.pi, 41)
sweep = pym.SweepSteps(dac['1a'], 5* np.sin(x))
data = [k20['voltage_dc']() for _ in sweep]
    
In [15]:
    
plt.figure(figsize=(12,3))
plt.plot(x, data, marker='o')
    
    Out[15]:
    
Why not running a 2d measurment
In [16]:
    
import numpy as np
x = np.linspace(0, 2*np.pi, 21)
sweep1 = pym.SweepLinear(dac['1b'], 0, 5, 6)
sweep0 = pym.SweepSteps(dac['1a'], 5* np.sin(x))
for step1 in sweep1:
    print(step1, end=' ')
    for step0 in sweep0:
        k20['voltage_dc']()
    
    
Buffering
In [17]:
    
vdc = k20['voltage_dc']
vdc.integration_time = 0.005
vdc.display.enable = False
vdc.autorange = False
vdc.range = 10
vdc.buffering(101)
    
In [18]:
    
x = np.linspace(0, 4*np.pi, 101)
sweep = pym.SweepSteps(dac['1a'], 5* np.sin(x))
for step in sweep:
    vdc.trg(waiting_time=0.02)
# Read the buffer at once
data = vdc.read()
    
In [19]:
    
plt.figure(figsize=(12,3))
plt.plot(x, data, marker='o')
    
    Out[19]: