Exemplo n.º 1
0
 def __init__(self, sampleRate, cgenFreq, rfBandwidth, rfFreq, rxGain,
              txGain):
     self.sdr = pyLMSS.pyLMS7002Soapy(0)  # pyLMS7002 device instance
     self.sampleRate = sampleRate  # sample rate for limeSDR
     self.cgenFreq = cgenFreq  # center generator frequency
     self.rfBandwidth = rfBandwidth  # RF bandwidth
     self.rfFreq = rfFreq  # RF frequency
     self.rxGain = rxGain  # Rx Gain
     self.txGain = txGain  # Tx Gain
     self.sdr.configureAntenna(startFreq)
Exemplo n.º 2
0
def ConnectSDR():
    # Connect to SDR and initialise
    limeSDR = pyLMSS.pyLMS7002Soapy(0)
    lms7002 = limeSDR.LMS7002
    # lms7002.verbose = 1000
    hardware.setVariables()
    ui.ConnectButton.setText(hardware.sdrName)
    ui.InitialisedMessage.setText("Loading VNA.hex to MCU")
    app.processEvents()
    mcuProgram(lms7002)  # Load vna.hex to MCU SRAM for measuring RSSI
    connectedButtons(True)
    ui.InitialisedMessage.setText("Ready")
Exemplo n.º 3
0
 def setVariables(self):
     #  set variables to the correct values for Lime-Mini or Lime-USB
     limeSDR = pyLMSS.pyLMS7002Soapy(0)
     if limeSDR.boardName == 'LimeSDRMini':
         self.sdrName = 'LimeSDR-Mini'
         self.fRef = 40e6
         self.iAmp = 5
         self.band1 = 1
         self.band2 = 0  # not relevant for Mini but presume still need to set it
         self.lnaGain = 6
         self.txChan = 'A'
     else:
         self.sdrName = 'LimeSDR-USB'
         self.fRef = 30.72e6
         self.iAmp = 20  # for TBB.CG_IAMP_TBB - controls front-end gain of TBB.  Seems to have little effect.
         self.band1 = 1  # for TRF.SEL_BAND1_TRF
         self.band2 = 0  # for TRF.SEL_BAND2_TRF
         self.lnaGain = 6  # was 8.  1 to 15 allowed
         self.pgaGain = 1
         self.lna = 'LNAL'  # not reqd?
Exemplo n.º 4
0
    def snaThread(self):
        radio = pyLMSS.pyLMS7002Soapy(0)
        self.sweeper = SingleToneSweeper(radio, self)
        webbrowser.open("http://127.0.0.1:55555", new=1)

        while True:
            if (self.snaRunMode == self.RUN_MODE_OFF):
                time.sleep(0.1)
                continue
            elif (self.snaRunMode == self.RUN_MODE_UPDATE_CONFIG):
                self.snaRunMode = self.RUN_MODE_ON

            start = time.time()

            self.sweeper.setGain(self.snaRxGain, self.snaTxGain)
            self.sweeper.setSampleRate(self.snaSampleRate)
            self.sweeper.sweep(self.snaStartFreq, self.snaEndFreq,
                               self.snaNumSteps)

            end = time.time()
            print(end - start)
Exemplo n.º 5
0
 def freqDepVar(self, startFreq):
     limeSDR = pyLMSS.pyLMS7002Soapy(0)
     #  <= 800MHz, tx pwr is +10dB for Band1 vs Band2.  It then falls ~'linearly' to ~equal at ~2100MHz.
     #  >= 2100MHz tx pwr is between 0dB and +15dB for Band 2.  At 2400MHz about +4dB and very peaky at 2900MHz
     if self.sdrName == 'LimeSDR-USB':
         if ui.TxAorB.value() == 0:
             self.txChan = 'A'
         else:
             self.txChan = 'B'
         if startFreq < 1500:
             self.lna = 'LNAL'
             self.band1 = 1
             self.band2 = 0
         elif startFreq >= 1500 and startFreq < 2100:
             self.lna = 'LNAH'
             self.band1 = 1
             self.band2 = 0
         else:
             self.lna = 'LNAH'
             self.band1 = 0
             self.band2 = 1
     else:
         limeSDR.configureAntenna(startFreq)  # doesn't this do all that above for the usb as well - see pySoapy?
Exemplo n.º 6
0
    RFE.G_LNA_RFE = lnaGain

    TxTSP.CMIX_BYP = 'BYP'
    RxTSP.GC_BYP = 'BYP'
    RxTSP.GCORRQ = 2047

    I = 0x7FFF
    Q = 0x8000
    TxTSP.loadDCIQ(I, Q)
    return pgaGain, lnaGain


#################################################################

logTxt("Searching for LimeSDR... ", end="")
limeSDR = pyLMSS.pyLMS7002Soapy(0)
if limeSDR.boardName == "LimeSDRMini":
    isMini = True
    lms7002 = limeSDR.LMS7002
    lms7002.fRef = 40e6
else:
    isMini = False
    lms7002 = limeSDR.LMS7002
    lms7002.fRef = 30.72e6

lms7002.MIMO = 'MIMO'
logTxt("FOUND")

# Initial configuration
logTxt("Tuning CGEN... ", end="")
startTime = timer()
Exemplo n.º 7
0
 def __init__(self):
     print("Lime SDR Initialized")
     self.soapy = pyLMS7002Soapy.pyLMS7002Soapy(verbose=1)
