Post Go back to editing

Pluto `Frequency Sweep Example gnu radio

Category: Software
Product Number: pluto

hi i m a novice, need help in translating the GNURADIO bandlimited threshold detector -wiki.gnuradio.org/index.php

the purpose is the sweep the spectrum fro 70 mhz to 6ghz and record the active frequencies with their power 

can anyone help me out - i have Analog Devices PlutoSDR Rev.B (Z7010-AD9364) connected to my windows 10 pc

Thread Notes

Parents
  • To change the LO frequency in GR programmatically, there are two ways that come to mind. You could restart the flowgraph each time with a new LO setting for pluto. This is just a small change to the generated flowgraph in Python and introduce a loop. Or you could use the Attribute Sink block to do an attribute update for the LO frequency property of the device: https://wiki.analog.com/resources/tools-software/linux-drivers/iio-transceiver/ad9361#local_oscillator_control_lo 

    -Travis

  • hi i have tried but failed, see attached flowgraph drive.google.com/.../1EV5vlCO6T93sB7cd1FBxEsR5SQJ05sOP, can you help to correct what am i missing to show the full spectrum instead of the moving spectrum.

    also how to connect it as input to the detector in the bandlimited threshold detector example

    i tried in python too but something is wrong there also. i cant get the whole spectrum to be displayed at one go  - python code also in the same folder shared above myscanner.py

  • I cannot access that link. Can you post the raw text here through the "insert" option or use pastebin/github-gist?

    -Travis

  • What is the problem you are observing?

    -Travis

  • i am only able to get a portion of the spectrum value charted whereas i want to show the full spectrum range that the sdr has. Also i could not figure out how to merge the bandwidth threshold logger flowgrah to be adapted to a realword sdr

  • i am only able to get a portion of the spectrum value charted whereas i want to show the full spectrum range that the sdr has.

    What is limiting this?

    -Travis

  • Dear Travis,

    my knownledge is limiting me create a flowgraph suitable for the purpose


    please have a look at the flowgraph and advise what needs to be corrected, currently the fft is on autoscroll for the current bandwidth in centre.

    Appreciate your support

    code as below for grc

    options:
      parameters:
        author: navneet
        catch_exceptions: 'True'
        category: '[GRC Hier Blocks]'
        cmake_opt: ''
        comment: ''
        copyright: ''
        description: ''
        gen_cmake: 'On'
        gen_linking: dynamic
        generate_options: qt_gui
        hier_block_src_path: '.:'
        id: sweeperbyalienai23
        max_nouts: '0'
        output_language: python
        placement: (0,0)
        qt_qss_theme: ''
        realtime_scheduling: ''
        run: 'True'
        run_command: '{python} -u {filename}'
        run_options: prompt
        sizing_mode: fixed
        thread_safe_setters: ''
        title: Frequency Sweeper
        window_size: (1000,1000)
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [8, 8]
        rotation: 0
        state: enabled
    
    blocks:
    - name: bandwidthrx
      id: variable
      parameters:
        comment: ''
        value: '5200000'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1168, 8.0]
        rotation: 0
        state: true
    - name: freq
      id: variable
      parameters:
        comment: ''
        value: python_mod.sweeper(fun_prob)
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [552, 16.0]
        rotation: 0
        state: enabled
    - name: freqmim
      id: variable_qtgui_range
      parameters:
        comment: ''
        gui_hint: ''
        label: 'Frequency Min '
        min_len: '200'
        orient: QtCore.Qt.Horizontal
        rangeType: float
        start: '0'
        step: '1000000'
        stop: '6000000000'
        value: '70000000'
        widget: counter_slider
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1336, 4.0]
        rotation: 0
        state: true
    - name: frequency
      id: variable_qtgui_label
      parameters:
        comment: ''
        formatter: None
        gui_hint: ''
        label: 'Frequency '
        type: real
        value: freq
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [680, 4.0]
        rotation: 0
        state: true
    - name: fun_prob
      id: variable_function_probe
      parameters:
        block_id: probSign
        comment: ''
        function_args: ''
        function_name: level
        poll_rate: '10'
        value: '0'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [8, 428.0]
        rotation: 0
        state: true
    - name: samp_rate
      id: variable
      parameters:
        comment: ''
        value: '56000000'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [8, 120.0]
        rotation: 0
        state: enabled
    - name: variable_qtgui_label_0
      id: variable_qtgui_label
      parameters:
        comment: ''
        formatter: None
        gui_hint: ''
        label: amp
        type: real
        value: '0'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [8, 188.0]
        rotation: 0
        state: true
    - name: analog_noise_source_x_0
      id: analog_noise_source_x
      parameters:
        affinity: ''
        alias: ''
        amp: '1'
        comment: ''
        maxoutbuf: '0'
        minoutbuf: '0'
        noise_type: analog.GR_GAUSSIAN
        seed: '0'
        type: float
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [280, 164.0]
        rotation: 0
        state: disabled
    - name: analog_sig_source_x_0
      id: analog_sig_source_x
      parameters:
        affinity: ''
        alias: ''
        amp: '1'
        comment: ''
        freq: '0'
        maxoutbuf: '0'
        minoutbuf: '0'
        offset: '0'
        phase: '0'
        samp_rate: samp_rate
        type: complex
        waveform: analog.GR_CONST_WAVE
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [8, 284.0]
        rotation: 0
        state: disabled
    - name: analog_sig_source_x_1
      id: analog_sig_source_x
      parameters:
        affinity: ''
        alias: ''
        amp: '1'
        comment: ''
        freq: freq
        maxoutbuf: '0'
        minoutbuf: '0'
        offset: '0'
        phase: '0'
        samp_rate: samp_rate
        type: float
        waveform: analog.GR_COS_WAVE
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [280, 4.0]
        rotation: 0
        state: disabled
    - name: blocks_add_xx_0
      id: blocks_add_xx
      parameters:
        affinity: ''
        alias: ''
        comment: ''
        maxoutbuf: '0'
        minoutbuf: '0'
        num_inputs: '2'
        type: float
        vlen: '1'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [600, 136.0]
        rotation: 0
        state: disabled
    - name: blocks_throttle_0
      id: blocks_throttle
      parameters:
        affinity: ''
        alias: ''
        comment: ''
        ignoretag: 'True'
        maxoutbuf: '0'
        minoutbuf: '0'
        samples_per_second: samp_rate
        type: complex
        vlen: '1'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [280, 328.0]
        rotation: 0
        state: disabled
    - name: blocks_throttle_0_0
      id: blocks_throttle
      parameters:
        affinity: ''
        alias: ''
        comment: ''
        ignoretag: 'True'
        maxoutbuf: '0'
        minoutbuf: '0'
        samples_per_second: samp_rate*4
        type: complex
        vlen: '1'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1008, 512.0]
        rotation: 0
        state: disabled
    - name: fft_vxx_0
      id: fft_vxx
      parameters:
        affinity: ''
        alias: ''
        comment: ''
        fft_size: '1024'
        forward: 'True'
        maxoutbuf: '0'
        minoutbuf: '0'
        nthreads: '1'
        shift: 'True'
        type: float
        window: window.blackmanharris(1024)
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1256, 420.0]
        rotation: 0
        state: disabled
    - name: iio_pluto_source_0
      id: iio_pluto_source
      parameters:
        affinity: ''
        alias: ''
        bandwidth: bandwidthrx
        bbdc: 'True'
        buffer_size: '32768'
        comment: ''
        filter: ''
        filter_source: '''Auto'''
        fpass: '0'
        frequency: freq
        fstop: '0'
        gain1: '''manual'''
        len_tag_key: packet_len
        manual_gain1: '64'
        maxoutbuf: '0'
        minoutbuf: '0'
        quadrature: 'True'
        rfdc: 'True'
        samplerate: ' 1920000'
        type: fc32
        uri: uri
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [760, 236.0]
        rotation: 0
        state: true
    - name: logpwrfft_x_0
      id: logpwrfft_x
      parameters:
        affinity: ''
        alias: ''
        average: 'False'
        avg_alpha: '1.0'
        comment: ''
        fft_size: '1024'
        frame_rate: '30'
        maxoutbuf: '0'
        minoutbuf: '0'
        ref_scale: '2'
        sample_rate: samp_rate
        shift: 'False'
        type: complex
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1104, 224.0]
        rotation: 0
        state: disabled
    - name: probSign
      id: blocks_probe_signal_x
      parameters:
        affinity: ''
        alias: ''
        comment: ''
        type: complex
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1080, 416.0]
        rotation: 0
        state: enabled
    - name: probSign1
      id: blocks_probe_signal_x
      parameters:
        affinity: ''
        alias: ''
        comment: ''
        type: complex
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [520, 408.0]
        rotation: 0
        state: disabled
    - name: python_mod
      id: epy_module
      parameters:
        alias: ''
        comment: ''
        source_code: "# this module will be imported in the into your flowgraph\nf1=2380000000\n\
          f2=2420000000\nf=f1\nstep = 100000\n\ndef sweeper(prob_lvl):\n    global f1,f2,f,step\n\
          \    if prob_lvl:\n        f +=step\n    if f>f2:f=f1\n\n    return f"
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [848, 16.0]
        rotation: 0
        state: true
    - name: qtgui_freq_sink_x_0
      id: qtgui_freq_sink_x
      parameters:
        affinity: ''
        alias: ''
        alpha1: '1.0'
        alpha10: '1.0'
        alpha2: '1.0'
        alpha3: '1.0'
        alpha4: '1.0'
        alpha5: '1.0'
        alpha6: '1.0'
        alpha7: '1.0'
        alpha8: '1.0'
        alpha9: '1.0'
        autoscale: 'False'
        average: '1.0'
        axislabels: 'True'
        bw: samp_rate
        color1: '"blue"'
        color10: '"dark blue"'
        color2: '"red"'
        color3: '"green"'
        color4: '"black"'
        color5: '"cyan"'
        color6: '"magenta"'
        color7: '"yellow"'
        color8: '"dark red"'
        color9: '"dark green"'
        comment: ''
        ctrlpanel: 'True'
        fc: freq
        fftsize: '1024'
        freqhalf: 'True'
        grid: 'False'
        gui_hint: ''
        label: Relative Gain
        label1: ''
        label10: ''''''
        label2: ''''''
        label3: ''''''
        label4: ''''''
        label5: ''''''
        label6: ''''''
        label7: ''''''
        label8: ''''''
        label9: ''''''
        legend: 'True'
        maxoutbuf: '0'
        minoutbuf: '0'
        name: '""'
        nconnections: '1'
        norm_window: 'False'
        showports: 'False'
        tr_chan: '0'
        tr_level: '0.0'
        tr_mode: qtgui.TRIG_MODE_FREE
        tr_tag: '""'
        type: complex
        units: dB
        update_time: '0.10'
        width1: '1'
        width10: '1'
        width2: '1'
        width3: '1'
        width4: '1'
        width5: '1'
        width6: '1'
        width7: '1'
        width8: '1'
        width9: '1'
        wintype: window.WIN_BLACKMAN_hARRIS
        ymax: '10'
        ymin: '-140'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1368, 188.0]
        rotation: 0
        state: enabled
    - name: qtgui_time_sink_x_0
      id: qtgui_time_sink_x
      parameters:
        affinity: ''
        alias: ''
        alpha1: '1.0'
        alpha10: '1.0'
        alpha2: '1.0'
        alpha3: '1.0'
        alpha4: '1.0'
        alpha5: '1.0'
        alpha6: '1.0'
        alpha7: '1.0'
        alpha8: '1.0'
        alpha9: '1.0'
        autoscale: 'False'
        axislabels: 'True'
        color1: blue
        color10: dark blue
        color2: red
        color3: green
        color4: black
        color5: cyan
        color6: magenta
        color7: yellow
        color8: dark red
        color9: dark green
        comment: ''
        ctrlpanel: 'False'
        entags: 'True'
        grid: 'False'
        gui_hint: ''
        label1: Signal 1
        label10: Signal 10
        label2: Signal 2
        label3: Signal 3
        label4: Signal 4
        label5: Signal 5
        label6: Signal 6
        label7: Signal 7
        label8: Signal 8
        label9: Signal 9
        legend: 'True'
        marker1: '-1'
        marker10: '-1'
        marker2: '-1'
        marker3: '-1'
        marker4: '-1'
        marker5: '-1'
        marker6: '-1'
        marker7: '-1'
        marker8: '-1'
        marker9: '-1'
        name: '""'
        nconnections: '1'
        size: '1024'
        srate: samp_rate
        stemplot: 'False'
        style1: '1'
        style10: '1'
        style2: '1'
        style3: '1'
        style4: '1'
        style5: '1'
        style6: '1'
        style7: '1'
        style8: '1'
        style9: '1'
        tr_chan: '0'
        tr_delay: '0'
        tr_level: '0.0'
        tr_mode: qtgui.TRIG_MODE_FREE
        tr_slope: qtgui.TRIG_SLOPE_POS
        tr_tag: '""'
        type: complex
        update_time: '0.10'
        width1: '1'
        width10: '1'
        width2: '1'
        width3: '1'
        width4: '1'
        width5: '1'
        width6: '1'
        width7: '1'
        width8: '1'
        width9: '1'
        ylabel: Amplitude
        ymax: '1'
        ymin: '-1'
        yunit: '""'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [520, 308.0]
        rotation: 0
        state: disabled
    - name: qtgui_vector_sink_f_0
      id: qtgui_vector_sink_f
      parameters:
        affinity: ''
        alias: ''
        alpha1: '1.0'
        alpha10: '1.0'
        alpha2: '1.0'
        alpha3: '1.0'
        alpha4: '1.0'
        alpha5: '1.0'
        alpha6: '1.0'
        alpha7: '1.0'
        alpha8: '1.0'
        alpha9: '1.0'
        autoscale: 'False'
        average: '1.0'
        color1: '"blue"'
        color10: '"dark blue"'
        color2: '"red"'
        color3: '"green"'
        color4: '"black"'
        color5: '"cyan"'
        color6: '"magenta"'
        color7: '"yellow"'
        color8: '"dark red"'
        color9: '"dark green"'
        comment: ''
        grid: 'False'
        gui_hint: ''
        label1: ''
        label10: ''
        label2: ''
        label3: ''
        label4: ''
        label5: ''
        label6: ''
        label7: ''
        label8: ''
        label9: ''
        maxoutbuf: '0'
        minoutbuf: '0'
        name: '""'
        nconnections: '1'
        ref_level: '0'
        showports: 'False'
        update_time: '0.10'
        vlen: '1024'
        width1: '1'
        width10: '1'
        width2: '1'
        width3: '1'
        width4: '1'
        width5: '1'
        width6: '1'
        width7: '1'
        width8: '1'
        width9: '1'
        x_axis_label: '"x-Axis"'
        x_start: '0'
        x_step: '1.0'
        x_units: '""'
        y_axis_label: '"y-Axis"'
        y_units: '""'
        ymax: '10'
        ymin: '-140'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1384, 300.0]
        rotation: 0
        state: disabled
    - name: uri
      id: parameter
      parameters:
        alias: ''
        comment: ''
        hide: none
        label: URI
        short_id: ''
        type: ''
        value: '"ip:192.168.2.1"'
      states:
        bus_sink: false
        bus_source: false
        bus_structure: null
        coordinate: [1000, 4.0]
        rotation: 0
        state: enabled
    
    connections:
    - [analog_noise_source_x_0, '0', blocks_add_xx_0, '1']
    - [analog_sig_source_x_0, '0', blocks_throttle_0, '0']
    - [analog_sig_source_x_1, '0', blocks_add_xx_0, '0']
    - [blocks_add_xx_0, '0', qtgui_freq_sink_x_0, '0']
    - [blocks_throttle_0, '0', probSign1, '0']
    - [blocks_throttle_0, '0', qtgui_time_sink_x_0, '0']
    - [blocks_throttle_0_0, '0', logpwrfft_x_0, '0']
    - [fft_vxx_0, '0', blocks_throttle_0_0, '0']
    - [iio_pluto_source_0, '0', fft_vxx_0, '0']
    - [iio_pluto_source_0, '0', probSign, '0']
    - [iio_pluto_source_0, '0', qtgui_freq_sink_x_0, '0']
    - [logpwrfft_x_0, '0', qtgui_vector_sink_f_0, '0']
    
    metadata:
      file_format: 1

    next is python_mod code

    # this module will be imported in the into your flowgraph
    f1=2380000000
    f2=2420000000
    f=f1
    step = 100000

    def sweeper(prob_lvl):
    global f1,f2,f,step
    if prob_lvl:
    f +=step
    if f>f2:f=f1

    return f
  • What is your dwell time requirement?

    Note too that when you change frequency the data may not reflect the updated frequency as there is natural elasticity in the system. This delay would need to be measured.

    -Travis

  • Kindly explain what do you mean by dwell time.

    the user should be able to see the full spectrum of the sdr and the signal power for the frequency while it gets scanned and the scanning and display should be as fast as the capability of the sdr.

    Please advise if this answers you queries to suggest a solution

  • Dwell time is how long you remain at one frequency.

    -Travis

Reply Children
  • ok travis lets say 3 milli seconds that means the radio will be able to visit the same freq atlesst twict in a second for the bandwidth between 70 Mhz - 6 Ghz

    Hope i am correct

  • Maybe I can frame this a bit for you. So in GNU Radio the way you are controlling frequency updates relative to the data stream is purely asynchronous. From the perspective of general software control of the LO frequency and data stream, they are asynchronous.  This creates a scenarios like I mentioned in a previous post:

    Note too that when you change frequency the data may not reflect the updated frequency as there is natural elasticity in the system. This delay would need to be measured

    Without highly customizing the HDL and software control the only way to make sure the current data reflects the current desired frequency is to process say N buffers aka wait. N would take into account the GNU Radio inter-block buffers and the buffers libiio uses to stream data from hardware. By default the number of libiio buffers is 4 (size of buffers is set by the block). Getting the number of inline buffers in GNU Radio is complex since its managed by a scheduler. The hacky way to do this is to just make N large. Like >10+libiio buffers.

    I would recommend verifying that your data reflects the desired frequency of interest. Say ping pong between 2 frequencies with known spectral content. Once that works you can scan the entire band of interest.

    -Travis