예제 #1
0
    
    #the space between frequencies should be the tone freq resolution
    freqList = np.arange(startFreq,endFreq+dacFreqResolution, dacFreqResolution)
    nFreqs = len(freqList)
    freqListMHz = freqList/MHz
    
    fftResponses = np.zeros(nFreqs)
    ddcResponses = np.zeros(nFreqs)
    rawFftResponses = np.zeros(nFreqs)
    rawDdcResponses = np.zeros(nFreqs)
    quantFreqList = np.zeros(nFreqs)
    for iFreq,freq in enumerate(freqList):
        print 'freq {} of {}: {} MHz'.format(iFreq,nFreqs,freq/1.e6)
        waveFreqs = [freq]
        #next load up the signal LUT for the given frequency
        loadDict = loadWaveToMem(fpga,waveFreqs=waveFreqs,phases=None,sampleRate=sampleRate,nSamplesPerCycle=nSamplesPerCycle,nBytesPerMemSample=nBytesPerMemSample,nBitsPerSamplePair=nBitsPerSamplePair,memNames = memNames,nSamples=nSamples,memType=memType,dynamicRange=dynamicRange)
        quantFreqList[iFreq] = loadDict['quantizedFreqs'][0]

        fpga.write_int('sel_bch',selChanIndex)
        snapDict = snapDdc(bSnapAll=False,selBinIndex=selBinIndex,selChanIndex=selChanIndex,selChanStream=selChanStream,ddsAddrTrig=ddsAddrTrig)
        ddcResponses[iFreq] = np.mean(np.abs(snapDict['ddcOut']))
        rawDdcResponses[iFreq] = np.abs(snapDict['ddcOut'])[0]

        fftResponses[iFreq] = np.mean(np.abs(snapDict['bin']))
        rawFftResponses[iFreq] = np.abs(snapDict['bin'])[0]

    dbFftResponse = 20.*np.log10(fftResponses)
    dbRawFftResponse = 20.*np.log10(rawFftResponses)
    dbDdcResponse = 20.*np.log10(ddcResponses)
    dbRawDdcResponse = 20.*np.log10(rawDdcResponses)
예제 #2
0
파일: responsePlot.py 프로젝트: bmazin/SDR
    #print freqList
#    print 'freq range',freqList[0]/1.e6,freqList[-1]/1.e6
#    print 'freq step',(freqList[1]-freqList[0])/1.e6

    avgs = []
    responseVals = []
    oflws = []
    for iFreq,freq in enumerate(freqList):
        if iFreq % 25 == 0:
            print iFreq
        if memType == 'qdr':
            fpga.write_int(startRegisterName,0) #halt reading from mem while writing
        elif memType == 'bram':
            fpga.write_int(startRegisterName,1) #halt firmware writing from mem while writing

        loadWaveToMem(fpga,waveFreqs=[freq],phases=[0.],sampleRate=sampleRate,nSamplesPerCycle=nSamplesPerCycle,nSamples=nSamples,nBytesPerMemSample=nBytesPerQdrSample,nBitsPerSamplePair=nBitsPerSamplePair,memNames = qdrMemNames,dynamicRange=dynamicRange,memType=memType)
        time.sleep(.1)
        fpga.write_int(startRegisterName,1) #start reading from mem

        snapshotBin.arm()
        snapshotOverflow.arm()
        time.sleep(.1)

        fpga.write_int('snap_fft_trig',1)#trigger snapshots
        time.sleep(.05)

        binData = snapshotBin.read(timeout=10)['data']
        i0 = np.array(binData['i0'])
        i1 = np.array(binData['i1'])
        q0 = np.array(binData['q0'])
        q1 = np.array(binData['q1'])