Streams and Vectors: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 38: Line 38:
[[File:ConnectStreamsToVector.png|700px]]
[[File:ConnectStreamsToVector.png|700px]]


The ''Streams to Vector'' block takes the two serial ''streams'' inputs and then converts them to an two-dimensional ''vector'' output. The block takes the sample from the ''in0'' port and places it into the first element in the ''vector''. The sample from the ''in1'' port is then placed into the second element in the ''vector''. The output is therefore the two-dimensional vector from one sample from ''in0'' and one sample from ''in1''.
The ''Streams to Vector'' block acts as an interleaver, taking the two serial ''stream'' inputs and converting them to a two-dimensional ''vector'' output. The block takes the sample from the ''in0'' port and places it into the first element in the output ''vector'', and then takes the a from the ''in1'' port and places into the second element in the ''vector''.

Revision as of 20:48, 6 January 2022

This tutorial will describe the difference between a Stream and a Vector. You can find the previous tutorial here: Converting Data Types

Streams

Streams in GNU Radio are what convey the information between blocks and are represented by the arrows connecting blocks in a flowgraph. A stream must have a data type, such as Float 32 or Byte. A stream carries 1 sample for each time instance and are used to represent and process serial data.

The Signal Source block produces a Complex Float 32 stream. The output of the block at each time instance contains 1 complex sample:

SignalSourceStreamExample.png


Vectors

Vectors carry multiple samples per time instance, representing data in parallel. By analogy, a stream represents a scalar at each time instance whereas a vector represents an array at each time instance.

GRC uses lighter colors to represent streams and darker colors to represent vector outputs:

StreamVectorDarkerColors.png


Streams and Vectors Flowgraph Example

The following example will describe how to convert a stream to a vector and back to a stream. Two complex sinusoid streams will be converted to a 2-element vector, displayed, and then converted back to their independent streams.

Add two Signal Source blocks to the workspace:

TwoSignalSourceBlocks.png


Edit the parameters of the second Signal Source to have a frequency of 100 and amplitude of 0.1 to distinguish it visually from the first Signal Source:

ChangeFrequencyAmplitudeSignalSource.png

Click OK to accept the parameters.

Search for the Streams to Vector block, drag it into the workspace and connect it to the Signal Source blocks:

ConnectStreamsToVector.png

The Streams to Vector block acts as an interleaver, taking the two serial stream inputs and converting them to a two-dimensional vector output. The block takes the sample from the in0 port and places it into the first element in the output vector, and then takes the a from the in1 port and places into the second element in the vector.