Python Block Tags
TODO:
- use a threshold
- set a tag when threshold exceeded
- feed in a noise source (average it?)
- tag blocker
- block to read tag, then change the output
- make a picture associating tags with samples
The flowgraph will use two Embedded Python Blocks for detecting when the input signal crosses the threshold and setting a tag for it and then reading the tag and updating an output counter with the time since the last detection.
The previous tutorial, Python Block Message Passing demonstrates how to send and receive messages using the Embedded Python Block. The next tutorial, Low Pass Filter Example, demonstrates how to use filtering blocks in GNU Radio.
Tags Overview
Tags are a way to convey information alongside digitized RF samples in a time-synchronous fashion. Tags are particularly useful when downstream blocks need to know upon which sample the receiver was tuned to a new frequency, or for including timestamps with specific samples.
Where messages convey information in an asynchronous fashion with no clock-based time guarantee, tags are information which are associated with specific RF samples. Tags ride alongside digitized RF samples in data streams and vectors, including Complex Float 32, Float 32, Byte and all of the other formats.
More information about tags can be found here: Stream Tags
Creating Test Signal
A test signal is needed. Begin by dragging in the blocks for the input signal:
- GLFSR Source
- Repeat
- Multiply Const
- Add Const
- Single Pole IIR Filter
- Throttle
- QT GUI Time Sink
Change the following parameters:
- GLFSR Source, Degree: 32
- Repeat, Interpolation: 128
- Multiply Const, Constant: 0.5
- Add Const, Constant: 0.5
- Single Pole IIR Filter, Alpha: 0.05
- QT GUI Time Sink
- Number of Points: 2048
- Y min: 0
- samp_rate Variable, Value: 3200
Change all of the blocks to be Float input and output. Connect them all according to the following flowgraph:
Run the flowgraph. A randomized sequence of filtered 0s and 1s is generated:
Threshold Detector: Defining the Block
Drag in a Python Block and double-click it to edit the source code.
Threshold: Writing the Tags
The next tutorial, Low Pass Filter Example, demonstrates how to use filtering blocks in GNU Radio.