GNU Radio World

Variables and Messages

A flowgraph variable crossing into and out of the message domain. Message Pair to Var moves the frequency slider whenever a message pair (freq . value) arrives -- from the strobe every four seconds, or from the button -- and Variable to Message announces every change of that slider, by hand or by message, as a pair Message Debug prints.

Press Load to open this flowgraph in an editor embedded above, then ▶ to run it. Nothing is downloaded until you do.

Open in the full editor ▶ Download the .grc

Blocks used

BlockModuleUsed
GUI LayoutGNU Radio1
Message DebugGNU Radio1
Message Pair to VarGNU Radio1
Message StrobeGNU Radio1
QT GUI Msg Push ButtonGNU Radio1
QT GUI RangeGNU Radio1
QT GUI Time SinkGNU Radio1
Signal SourceGNU Radio1
ThrottleGNU Radio1
VariableGNU Radio1
Variable to MessageGNU Radio1

Flowgraph source

blocks/variables_and_messages.grc
options:
    parameters:
        author: Marc
        comment: ''
        copyright: ''
        description: A flowgraph variable crossing into and out of the message domain. Message Pair to Var moves the frequency slider whenever a message pair (freq . value) arrives -- from the strobe every four seconds, or from the button -- and Variable to Message announces every change of that slider, by hand or by message, as a pair Message Debug prints.
        generate_options: qt_gui
        id: Variables_and_Messages
        title: Variables and Messages
    states:
        coordinate: [10, 10]
        rotation: 0
        state: enabled
blocks:
-   name: freq
    id: variable_qtgui_range
    parameters:
        comment: ''
        label: Tone frequency (Hz)
        min_len: '240'
        orient: QtCore.Qt.Horizontal
        rangeType: float
        start: '100'
        step: '100'
        stop: '8000'
        value: '1000'
        widget: counter_slider
    states:
        coordinate: [600, 10]
        rotation: 0
        state: enabled
-   name: samp_rate
    id: variable
    parameters:
        comment: ''
        value: '32000'
    states:
        coordinate: [890, 10]
        rotation: 0
        state: enabled
-   name: set_500
    id: variable_qtgui_msg_push_button
    parameters:
        comment: ''
        gui_hint: ''
        label: Set to 500 Hz
        msgName: freq
        relBackgroundColor: default
        relFontColor: default
        type: real
        value: '500'
    states:
        coordinate: [90, 310]
        rotation: 0
        state: enabled
-   name: changes
    id: blocks_message_debug
    parameters:
        affinity: ''
        alias: ''
        comment: ''
        en_uvec: 'True'
        log_level: info
    states:
        coordinate: [470, 470]
        rotation: 0
        state: enabled
-   name: pair_to_var
    id: blocks_msgpair_to_var
    parameters:
        affinity: ''
        alias: ''
        comment: ''
        target: freq
    states:
        coordinate: [540, 210]
        rotation: 0
        state: enabled
-   name: scope
    id: qtgui_time_sink_x
    parameters:
        affinity: ''
        alias: ''
        alpha1: '1'
        alpha10: '1'
        alpha2: '1'
        alpha3: '1'
        alpha4: '1'
        alpha5: '1'
        alpha6: '1'
        alpha7: '1'
        alpha8: '1'
        alpha9: '1'
        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: 'True'
        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: Tone at the frequency the slider holds
        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'
        tr_mode: qtgui.TRIG_MODE_FREE
        tr_slope: qtgui.TRIG_SLOPE_POS
        tr_tag: ''
        type: float
        update_time: '0.1'
        width1: '1'
        width10: '1'
        width2: '1'
        width3: '1'
        width4: '1'
        width5: '1'
        width6: '1'
        width7: '1'
        width8: '1'
        width9: '1'
        ylabel: Amplitude
        ymax: '1.5'
        ymin: '-1.5'
        yunit: ''
    states:
        coordinate: [690, 690]
        rotation: 0
        state: enabled
-   name: strobe_2500
    id: blocks_message_strobe
    parameters:
        affinity: ''
        alias: ''
        comment: ''
        maxoutbuf: '0'
        minoutbuf: '0'
        msg: pmt.cons(pmt.intern("freq"), pmt.from_double(2500))
        period: '4000'
    states:
        coordinate: [90, 210]
        rotation: 0
        state: enabled
-   name: throttle
    id: blocks_throttle2
    parameters:
        affinity: ''
        alias: ''
        comment: ''
        ignoretag: 'True'
        limit: auto
        maximum: '0.1'
        maxoutbuf: '0'
        minoutbuf: '0'
        samples_per_second: samp_rate
        type: float
        vlen: '1'
    states:
        coordinate: [360, 690]
        rotation: 0
        state: enabled
-   name: tone
    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_SIN_WAVE
    states:
        coordinate: [10, 670]
        rotation: 0
        state: enabled
-   name: var_to_msg
    id: blocks_var_to_msg
    parameters:
        affinity: ''
        alias: ''
        comment: ''
        maxoutbuf: '0'
        minoutbuf: '0'
        msgname: freq
        target: freq
    states:
        coordinate: [10, 500]
        rotation: 0
        state: enabled
-   name: wasm_gui_layout_0
    id: wasm_gui_layout
    parameters:
        affinity: ''
        alias: ''
        columns: '12'
        comment: ''
        layout: '{}'
        row_height: '60'
    states:
        coordinate: [310, 10]
        rotation: 0
        state: enabled
connections:
-   src_blk_id: set_500
    src_port_id: pressed
    snk_blk_id: pair_to_var
    snk_port_id: inpair
-   src_blk_id: strobe_2500
    src_port_id: strobe
    snk_blk_id: pair_to_var
    snk_port_id: inpair
- [throttle, '0', scope, '0']
- [tone, '0', throttle, '0']
-   src_blk_id: var_to_msg
    src_port_id: msgout
    snk_blk_id: changes
    snk_port_id: print
metadata:
    file_format: 2
    grc_version: 3.11.0.0