# To setup a measurement (will be useful for another piece of software): # 1. Set Measurement Group # 2. Set Measurement # 3. Set View # 4. Set Units # 5. Set display scale and references #-- Pause the measurement (has no effect if measurement is done) swPausedMeas = False instInitialStatus = interpretInstStatusWord(int(SR785.query("INST?"))) wstderr("\nInstrument status:\n" + PPstderr.pformat(instInitialStatus)+"\n\n") #if instInitialStatus['STRT'] and not(instInitialStatus['PAUS']) and PAUSE_MEAS: if instInitialStatus['STRT'] and not(instInitialStatus['PAUS']) and PAUSE_MEAS: wstderr("\nPausing current measurement...\n") SR785.tell("PAUS") swPausedMeas = True measParams = { 'display' : {}, 'frequency' : {}, 'sweptSineSrc' : {}, 'input' : {}, 'averaging' : {}, 'trigger' : {}, 'status' : instInitialStatus } meas = {} #-- Grab all meta-data pertinent to a swept sine measurement... wstderr("\nQuerying all instrument parameters...\n")
#keys.sort() #for key in keys: # f.write(key + "=" + str(metaDataDict[key]) + "\r\n") #f.write("completeConfig=" + completeConfigStr + "\r\n") integral = np.float64(0) iterNum = np.uint64(1) try: # TODO: does this actually tell you current freq when in sweep mode? # if so, great, that's the desired behavior. # TODO: Make sure that nothing I do changes the ref sync behavior #-- Grab initial DDS frequency freqStr = DDS.query("FREQ?") oldVal = np.float64(freqStr) #-- Set DDS in sine mode, if not already so DDS.tell("AM:STATe OFF;:FM:STATe OFF;:FSKey:STATe OFF;:SWEep:STATe OFF;:BURSt:STATe OFF") time.sleep(0.1) #DDS.tell("FUNC SIN") #DDS.tell("FREQ " + freqStr) with open(qualDataFname, 'w') as f: while True: c = csv.writer(f) #-- Beginning of time window sampTime21 = time.time() #-- Grab sample from error measurement sample = tekScope.query("MEASU:MEAS1:VAL?") #-- Check if it is off-scale (high or low) if sample == "9.9E37":
from __future__ import division import sys from instrumentComms import InstrumentComms def wstdout(txt): sys.stdout.write(txt) sys.stdout.flush() def wstderr(txt): sys.stderr.write(txt) sys.stderr.flush() if __name__ == "__main__": #commsType = "Ethernet" ipAddress = "128.118.112.2" httpPort = 80 try: #-- Set up with serial port comms instrument = InstrumentComms(useSerial=True) instrument.simpleSerial() commsType = "serial" except: #-- If that failed, try to set up with Ethernet comms instrument = InstrumentComms(useEthernet=True, ipAddress=ipAddress) commsType = "Ethernet" instrument.tell(sys.argv[1])