def main(): lapData = readCSV() port = "24" baudrate = "38400" load = dcload.DCLoad() TalkToLoad(load, port, baudrate, lapData) return 0
def on_open_click(self): print("Click", self.dev_selector.currentText()) if self.dev is None: self.initalizing = True self.dev = dcload.DCLoad() self.dev.Initialize(self.dev_selector.currentText(), 115200) self.btn_connect.setText("Close") self.model, serial_no, fw = self.dev.GetProductInformation() self.dev_id.setText(self.model) mode = self.dev.GetMode() self.mode = mode if mode == "CC": self.mode_cc.setChecked(True) elif mode == "CV": self.mode_cv.setChecked(True) elif mode == "CR": self.mode_cr.setChecked(True) elif mode == "CW": self.mode_cp.setChecked(True) self.update_mode() self.dev.SetRemoteControl() # self.dev.write("PULSe:FREQuency?") # self.cur_pulse_freq = self.dev.read().strip() # self.dev.write("PULSe:DCYCle?") # self.cur_pulse_duty = self.dev.read().strip() # self.dev.write("PULSe:LEVel:PERCentage:CURRent?") trans_state = self.dev.GetTransient(self.mode) self.trans_state = trans_state if trans_state[1] + trans_state[3] == 0: self.cur_pulse_freq = 10000 self.cur_pulse_duty = 50 else: self.cur_pulse_freq = 1 / (trans_state[1] + trans_state[3]) self.cur_pulse_duty = trans_state[1] / (trans_state[1] + trans_state[3]) * 100 self.cur_pulse_level = trans_state[0] / (self.slider.value()/self.get_main_scale_div()) * 100 cur_function = self.dev.GetFunction() if cur_function == "transient": self.cur_pulse_enabled = True else: self.cur_pulse_enabled = False print("Pluse Freq : %s DUTY: %s%%" % (self.cur_pulse_freq, self.cur_pulse_duty)) self.update_pulse_info() self.initalizing = False else: del self.dev self.btn_connect.setText("Open") self.dev = None self.initalizing = True
def testBK8514(comport): load = dcload.DCLoad() print 'Checking for load on', comport load.Initialize(comport, 38400) sn = load.GetProductInformation() if sn: sn = sn.split('\t')[1] return (sn, load) else: load.sp.close() return ('', '')
def main(): if len(sys.argv) != 4: Usage() access_type = sys.argv[1] port = int(sys.argv[2]) baudrate = int(sys.argv[3]) if access_type == "com": load = Dispatch('BKServers.DCLoad85xx') elif access_type == "obj": load = dcload.DCLoad() else: Usage() TalkToLoad(load, port, baudrate) return 0
def __init__(self, comport, max_voltage=500, max_current=15): self.MaxVoltage = max_voltage self.MaxCurrent = max_current self.load = dcload.DCLoad() self.load.Initialize(comport, 38400) self.load.SetRemoteControl() self.load.SetMode('cv') self.load.SetMaxVoltage(max_voltage) self.load.SetMaxCurrent(max_current) self.load.SetCVVoltage(max_voltage) values = self.load.GetProductInformation() for value in values.split("\t"): print " ", value
def main(): print "Test Started" if len(currents) == len(times): load = dcload.DCLoad() load.Initialize(port, baudrate) load.SetRemoteControl() load.SetMaxCurrent(5) load.SetMode("cc") output = open(str(load.TimeNow()).replace(":", "_") + ".csv", "wb") writer = csv.writer(output, delimiter=',') writer.writerow( ["Time (mS)", "Voltage (V)", "Current (A)", "Power (W)"]) load.TurnLoadOn() beginTest = current_milli_time() for current in currents: load.SetCCCurrent(current) start = current_milli_time() while current_milli_time() < start + ( times[currents.index(current)] * 1000): state = load.GetInputValues() values = [] for num in state.split(): try: values.append(float(num)) except ValueError: pass writer.writerow([ current_milli_time() - beginTest, values[0], values[1], values[2] ]) load.TurnLoadOff() print "Test Ended" else: print "Currents and Times must have equal length" return 0
import dcload LOAD_PORT = '/dev/ttyUSB1' load = dcload.DCLoad() load.Initialize(LOAD_PORT, 9600) load.SetRemoteControl() load.SetMaxPower(2) load.SetCWPower(1)
def init_bk(): global bk bk = dcload.DCLoad() bk.Initialize(bk_device, 9600) bk.SetRemoteControl() set_bk(0.0)
bk.TurnLoadOn() bk.SetMaxPower(value * 5 + 1) bk.SetMaxCurrent(value * 5 + 1) if BK_MODE == 'power': bk.SetMode('cw') bk.SetMaxPower(value + 1.0) bk.SetCWPower(value) elif BK_MODE == 'current': bk.SetMode('cc') bk.SetMaxCurrent(value + 1.0) bk.SetCCCurrent(value) voltageSerial = serial.Serial(VOLTAGE_DEVICE, 9600, dsrdtr=False, timeout=5) voltageSerial.write("SYSTem:REMote\n") bk = dcload.DCLoad() bk.Initialize(BK_DEVICE, 9600) bk.SetRemoteControl() set_bk(0.0) relaySerial = serial.Serial(RELAY_DEVICE, 9600, dsrdtr=False, timeout=5) startTime = time.time() fout = None def start_logging(): global fout fout = open(OUTPUT_FILE, 'a+') print "wtf: %s" % fout
def main(): ############################################################################### # Provide Logging Facility ############################################################################### # create logger instance logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) # create console handler and set level to debug ch = logging.StreamHandler() ch.setLevel(chLogLevel) # create formatter formatter = logging.Formatter('%(levelname)s - %(message)s') # add formatter to ch ch.setFormatter(formatter) # add ch to logger logger.addHandler(ch) #------------------------------------------------------------------------------ # create instance load = dcload.DCLoad() # list for efficiency values for plot efficiency = [] current = [] # DMM Config dmm_u_config = [ 'CONF:VOLT:DC', 'SENS:VOLT:DC:RANG 100', #up tp 100V 'TRIG:DEL 0', #Set the delay between trigger and measurement 'TRIG:SOUR IMM', #Set meter’s trigger source 'SAMP:COUN 1' ] #Set number of samples per trigger dmm_i_config = [ 'CONF:CURR:DC', 'SENS:CURR:DC:RANG 10', #up tp 10V 'TRIG:DEL 0', #Set the delay between trigger and measurement 'TRIG:SOUR IMM', #Set meter’s trigger source 'SAMP:COUN 1' ] #Set number of samples per trigger #set up digital multimeter time.sleep(1) dmm_uin = NTBResource(dmm_uin_name, dmm_u_config) time.sleep(1) dmm_uout = NTBResource(dmm_uout_name, dmm_u_config) time.sleep(1) dmm_iin = NTBResource(dmm_iin_name, dmm_i_config) time.sleep(1) dmm_iout = NTBResource(dmm_iout_name, dmm_i_config) time.sleep(1) #dmm_v_name = 'TCPIP0::mmies006::INSTR' NTB-style setup = NTBSetup([dmm_uin, dmm_uout, dmm_iin, dmm_iout]) time.sleep(1) #set up DC load print("DC-load, init") load.initialize(DCLOAD_COMPORT, DCLOAD_BAUD) # Open a serial connection print("DC-load, set remote control", load.setRemoteControl()) print("DC-load, set max voltage to 15V", load.setMaxVoltage(15)) print("DC-load, set max power to 300W", load.setMaxPower(300)) print("DC-load, to constant current mode", load.setMode('cc')) print("DC-load, set first current", load.setCCCurrent(startCurrent)) print("DC-load, turn on", load.turnLoadOn()) # Open log file try: filename = sys.argv[1] except: timestr = time.strftime("%Y%m%d-%H%M%S") filename = timestr + ".txt" if not os.path.isfile(filename): with open(filename, 'w') as logdata: # Print header row_head = ( "Time Uin[V] Iin[A] Pin[W] Uout[V] Iout[A] Pout[W] n[]") print(row_head, file=logdata) print(row_head) try: for actualCurrent in range(startCurrent, endCurrent + stepSize, stepSize): #print("Set current to %i mA" % actualCurrent) load.setCCCurrent(actualCurrent) time.sleep(2) #wait until steady state # Arm and trig the instruments setup.write_all('INIT') #setup.write_all('*TRG') # Read out the measurment values res_uin_raw = dmm_uin.query('FETC?', 'values')[0] res_uout_raw = dmm_uout.query('FETC?', 'values')[0] res_iin_raw = dmm_iin.query('FETC?', 'values')[0] res_iout_raw = dmm_iout.query('FETC?', 'values')[0] res_time = time.strftime('%H:%M:%S') #scale if shunt is used res_uin = res_uin_raw res_uout = res_uout_raw res_iin = res_iin_raw * shuntGainIin res_iout = res_iout_raw * shuntGainIout #calculate power and efficiency res_pin = res_uin * res_iin res_pout = res_uout * res_iout try: #if division thru zero res_eff = res_pout / res_pin except: res_eff = 0 #store efficiency for plot efficiency.append(res_eff) current.append(actualCurrent / 1000) #Save measurements in logfile row_content = '{0} {1} {2} {3} {4} {5} {6} {7}' \ .format(res_time, res_uin, res_iin, res_pin, res_uout, res_iout, res_pout, res_eff) print(row_content, file=logdata) row_content_console = ("{0},Uin={1:2.3f}V,Iin={2:1.3f}A,Pin={3:3.3f}W,Uout={4:2.3f}V,Iout={5:2.3f}A,Pout={6:3.3f}W,n={7:1.4f}") \ .format(res_time, res_uin, res_iin, res_pin, res_uout, res_iout, res_pout, res_eff) print(row_content_console) except KeyboardInterrupt: print('Aborted') print("close file and disconnect digital multimeter") logdata.close() setup.close_all() #ramp down current print("Ramp down current") lastCurrentSetting = int(load.getCCCurrent()) for actualCurrent in range(lastCurrentSetting, startCurrent - stepSize, -stepSize): print("Set current to %i A" % actualCurrent) load.setCCCurrent(actualCurrent) time.sleep(0.1) print("turn off load and set local control") print(load.turnLoadOff()) print(load.setLocalControl()) plt.figure("Efficiency") plt.title("Efficiency") plt.xlabel('Current [A]') plt.ylabel('Efficiency []') plt.plot(current, efficiency) plt.grid(b=True, which='major', color='b', linestyle='-') plt.show() else: print('file already exists')
def test(condition): if condition: return "PASS" else: return "FAIL" tb = "\t\t" bus = smbus.Bus() dev = sbs.BQ78350(bus, 0x16 / 2) # BK 8514 load comes up as COM5 load8514 = dcload.DCLoad() load8514.Initialize(5, 38400) # COMx, Baud Rate load8514.SetRemoteControl() load8514.TurnLoadOff() load8514.SetMaxCurrent(40.0) load8514.SetMaxVoltage(60.0) load8514.SetMaxPower(500.0) load8514.SetMode('CC') load8514.SetCCCurrent(0.0) # BK XLN6024 comes up as COM4, and we have to subtract one (zero-based index) xln6024 = serial.Serial(4 - 1, 57600, timeout=1) xln6024.write("OUT OFF\r\n") xln6024.write("VOLT 51.0\r\n") xln6024.write("CURR 0.0\r\n")