from importlib import reload
import sys
import numpy
import matplotlib.pyplot as plt
%matplotlib inline
# Reload already loaded modules
for m in ("AD5522_pi", "AD7685_pi", "AD5522dev_pi"):
try:
mod = sys.modules[m]
except KeyError:
pass
else:
reload(mod)
from AD5522dev_pi import AD5522dev
from AD5522_pi import MeasMode
board = AD5522dev(vref=5.0)
smu = board.smu
adc = board.adc
board.measchannel = 3
ch3 = board.channels[3]
def _setandmeasure(v):
ch3.Vforceset = v
return board.measure(count=10)[0]
ch3.mode = MeasMode.FVMI
v_s = numpy.arange(-6, 6.1, 0.5)
i_s = tuple(_setandmeasure(v) for v in v_s)
ch3.mode = MeasMode.HVMI
plt.plot(v_s, i_s)