Anda di halaman 1dari 3

from instrument import agilent_6060b

from instrument import rigol832


from instrument import yokogawa_wt310
from instrument import agilent_34410a
import visa
import time
import numpy as np
import xlsxwriter

#def main():

#load step
l1 = np.arange(0, 0.01, 0.0005)
l2 = np.arange(0.01, 0.02, 0.005)
load_current = np.hstack((l1,l2))
N_current = len(load_current)
N = N_current

#iout/vout from power meter


#in/vin from dmm
#initialize array
Iout_array = [0] * N
Vout_array = [0] * N
Pout_array = [0]* N
Iin_array = [0] * N
Vin_array = [0] * N
Pin_array = [0]*N
time_to_observe_1 = 0.5
time_wait = 1

#connect to all the instruments


rm = visa.ResourceManager()

# eload
E_load = rm.open_resource('GPIB1::5::INSTR',
write_termination='\n',read_termination = '\n') # need the termination else will
get timeout error
eload = agilent_6060b.agilent_6060b(E_load, mode='CURR', rang=1, debug=False)

#power meter
power_meter = rm.open_resource('GPIB1::1::INSTR',
write_termination='\n',read_termination = '\n') # need the termination else will
get timeout error
pmeter = yokogawa_wt310.yokogawa_wt310(power_meter,debug =False, mode = 'DC')

#power meter input


power_meter_in =
rm.open_resource('USB0::0x0B21::0x0025::4332504A303230373256::INSTR',
write_termination='\n',read_termination = '\n') # need the termination else will
get timeout error
pmeter_in = yokogawa_wt310.yokogawa_wt310(power_meter_in,debug =False, mode = 'DC')

#dmm setup
#DMM_I = rm.open_resource('USB0::0x0957::0x0607::MY47011505::INSTR',
write_termination='\n',read_termination = '\n')
DMM_V = rm.open_resource('GPIB1::10::INSTR',
write_termination='\n',read_termination = '\n')
#dmm_I = agilent_34410a.agilent_34410a(DMM_I, mode = 'CURR', ACDC ='DC')
dmm_V = agilent_34410a.agilent_34410a(DMM_V, mode = 'VOLT', ACDC ='DC')

time.sleep(4) # wait for those instrument to reset

#DC Supply
DC = rm.open_resource('USB0::0x1AB1::0x0E11::DP8C194205851::INSTR',
write_termination='\n',read_termination = '\n')
DCSupply = rigol832.rigol832(DC,debug =1,RST=1)
#DCSupply.setVoltage('CH1',3.3,1)
#DCSupply.activate('CH1')

#vMid supply
DCVMID = rm.open_resource('USB0::0x1AB1::0x0E11::DP8C194306032::INSTR',
write_termination='\n',read_termination = '\n')
DC_MID = rigol832.rigol832(DCVMID,debug =1,RST=1)

print 'set up successfully'


#eload setup
eload.setMode("CURR")
eload.setSlew(8000)
eload.setValue(0.0)

# ==========================================================================
# Excel creating
# ==========================================================================

workbook =
xlsxwriter.Workbook('/Users/peihanng/Documents/automation/Result/B3_0p7_18D2_180n.x
lsx')
worksheet = workbook.add_worksheet()

header = ("Vin", "Iin", "Vout", "Iout","VMID", "IMID", "V_VDD", "I_VDD","Pin",


"Pout", "Efficiency")

# Start from the first cell. Rows and columns are zero indexed.
row = 0
col = 0

# Iterate over the data and write it out row by row.


for item in (header):
worksheet.write(row, col, item)
col += 1

# ==========================================================================
# Sweep
# ==========================================================================

eload.activate()
for iter in range(N):
print ('cycle %d' %iter)
value = load_current[iter]
eload.setValue(value)
time.sleep(time_wait)

#[Vin, Iin, Pin] = pmeter_in.getLastSample()


[Vout, Iout, Pout] = pmeter.getLastSample()
time.sleep(0.25)
Iin = DCSupply.readCurrent('CH3')
Vin = DCSupply.readVoltage('CH3')

IMid = DC_MID.readCurrent('CH1')
VMid = DC_MID.readVoltage('CH1')

time.sleep(0.25)
I_VDD = DC_MID.readCurrent('CH2')
V_VDD = DC_MID.readVoltage('CH2')

#Iin = dmm_I.readData(0.25)
#Vin = dmm_V.readData(0.25)
Pin = Iin[0]*Vin[0]
P_VDD = I_VDD[0]*V_VDD[0]
P_VMID = IMid[0]*VMid[0]
#P_VDD = 0
#P_VMID = 0
Pin_total = Pin + P_VDD +P_VMID
#print type(Vout)
Efficiency = Pout/Pin_total * 100

#print Iin
#print type(Iin)

row +=1
col = 0

worksheet.write(row, col, Vin[0])


worksheet.write(row, col+1, Iin[0])
worksheet.write(row, col+2, Vout)
worksheet.write(row, col+3, Iout)
worksheet.write(row, col+4, VMid[0])
worksheet.write(row, col+5, IMid[0])
worksheet.write(row, col+6, V_VDD[0])
worksheet.write(row, col+7, I_VDD[0])

worksheet.write(row, col+8, Pin)


worksheet.write(row, col+9, Pout)
worksheet.write(row, col+10, Efficiency)

workbook.close()

eload.deactivate()
time.sleep(1)
#DCSupply.deactivate('CH1')

E_load.close()
DC.close()
power_meter.close()
DMM_V.close()

print 'done'
#DMM_I.close()

#if __name__ == "__main__":


# main()

Anda mungkin juga menyukai