import datetime st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') filename = open("data_" + st + ".txt", "a") # -ve to +ve values for j in range(0, Nsteps): H = -Max + 2 * j * dH v.write('AUXV1{,%f}' % H) print(H) time.sleep(rt) #pause for 3ms output_voltage = 0 for k in range(0, 5): #v.write('OUTP?1') v.write('SNAP?1,5') # 1 = kerr ellipticity,5 = DC laser temp1 = str(v.read()) split = temp1.split(',') ke = float(split[0]) sigdc = float(split[1]) temp = ke / sigdc output_voltage = output_voltage + float(temp) filename.write("%f %e \n" % (H, output_voltage / 5)) # second slope from +ve to -ve for j in range(0, Nsteps): H = Max - 2 * j * dH v.write('AUXV1{,%f}' % H) print(H) time.sleep(rt) #pause for 3ms output_voltage = 0
os.chdir('/home/mokeuser/Downloads/linux-gpib-4.0.4rc2/language/python/' + Sample) #starts measurements from here and we make two measurement cycles with C vs Freq for j in range(0, 2): # please change the number of cycles accordingly #Files will be saved with the sample name and number C vs Freq sweep defined as "i" filename = open("CP_RP_" + Sample + "_%i.txt" % j, "a") for i in range(0, len(Freq)): v.write('FREQ %e' % Freq[i]) # it is important to give this 15 s time for the instrument to set the frequency time.sleep(15) print Freq[i] v.write('FETC?') X = v.read() print X split = X.split(',') C = split[0] R = split[1] #data will be saved with first column as freqeuncy, second column with capacitance and third column with resistance filename.write("%e %s %s\n" % (Freq[i], C, R)) filename.close() v.write('*CLS') v.write('*CLS') v.write('FUNC:IMP CSRS') # sample is repeated for series capacitance and resistance
from time import sleep from Gpib import * v = Gpib('voltmeter') v.clear() v.write('D0 Q0') sleep(1) for i in range(0, 10): print v.read()
#import gpib from Gpib import * import sys v = Gpib('LIA') file = open(sys.argv[1] + "log.txt", "w") print('Harmonics') v.write('HARM?') Harmonics = str(v.read()) print(Harmonics) file.write(" Harmonics = %s " % Harmonics + "\n") file.write( "############################################################################" + "\n") print('###################################################################') print('Time constant') v.write('OFLT?') tc = str(v.read()) file.write(" Time constant = %s " % tc + "\n") print(tc) print(' 0 = 10 us') file.write("0 = 10 us" + "\n") print(' 1 = 30 us') file.writelines("1 = 30 us" + "\n") print(' 3 = 300 us') file.writelines("3 = 300 us" + "\n") print(' 5 = 3 ms')
from time import sleep from Gpib import * v = Gpib('voltmeter') v.clear() v.write('D0 Q0') sleep(1) for i in range(0,10): print v.read()
from time import sleep from Gpib import * v = Gpib('voltmeter') v.clear() v.write('D0 Q0') sleep(1) for i in range(0, 10): print(v.read())
class ATS2(object): def __init__(self): self.gpib = Gpib('ats2'); self.gpib.clear() def setAmpVppA(self, val): self.gpib.write(":AGEN:AMPL A,%fVPP" % val) def getAmpVppA(self): self.gpib.write(":AGEN:AMPL? A,VPP") response = self.gpib.read(1024) valmatch = re.search(":AGEN:AMPL A,([\d\.]+)VPP", response) return float(valmatch.groups()[0]) ampVppA = property(getAmpVppA, setAmpVppA) def setAmpVppB(self, val): self.gpib.write(":AGEN:AMPL B,%fVPP" % val) def getAmpVppB(self): self.gpib.write(":AGEN:AMPL? B,VPP") response = self.gpib.read(1024) valmatch = re.search(":AGEN:AMPL B,([\d\.]+)VPP", response) return float(valmatch.groups()[0]) ampVppB = property(getAmpVppB, setAmpVppB) def setOutput(self, val): if val == "bal": self.gpib.write(":AGEN:CONFIG BAL") elif val == "unbal": self.gpib.write(":AGEN:CONFIG UNBAL") else: raise TypeError def getOutput(self): self.gpib.write(":AGEN:CONFIG?") response = self.gpib.read(1024) valmatch = re.search(":AGEN:CONFIG (\w+)", response) if valmatch.groups()[0] == "BAL": return "bal" elif valmatch.groups()[0] == "UNBAL": return "unbal" else: raise TypeError output = property(getOutput, setOutput) def setFreq1(self, val): self.gpib.write(":AGEN:DASINE:FRQ1 %fHZ" % val) def getFreq1(self): self.gpib.write(":AGEN:DASINE:FRQ1? HZ") response = self.gpib.read(1024) valmatch = re.search(":AGEN:DASINE:FRQ1 ([\d\.]+)HZ", response) return float(valmatch.groups()[0]) freq1 = property(getFreq1, setFreq1) def setFreq2(self, val): self.gpib.write(":AGEN:DASINE:FRQ2 %fHZ" % val) def getFreq2(self): self.gpib.write(":AGEN:DASINE:FRQ2? HZ") response = self.gpib.read(1024) valmatch = re.search(":AGEN:DASINE:FRQ2 ([\d\.]+)HZ", response) return float(valmatch.groups()[0]) freq2 = property(getFreq2, setFreq2) def setMode(self, val): if val == Modes.SINE : self.gpib.write(":AGEN:WFM DASINE,STER") def getMode(self): self.gpib.write(":AGEN:WFM?") response = self.gpib.read(1024) print response if response == ":AGEN:WFM DASINE,STEREO\n": return Modes.SINE else: raise TypeError, "INvalid mode returned" mode = property(getMode, setMode) def setOnA(self, val): self.gpib.write(":AGEN:OUTPUT?") response = self.gpib.read(1024) if val: if response == ":AGEN:OUTPUT B\n": self.gpib.write(":AGEN:OUTPUT AB") else: self.gpib.write(":AGEN:OUTPUT A") else: if response == ":AGEN:OUTPUT AB\n": self.gpib.write(":AGEN:OUTPUT B") elif response == ":AGEN:OUTPUT B\n": pass else: self.gpib.write(":AGEN:OUTPUT OFF") def getOnA(self): self.gpib.write(":AGEN:OUTPUT?") response = self.gpib.read(1024) if response == ":AGEN:OUTPUT A\n": return True elif response == ":AGEN:OUTPUT AB\n": return True else: return False onA = property(getOnA, setOnA) def setOnB(self, val): self.gpib.write(":AGEN:OUTPUT?") response = self.gpib.read(1024) if val: if response == ":AGEN:OUTPUT A\n": self.gpib.write(":AGEN:OUTPUT AB") else: self.gpib.write(":AGEN:OUTPUT B") else: if response == ":AGEN:OUTPUT AB\n": self.gpib.write(":AGEN:OUTPUT A") elif response == ":AGEN:OUTPUT A\n": pass else: self.gpib.write(":AGEN:OUTPUT OFF") def getOnB(self): self.gpib.write(":AGEN:OUTPUT?") response = self.gpib.read(1024) if response == ":AGEN:OUTPUT B\n": return True elif response == ":AGEN:OUTPUT AB\n": return True else: return False onB = property(getOnB, setOnB)