Converting Data Types: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:


==Char/Byte Data Type ==
==Char/Byte Data Type ==
The ''Char'' or ''Byte'' data type is another useful data type for representing binary data. The ''Byte'' data type is represented by a ''char'' in c++ which is 8 bits. The ''byte'' type can represent numbers from 0 to (2^8)-1=255. Where ''Complex Float 32'' is used to represent digitized complex samples and ''Float 32'' represents real digitized samples, the ''Byte'' data type is used to represent binary numbers.
The ''Char'' or ''Byte'' data type is another useful data type for representing binary data. The ''Byte'' data type is represented by the magenta color in GRC:
 
The ''Byte'' data type is represented by the magenta color in GRC:


[[File:Types.png|500px]]
[[File:Types.png|500px]]
Line 23: Line 21:
[[File:RandomSourceByteOutput.png|500px]]
[[File:RandomSourceByteOutput.png|500px]]


== Converting ''Byte'' to ''Float 32'' ==
== Converting ''Byte'' to ''Float 32''==
 
The default parameters of the ''Random Source'' will randomly generate values of 0 and 1. We will want to view them using the ''QT GUI Time Sink'', add it and the ''Throttle'' block into the workspace and connect the blocks:
 
[[File:ConnectionErrorCharToComplex.png|700px]]





Revision as of 16:12, 6 January 2022

This tutorial will describe how to convert between data types. The previous tutorial, Signal Data Types, presents an introduction to the Complex Float 32 and Float 32 data types for representing digitized signals.

Char/Byte Data Type

The Char or Byte data type is another useful data type for representing binary data. The Byte data type is represented by the magenta color in GRC:

Types.png

Search for the Random Source block and drag it into the workspace:

SearchRandomSourceBlock.png


The block defaults to the green Integer 32 data type. Double-click the block to open the properties and modify the data type to byte:

SelectByteDataTye.png


The Random Source is now converted to the magenta Char or Byte data type.

RandomSourceByteOutput.png

Converting Byte to Float 32

The default parameters of the Random Source will randomly generate values of 0 and 1. We will want to view them using the QT GUI Time Sink, add it and the Throttle block into the workspace and connect the blocks:

ConnectionErrorCharToComplex.png





  • random source
  • use in modulator

char/byte data type convert to float display