Exemplo n.º 8
0
    def Analyse(self, Calibration, Rx, measType):
        limeSDR = pyLMSS.pyLMS7002Soapy(0)
        lms7002 = limeSDR.LMS7002
        # Measure received signal power and phase. Phase is not plotted (yet) but can be saved to file.
        self.measType = measType
        self.res = []
        self.resPhase = []
        self.pgaGains = []  # stores pga gains set per Freq during calibration
        self.lnaGains = []  # stores lna gains set per Freq during calibration
        self.refPhase = 0
        power = []
        freq = []

        startFreq, endFreq, nFreq, centreFreq, spanFreq = getFreq()
        nFreq += 1  # to give equal frequency spacing around centre freq
        self.freqs = numpy.linspace(startFreq, endFreq, nFreq)

        hardware.freqDepVar(startFreq)
        LNA = hardware.lna
        TxTSP = lms7002.TxTSP[hardware.txChan]
        TRF = lms7002.TRF[hardware.txChan]
        setTransceiver(lms7002, Rx, startFreq)

        #  valid MAC values are [1,2,'A','B','R','RX','T','TX']. Tells MCU which channel to use for trx, tx, rx
        #  synthesisers SXT and SXR share register addresses so channel is identified by MAC setting
        lms7002.MAC = Rx

        for i in range(0, len(self.freqs)):
            lms7002.verbose = 0  # controls logging level.  Set to 1000 for more detail
            f = self.freqs[i] * 1e6

            # set freq and cal rx DC offset. Both Tx and Rx since rx is using tx PLL
            lms7002.SX['T'].setFREQ(f)
            lms7002.SX['T'].PD_LOCH_T2RBUF = 0  # set to use tx PLL (TDD Mode)

            if Calibration != '':  # Set gains for DUT measurement to the calibrated values
                pgaGain = Calibration.pgaGains[i]
                lnaGain = Calibration.lnaGains[i]
                lms7002.RBB[Rx].G_PGA_RBB = pgaGain
                lms7002.RFE[Rx].G_LNA_RFE = lnaGain
            else:
                # optimise Rx gain for best dynamic range, return the values and append them to cal lists
                pgaGain, lnaGain = adjustRxGain(lms7002, Rx, i)
                self.pgaGains.append(pgaGain)
                self.lnaGains.append(lnaGain)

            # set transmit and receive for testing? loopback?
            syncPhase(lms7002, Rx)

            # Check residual RSSI (DC offset?) at the set rx gain
            TRF.PD_TXPAD_TRF = 'OFF'  # Transmit power amplifier
            calRSSI = lms7002.RxTSP[Rx].RSSI
            if calRSSI > calThreshold:
                lms7002.calibration.rxDCLO(Rx, LNA, lnaGain=lnaGain, pgaGain=pgaGain)  # takes about 0.9s
                calRSSI = lms7002.RxTSP[Rx].RSSI
            TRF.PD_TXPAD_TRF = 'ON'

            # get the (averaged) RSSI value from the LimeSDR
            TxTSP.CMIX_BYP = 'USE'
            lms7002.RxTSP[Rx].GC_BYP = 'USE'  # turn on gain cor
            rssi = 1.0 * mcuRSSI(lms7002)
            TxTSP.CMIX_BYP = 'BYP'
            lms7002.RxTSP[Rx].GC_BYP = 'BYP'
            lms7002.RxTSP[Rx].GCORRQ = 2047

            # add the RSSI value to the magnitude list 'res', in position i
            self.res.append(rssi)
            DutPower = 20 * numpy.log10(rssi)

            # measure phase for freq i and append to list.
            if ui.Phase.isChecked():
                if Calibration == "":
                    if i == 0:
                        self.refPhase = mcuPhase(lms7002, Rx)
                    phase = mcuPhase(lms7002, Rx) - self.refPhase  # set cal phase ref=zero at start freq
                else:
                    phase = mcuPhase(lms7002, Rx) - Calibration.refPhase
                self.resPhase.append(phase)
            else:
                self.resPhase.append(0)

            # plot the results on the GUI graphwidget and update the progress indicators.
            freq.append(self.freqs[i])
            progress = int((i+1)*100/len(self.freqs))
            if Calibration == '':
                CalPower = 0
            else:
                CalPower = 20 * numpy.log10(Calibration.res[i])
            power.append(DutPower-CalPower)
            if measType == 'ReturnLoss':
                ui.calShortProgress.setValue(progress)
                rlCurve.setData(freq, power)
            else:
                ui.calThroughProgress.setValue(progress)
                throCurve.setData(freq, power)
            pyqtgraph.QtGui.QApplication.processEvents()  # force GUI update

        if ui.SaveBox.isChecked():
            reference = str(self)  # a unique filename reference for the measurement instance
            writeDataFile(reference[32:-1], self.measType, self.freqs, self.res, self.resPhase)
Exemplo n.º 9
0
    tmp = round(val * 10**decPlaces)
    tmp = tmp / 10**decPlaces
    formatString = "%." + str(decPlaces) + "f"
    return formatString % tmp


def userConfirmation(msg):
    userReady = 'n'
    while userReady != 'y':
        userReady = input(msg + '. Type y to continue. ')


################################
################################

sdr = pyLMSS.pyLMS7002Soapy(0)
sdr.configureAntenna(startFreq)

if fastSweep:
    sampleRate = 10e6
    rfBandwidth = 100e6
    cgenFrequency = 80e6
else:
    sampleRate = 5e6
    rfBandwidth = 100e6
    cgenFrequency = 80e6

rxGain = 20
txGain = 30
rfFrequency = startFreq