Hello. My task is to make a broadband spectrum analyzer on the usrp b200
board. For this, the standard functions for reading samples in python are
not suitable for me. Therefore, I edited them. When reading samples using
the start_con method, I cannot specify a band greater than 5 MHz.
Therefore, I use the num_sams_and_done method. But I have problems with
him. The fact is that my frequency which I know appears in the wrong place.
For example, I generate a frequency of 910 MHz and it appears at 930 MHz
(with a bandwidth of 20 MHz). I can not understand what caused it. Here are
my reading functions in two ways. I would be extremely grateful for the
help.





def test_reciev(self,freq,bandwich):
    complex_buffs=np.array([])
    buffs = np.array([])
    result = np.empty((len([0]), self.samples), dtype=np.complex64)

    for i, freqq in enumerate(freq):

        recv_samps = 0
        #self.usrp.set_rx_rate(bandwich[i])
        k=uhd.types.TuneRequest(freqq)
        #k.args(uhd.types.device_addr("mode_n=integer"))
        self.usrp.set_rx_freq(k)
        self.stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.start_cont)
        self.stream_cmd.stream_now = True
        self.streamer_rx.issue_stream_cmd(self.stream_cmd)
        while self.usrp.get_rx_sensor("lo_locked").to_bool() != True:
            continue

        samps = np.array([], dtype=np.complex64)
        while recv_samps < self.samples:

            samps = self.streamer_rx.recv(self.recv_buff, self.metadata_rx)
            if self.metadata_rx.error_code !=
lib.types.rx_metadata_error_code.none:
                print(self.metadata_rx.strerror())
            if samps:
                real_samps = min(self.samples - recv_samps, samps)
                result[:, recv_samps:recv_samps + real_samps] =
self.recv_buff[:, 0:real_samps]
                recv_samps += real_samps
        #print (self.usrp.get_rx_sensor('rssi'))
        #print(self.streamer_rx.get_max_num_samps())
        #while samps:
        #    samps = self.streamer_rx.recv(self.recv_buff, self.metadata_rx)


        #self.stream_cmd.time_spec = lib.types.time_spec(0)
        self.stream_cmd = lib.types.stream_cmd(lib.types.stream_mode.stop_cont)
        self.streamer_rx.issue_stream_cmd(self.stream_cmd)

        complex_buffs=np.append(complex_buffs,result).ravel()
        #correct_result=result
        correct_result_1=result-(np.mean(result.real)+np.mean(result.imag)*1j)
        #correct_result.real=result.real-np.mean(result.real)
        #correct_result.imag = result.imag - np.mean(result.imag)

        PSD =  self.fft_test(result)


        #PSD[8188:8202]=np.mean(PSD[8180:8188])


        buffs = np.append(buffs,PSD)



    return complex_buffs,
buffs#np.append(buffs[value.samples:],buffs[:value.samples])



def test_reciev(self,freq,bandwich):
    complex_buffs=np.array([])
    buffs = np.array([])
    result = np.empty((len([0]), self.samples), dtype=np.complex64)

    for i, freqq in enumerate(freq):

        recv_samps = 0
        #self.usrp.set_rx_rate(bandwich[i])
        k=uhd.types.TuneRequest(freqq)
        #k.args(uhd.types.device_addr("mode_n=integer"))
        self.usrp.set_rx_freq(k)

        while self.usrp.get_rx_sensor("lo_locked").to_bool() != True:
            continue


        while recv_samps < self.samples:

            samps = self.streamer_rx.recv(self.recv_buff, self.metadata_rx)
            if self.metadata_rx.error_code !=
lib.types.rx_metadata_error_code.none:
                print(self.metadata_rx.strerror())
            if samps:
                real_samps = min(self.samples - recv_samps, samps)
                result[:, recv_samps:recv_samps + real_samps] =
self.recv_buff[:, 0:real_samps]
                recv_samps += real_samps
        #print (self.usrp.get_rx_sensor('rssi'))


        self.stream_cmd.time_spec = lib.types.time_spec(0)
        self.streamer_rx.issue_stream_cmd(self.stream_cmd)

        complex_buffs=np.append(complex_buffs,result).ravel()
        correct_result=result
        correct_result_1=result-(np.mean(result.real)+np.mean(result.imag)*1j)
        correct_result.real=result.real-np.mean(result.real)
        correct_result.imag = result.imag - np.mean(result.imag)

        PSD =  self.fft_test(result)


        #PSD[8188:8202]=np.mean(PSD[8180:8188])


        buffs = np.append(buffs,PSD)



    return complex_buffs,
buffs#np.append(buffs[value.samples:],buffs[:value.samples])
_______________________________________________
USRP-users mailing list
USRP-users@lists.ettus.com
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com

Reply via email to