I have a Keithley 6221 and 2182A current source and nanovoltmeter set up and connected to eachother (which are both connected to a sample). I wrote code to remote program and output data values for the Delta mode to a CSV file. This works fine.
However, when I try to adapt the code for the pulse delta mode, I run into issues. The 6221 outputs "invalid header" and "parameter out of range" and "init ignored" errors, and otherwise outputs no data at all. I believe the 'TRAC:POIN ' command is part of the error, since when I comment out that line of code some of the errors disappear. When I change the number of points in the buffer (to 2 or 10 for example) and run the code, I don't receive any data output. I am trying to read just 1 value for testing purposes, which is why I usually set the number of points in the buffer to 1 ('TRAC:POIN 1'). It seems as if nothing is being read by the machine. I am confused, as this does not happen when I run the delta mode measurement. I adjusted the code by adding the appropriate 'PDEL ' in the code instead of 'DEL', along with one or two commands to adjust the source delay and high current. I believe everything before line 31 (#setup6221Delta) which initializes the 2182A and a few other things should be fine, as I start changing things after that. Additionally, the machine physically seems to output the correct values on its screen, as they match the values that are shown when I perform the test locally, but the data does not seem to output. Are there other modifications that I should be making to the code?
If anyone has any suggestions or advice, I would greatly appreciate it. I have posted my code below. I use Spyder and python.
Please let me know if you have any questions or need clarity.
Thank you very much in advance.
import pyvisa as visa
import csv
import time
from lakeshore import Model335
from lakeshore.model_335 import *
import numpy as np
import logging as log
rm = visa.ResourceManager('@py')
my_instrument = rm.open_resource('GPIB0::16::INSTR')
my_instrument.write('*RST') #restores 6221 defaults
my_instrument.write("TRAC:CLE")
my_instrument.write('SYST:COMM:SER:SEND "REN"')
#setup2182A
voltrange = 0.01
log.info("Setting up 2182A measurement range and integration rate")
my_instrument.write('SYST:COMM:SER:SEND "VOLT:RANG %f"' % voltrange) #sets 2V range for 2182a
log.info("Voltage range has been set to %f V" % voltrange)
rate = 1
my_instrument.write('SYST:COMM:SER:SEND "VOLT:NPLC %f"' % rate) #Set rate to 1PLC for 2182a
log.info("VIntegration rate has been set to %f V" % rate)
#setup6221Delta
log.info("Beginning sequence to set up, arm, and run Delta")
my_instrument.write('*RST') #restores 6221 defaults
my_instrument.write('SOUR:PDEL:HIGH 10e-6') #sets high source value
my_instrument.write("SOUR:PDEL:SDEL 5.6e-5") #sets delta delay
my_instrument.write('SOUR:PDEL:COUN 1') #Sets Delta count
#my_instrument.write('SOUR:DELT:CAB ON') #Enables compliance abort
my_instrument.write('TRAC:POIN 10') #sets buffer
log.info('Set up completed')
my_instrument.write('SOUR:PDEL:ARM') #Arms Delta
while (x < 1)
my_instrument.write('INIT:IMM') #starts delta measurements
log.info('Delta measurements have started')
#readings
my_instrument.query('SENS:DATA?')
temp = str(my_instrument.query('TRAC:DATA?'))
var = temp.replace('+', '')
print(var)
var2 = var.split(',')[0]
print(var2)
x = x + 0.1
values = [round(timevalue+(end-starttime),2), var2]
#adding the time value increment to the time elapsed since code started
with open('testpulsepulsetest.csv', mode = 'a', newline='') as f:
writer = csv.writer(f, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
writer.writerow(values)
time.sleep(0.05)
timevalue = timevalue + 0.05
#finished
#reset
my_instrument.write('*RST') #restores 6221 defaults
my_instrument.write("TRAC:CLE")