from Gpib import * import time import sys import os v = Gpib('LCR') v.write('*CLS') v.write('*CLS') # sets function to parallel capacitance and parallel resistance v.write('FUNC:IMP CPRP') # sets the measuring voltage to 5mV, one can increase more for better s/n v.write('VOLTage 0.005') # number of averages, there is a delay in the communication, therefore it is better to keep this as 1, and measure many cycle as I did below v.write('APER FAST,1') # list of frequencies you wish to measure Freq = [ 20, 50, 100, 300, 500, 700, 1e3, 3e3, 5e3, 7e3, 10e3, 30e3, 50e3, 70e3, 100e3, 300e3, 500e3, 700e3, 800e3, 900e3, 1e6 ] #define sample name Sample = "electrolitic_12032019" #create folder with sample name os.makedirs(Sample)
import time import counter as c INT_TIME = 10 DEVICE_NAME = 0 PRIMARY_ADDR = 5 LOOPTILL = 150 INIT_DLY = 65 END_DLY = 70 FILENAME = 'dll_swp_5ps.csv' datalist = [] delay_fd = Gpib(name=DEVICE_NAME, pad=PRIMARY_ADDR) delay_fd.write("DLY {}".format(INIT_DLY)) time.sleep(3) start = time.clock() delay_fd.write("DLY {}".format(END_DLY)) for i in range(0, LOOPTILL): count_fd, control_fd = c.open_counter(INT_TIME) count = c.count(control_fd, count_fd, INT_TIME) datalist.append([count, time.clock() - start + 0.001 * (i + 1)]) c.close(control_fd, count_fd) #print('{},{}'.format(count,time.clock()-start)) print(time.clock() - start) save = open(FILENAME, 'w+') save.write('count, time\n')
from Gpib import * import os import time #Max=5.0; Max = float(sys.argv[1]) Min = -Max #Nsteps=200; Nsteps = int(sys.argv[2]) yy = 0.0 dH = Max / Nsteps v = Gpib('LIA') rt = 0.006 #rest time #First harmonics v.write('HARM1') Nameoffolder = sys.argv[3] #Nameoffolder='Test_24102017_10_A-B__wopolariser'; #os.chdir('/media/e16310') os.makedirs(Nameoffolder) os.chdir('/home/mokeuser/Downloads/linux-gpib-4.0.4rc2/language/python/' + Nameoffolder) #os.chdir('/media/e16310/'+Nameoffolder) output_voltage_array = [] Final = [] Mean = [] Voltage = [] loop = [[]] * 10
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()
#save_file = open("fogIndTest4.csv",'w') for y in ylist: m.set_pos(mems, 0.03, y) print(y) peaks = [] counts = [] dataset = [] for i in range(0, 5): max_count = 0; MLV = 400; #ave_file = open("{}NoHPlate{}.csv".format(args.itrno,i), 'w') dly.write("DLY {:.3f}".format(DLY_START)) time.sleep(600/1000) for dly_data in frange(DLY_START, DLY_END, DLY_INC): dly.write("DLY {:.3f}".format(dly_data)) time.sleep(150/1000) count = c.get_count(TDC) data = "{:.3f},{}\n".format(dly_data, count) #print("{} {}".format(args.itrno,data)) #ave_file.write(data) if(count > max_count): max_count = count; MLV = dly_data #print("HEY{} {}".format(MLV,max_count)) peaks.append(MLV) counts.append(max_count) #save_file.close()
#import gpib from Gpib import * import time import sys import os v = Gpib('LCR') v.write('*CLS') v.write('*CLS') # sets the measuring voltage, one can increase more for better s/n v.write('VOLTage 0.150') # number of averages, there is a delay in the communication, therefore it is better to keep this as 1, and measure many cycle as I did below v.write('APER FAST,1') # List of frequencies to measure #Freq = [20,30,50,100,200,300,400,500,600,700,800,900,1e3,1.5e3,2e3,2.5e3,3e3,3.5e3,4e3,4.5e3,5e3,5.5e3,6e3,6.5e3,7e3,7.5e3,8e3,8.5e3,9e3,9.5e3,10e3,15e3,20e3,25e3,30e3,35e3,40e3,45e3,50e3,55e3,60e3,65e3,70e3,75e3,80e3,85e3,90e3,95e3,100e3,150e3,200e3,250e3,300e3,350e3,400e3,450e3,500e3,550e3,600e3,650e3,700e3,750e3,800e3,850e3,900e3,950e3,1e6] Freq = [ 20, 30, 50, 100, 300, 500, 700, 1e3, 3e3, 5e3, 7e3, 10e3, 30e3, 50e3, 70e3, 100e3, 300e3, 500e3, 700e3, 800e3, 900e3, 1e6 ] #define sample name Sample = "Al2O3" #create folder with sample name os.makedirs(Sample) os.chdir('/home/mokeuser/Downloads/linux-gpib-4.0.4rc2/language/python/' + Sample) # Sets DC voltage(s) measure capacitance as a function fo frequency
from Gpib import * import counter as c import time d = Gpib(name=0, pad=5) d.write("DLY 70") count_fd, control_fd = c.open_counter(10) print c.count(control_fd, count_fd, 10) c.close(control_fd, count_fd) count_fd, control_fd = c.open_counter(10) print c.count(control_fd, count_fd, 10) time.sleep(10.0 / 1000) c.close(control_fd, count_fd) d.write("DLY 0") #for x in range(0,10000): count_fd, control_fd = c.open_counter(10) print c.count(control_fd, count_fd, 10) time.sleep(10.0 / 1000) c.close(control_fd, count_fd) count_fd, control_fd = c.open_counter(10) print c.count(control_fd, count_fd, 10) time.sleep(10.0 / 1000) c.close(control_fd, count_fd) #time.sleep(2
#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()
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)