def __init__( self, ip='10.0.0.112', params='/mnt/data0/neelay/MkidDigitalReadout/DataReadout/ChannelizerControls/DarknessFpga_V2.param', freqList=None, toneAttenList=None, resIDList=None, loFreq=5.e9, adcAtten=31.75, globalDacAtten=9): ''' INPUTS: ip: ROACH2 IP Address params: Roach2Controls parameter file loFreq: LO Frequency in Hz adcAtten: attenuation value (dB) of IF board ADC attenuator global Dac Atten: physical DAC attenuation freqList: list of tone frequencies in frequency comb to optimize (should be entire comb; no need to divide into separate sidebands resIDList: list of corresponding resonator IDs toneAttenList: list of corresponding resonator attenuation values ''' if freqList is None or toneAttenList is None: raise Exception('Must specify frequencies and attenuations') if len(freqList) != len(toneAttenList): raise ValueError( 'Frequency and attenuation lists must be the same length!') self.roach = Roach2Controls(ip, params, True, False) self.loFreq = loFreq self.adcAtten = adcAtten self.toneAttenList = toneAttenList self.globalDacAtten = globalDacAtten self.freqList = freqList self.resIDList = resIDList aboveLOInds = np.where(freqList >= loFreq)[0] belowLOInds = np.where(freqList < loFreq)[0] self.freqListLow = freqList[belowLOInds] self.freqListHigh = freqList[aboveLOInds] self.toneAttenListLow = toneAttenList[belowLOInds] self.toneAttenListHigh = toneAttenList[aboveLOInds] self.finalPhaseListLow = np.zeros(len(self.freqListLow)) self.finalPhaseListHigh = np.zeros(len(self.freqListHigh)) self.finalIQRatioListLow = np.ones(len(self.freqListLow)) self.finalIQRatioListHigh = np.ones(len(self.freqListHigh))
def __init__(self, roachNumber, config): """ INPUTS: roachNumber - config - ConfigParser Object holding all the parameters needed """ super(InitStateMachine, self).__init__() self.state = [ InitStateMachine.UNDEFINED ] * InitStateMachine.NUMCOMMANDS # This holds the state for each command type self.num = int(roachNumber) self.commandQueue = Queue() self.config = config FPGAParamFile = self.config.get('Roach ' + str(self.num), 'FPGAParamFile') ip = self.config.get('Roach ' + str(self.num), 'ipaddress') self.roachController = Roach2Controls(ip, FPGAParamFile, True, False)
""" Author: Alex Walter Date: June 2, 2018 This code sets all the roach attenuators to maximum Usage: $python maxAttens.py 222 223 """ import sys from Roach2Controls import Roach2Controls if __name__ == '__main__': for arg in sys.argv[1:]: ip = '10.0.0.' + arg params = 'DarknessFpga_V2.param' roach = Roach2Controls(ip, params, True) roach.connect() roach.changeAtten(0, 31.75) roach.changeAtten(1, 31.75) roach.changeAtten(2, 31.75) roach.changeAtten(3, 31.75)
fpga.write_int('adc_in_pos_phs', 1) incrementMmcmPhase(fpga, stepSize=totalChange) fpga.write_int('adc_in_pos_phs', 0) return {'failPattern': failPattern, 'stepIndices': stepIndices} if __name__ == '__main__': if len(sys.argv) > 1: ip = '10.0.0.' + sys.argv[1] else: print 'Usage:', sys.argv[0], 'roachNum' print ip roach = Roach2Controls( ip, '/mnt/data0/MkidDigitalReadout/DataReadout/ChannelizerControls/DarknessFpga_V2.param', True, False) roach.connect() roach.initializeV7UART() roach.sendUARTCommand(0x4) time.sleep(15) time.sleep(.01) if not roach.fpga.is_running(): print 'Firmware is not running. Start firmware, and calibrate qdr first!' exit(0) roach.fpga.get_system_information() print 'Fpga Clock Rate:', roach.fpga.estimate_fpga_clock() roach.fpga.write_int('run', 1) busDelays = [14, 18, 14, 13]
for i in range(-5,-1): if (sortedSpectrum[-1]-sortedSpectrum[i])>10: spectrumFlag=1 break return spectrumFlag if __name__=='__main__': roachList = [] specDictList = [] plotSnaps = True startAtten = 40 for arg in sys.argv[1:]: ip = '10.0.0.'+arg roach = Roach2Controls(ip, 'DarknessFpga_V2.param', True) roach.connect() roach.initializeV7UART() roachList.append(roach) for roach in roachList: atten = checkErrorsAndSetAtten(roach, startAtten) print 'Roach', roach.ip[-3:], 'atten =', atten print 'Checking for spikes in ADC Spectrum...' if plotSnaps: specFigList = [] specAxList = [] for roach in roachList: snapDict = roach.snapZdok() specDict = streamSpectrum(snapDict['iVals'], snapDict['qVals'])
# Get the configuration print "===> Read configuration" config = ConfigParser.ConfigParser() config.read('init.cfg') print "Configuration read from init.cfg" for section in config.sections(): print " Configuration section:", section for item in config.items(section): print " %20s : %s" % item # Connect print "===>Connect" ipaddress = config.get('Roach %d' % roachNumber, 'ipaddress') FPGAParamFile = config.get('Roach %d' % roachNumber, 'FPGAParamFile') roachController = Roach2Controls(ipaddress, FPGAParamFile, True, False) roachController.connect() # Program V6 print "===>Program V6" fpgPath = config.get('Roach %d' % roachNumber, 'fpgPath') roachController.fpga.upload_to_ram_and_program(fpgPath) fpgaClockRate = roachController.fpga.estimate_fpga_clock() print "Fpga Clock Rate:", fpgaClockRate # Initialize V7 print "===>Initialize V7" waitForV7Ready = config.getboolean('Roach %d' % roachNumber, 'waitForV7Ready') roachController.initializeV7UART(waitForV7Ready=waitForV7Ready) print 'initialized uart' roachController.initV7MB()
nargs='+', type=str, help='List of ROACH numbers (last 3 digits of IP)') parser.add_argument('-s', '--plot-spectrum', action='store_true', help='Plot spectrum of snapshot') clOptions = parser.parse_args() roachList = [] specDictList = [] plotSnaps = True startAtten = 40 for roachNum in clOptions.roaches: ip = '10.0.0.' + roachNum roach = Roach2Controls(ip, 'darknessfpga.param', True) roach.connect() roach.initializeV7UART() roachList.append(roach) snapDict = roach.snapZdok() specDict = streamSpectrum(snapDict['iVals'], snapDict['qVals']) specDictList.append(specDict) figList = [] axList = [] for i, specDict in enumerate(specDictList): fig, ax = plt.subplots(1, 1) ax.plot(specDict['times'], specDict['signal'].real, color='b', label='I')