""" ARGPARSE """ if args.stepsleep and args.stepsleep >= 0: sleep_time_frequency_step = args.stepsleep logger.info("nfreq = " + str(frequencies_number)) logger.info("beginPower = " + str(frequencies_beginPower)) logger.info("endPower = " + str(frequencies_endPower)) """ Initialize oscilloscope for battery measurement """ while True: try: print "\n", "initializing USB instrument..." sOsci = USBTMCObject(USBInstruments['HALLE']['vendorID'], USBInstruments['HALLE']['productID'], USBInstruments['HALLE']['serialNo']) print "\tInstrument: " + str(sOsci.cmd_and_return("*IDN?")) OsciUSB.setup_measurement_mean(sOsci, channels=[1, 2], statistics=False, statistics_samples=-1) print "" break except LIB.Exceptions.USBException as e: print e time.sleep(5.0) pass """ Initialize FuncGen to feed lock in """ while args.external: try: print "\n", "initializing FUNC-GEN via socket..."
parser = argparse.ArgumentParser(description="gets the waveform from the oscilloscope via usbtmc") parser.add_argument("file") parser.add_argument("-c", "--compress", action="store_true") parser.add_argument("--start", type=int, default=1, help="first point") parser.add_argument("--stop", type=int, default=1000000, help="last point") parser.add_argument("-d", "--draw", help="just print the waveform specified by file (must be ROOT!)", action="store_true") parser.add_argument("-i", "--interactive", action="store_true") args = parser.parse_args() if FORCE_DRAW: args.draw = True if not args.draw: print "WARNING: Make sure, the part of the waveform you want to transfer is within the datapoint range of max. 1M!" # connect to oscilloscope sOsci = USBTMCObject(USBInstruments['LABOR']['vendorID'], USBInstruments['LABOR']['productID']) print "\tInstrument: " + str(sOsci.ask("*IDN?")) # set up for waveform transfer sOsci.cmd("DATA:SOURCE CH1") sOsci.cmd("DATA:START {0}".format(args.start)) sOsci.cmd("DATA:STOP {0}".format(args.stop)) sOsci.cmd("DATA:ENCDG ASCII") sOsci.cmd("DATA:WIDTH 2") sOsci.cmd("HEADER 1") sOsci.cmd("VERBOSE 1") sOsci.cmd("*WAI") header = sOsci.ask("WFMOUTPRE?") npoints = sOsci.ask("WFMOUTPRE:NR_PT?") xzero = float(re.findall(r'\b\d+\b', sOsci.ask("WFMOUTPRE:XZERO?"))[0])
else: odir = LIB.File.set_directory('./data/', ask=True) fileprefix = 'RecWvfm_' ndata = args.ndata if 10000000 >= args.ndata >= 1000 else 10000 if 10000000 > args.start >= 0: wvfm_start = args.start else: wvfm_start = 0 if 10000000 >= args.start + args.ndata > wvfm_start: wvfm_stop = args.start + args.ndata else: wvfm_stop = args.start + 1000 # connect to oscilloscope sOsci = USBTMCObject(USBInstruments['LABOR']['vendorID'], USBInstruments['LABOR']['productID']) print ("\tInstrument: " + str(sOsci.ask("*IDN?"))) #sOsci.cmd('PRE:XUNIT "{0}"'.format(args.xunit)) sOsci.cmd('HORIZONTAL:SCALE {0}'.format(args.scale)) sOsci.cmd('HORIZONTAL:RECORDLENGTH {0}'.format(ndata)) sOsci.cmd("HEADER 1") print sOsci.ask('HORIZONTAL:SCALE?') print sOsci.ask('HORIZONTAL:RECORDLENGTH?') header = sOsci.ask("WFMOUTPRE?") npoints = sOsci.ask("WFMOUTPRE:NR_PT?") xzero = float(sOsci.ask("WFMOUTPRE:XZERO?").strip().split(' ')[-1].replace('"','')) xincr = float(sOsci.ask("WFMOUTPRE:XINCR?").strip().split(' ')[-1].replace('"', ''))
PID_PROP_RANGE = np.linspace(INI_PROP_L, INI_PROP_U, INI_N_STEPS_PROP) PID_INTG_RANGE = np.linspace(INI_INTG_L, INI_INTG_U, INI_N_STEPS_INTG) PID_MAP_PI = itertools.product(PID_PROP_RANGE, PID_INTG_RANGE) # # ___MAIN___ # # CONNECT TO DEVICES try: if not args.debug: LDC = SerialObject(SerialInstruments['LDC501']) PID = SerialObject(SerialInstruments['SIM960'], wait=0.01) if not args.noosci: OSC = USBTMCObject(USBInstruments['LABOR']['vendorID'], USBInstruments['LABOR']['productID']) TEM = GPIOSensor(GPIOSensors['THERM_LAB']) PID.cmd("*CLS") print "Instrument (LDC):\n\t" + LDC.ask("*IDN?") print "Instrument (PID):\n\t" + PID.ask("*IDN?") if not args.noosci: print "Instrument (OSC):\n\t" + OSC.ask("*IDN?") if TEM.read() is None: raise ValueError() LDC.cmd("TOKN ON") LDC.cmd("LDON OFF;MODU OFF; RNGE LOW; SMOD CC; SIBW LOW; SYND 5") time.sleep(1)
from datetime import datetime import gzip import numpy as np import os, re, sys, time # argparse if len(sys.argv) < 2: odir = './' else: odir = str(sys.argv[1]).strip() fileprefix = 'RecWvfm_' wvfm_start, wvfm_stop = 0, 1000000 # connect to oscilloscope sOsci = USBTMCObject(USBInstruments['LABOR']['vendorID'], USBInstruments['LABOR']['productID']) print ("\tInstrument: " + str(sOsci.ask("*IDN?"))) # set up for single acquisition print sOsci.ask("ACQ:MAXS?") sOsci.cmd("ACQ:MODE HIRes") sOsci.cmd("ACQ:STOPAfter SEQ") sOsci.cmd("ACQ:STATE RUN") # set up for waveform transfer sOsci.cmd("DATA:SOURCE CH1") sOsci.cmd("DATA:START {0}".format(wvfm_start)) sOsci.cmd("DATA:STOP {0}".format(wvfm_stop)) sOsci.cmd("DATA:ENCDG SRI") sOsci.cmd("DATA:WIDTH 2") sOsci.cmd("HEADER 1")