In [1]:
%config IPCompleter.greedy=True

In [2]:
from pymeasure import pym
import visa
rm = visa.ResourceManager()

In [3]:
rm.list_resources()


Out[3]:
('ASRL5::INSTR', 'ASRL10::INSTR', 'GPIB0::2::INSTR')

In [4]:
k20 = pym.instruments.Keithley2000Multimeter(rm, 'GPIB0::2::INSTR', reset=True)
k20


Out[4]:
Keithley2000Multimeter[0: 'voltage_dc', 1: 'current_dc', 2: 'resistance']

In [5]:
dac = pym.instruments.Ad5791Dac(rm,  'ASRL5::INSTR', reset=True)
dac


Out[5]:
Ad5791Dac[0: '1a', 1: '1b', 2: '2a', 3: '2b', 4: '3a', 5: '3b', 6: '4a', 7: '4b', 8: '5a', 9: '5b', 10: '6a', 11: '6b']

In [6]:
k20['voltage_dc']()


Out[6]:
[0.00015495833940804005]

In [7]:
dac['1a']()


Out[7]:
[0.0]

In [8]:
dac['1a'](-0.2)
dac['1a']()


Out[8]:
[-0.19998588559319608]

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]:
[<matplotlib.lines.Line2D at 0x88eb9b0>]

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]:
[<matplotlib.lines.Line2D at 0x8a39358>]

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']()


[0.0] [1.0] [2.0] [3.0] [4.0] [5.0] 

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]:
[<matplotlib.lines.Line2D at 0x8aa4a20>]