diff options
Diffstat (limited to 'gr-blocks/grc')
4 files changed, 71 insertions, 4 deletions
diff --git a/gr-blocks/grc/blocks_complex_to_interleaved_char.block.yml b/gr-blocks/grc/blocks_complex_to_interleaved_char.block.yml index 78a1da6e8b..84b85579a2 100644 --- a/gr-blocks/grc/blocks_complex_to_interleaved_char.block.yml +++ b/gr-blocks/grc/blocks_complex_to_interleaved_char.block.yml @@ -3,6 +3,10 @@ label: Complex To IChar flags: [ python, cpp ] parameters: +- id: scale_factor + label: Scale Factor + dtype: float + default: '1.0' - id: vector_output label: Vector Output dtype: enum @@ -23,7 +27,7 @@ outputs: templates: imports: from gnuradio import blocks - make: blocks.complex_to_interleaved_char(${vector_output}) + make: blocks.complex_to_interleaved_char(${vector_output}, ${scale_factor}) cpp_templates: includes: ['#include <gnuradio/blocks/complex_to_interleaved_char.h>'] @@ -33,4 +37,16 @@ cpp_templates: 'True': 'true' 'False': 'false' +documentation: |- + This block converts a complex sample to interleaved IQ bytes. + The default scale factor is 1.0 for backward compatibility, however if + the outputs should be signed voltage style bytes (-127 to 127) the scale factor + should be set to 127.0 (SCHAR_MAX). + + Also note that this block can inherently cause a loss of precision as it + maps the scaled inputs to integer outputs using an lrintf function. So + if you overlay a complex-to-ichar into a ichar-to-complex and overlay it + on the original signal, you can notice variation due to the integer + rounding. + file_format: 1 diff --git a/gr-blocks/grc/blocks_complex_to_interleaved_short.block.yml b/gr-blocks/grc/blocks_complex_to_interleaved_short.block.yml index bd4a588aca..89739e8245 100644 --- a/gr-blocks/grc/blocks_complex_to_interleaved_short.block.yml +++ b/gr-blocks/grc/blocks_complex_to_interleaved_short.block.yml @@ -3,6 +3,10 @@ label: Complex To IShort flags: [ python, cpp ] parameters: +- id: scale_factor + label: Scale Factor + dtype: float + default: '1.0' - id: vector_output label: Vector Output dtype: enum @@ -23,14 +27,32 @@ outputs: templates: imports: from gnuradio import blocks - make: blocks.complex_to_interleaved_short(${vector_output}) + make: blocks.complex_to_interleaved_short(${vector_output},${scale_factor}) + callbacks: + - set_scale_factor(${scale_factor}) cpp_templates: includes: ['#include <gnuradio/blocks/complex_to_interleaved_short.h>'] declarations: 'blocks::complex_to_interleaved_short::sptr ${id};' make: 'this->${id} = blocks::complex_to_interleaved_short::make(${vector_output});' + callbacks: + - set_scale_factor(${scale_factor}) translations: 'True': 'true' 'False': 'false' +documentation: |- + This block converts a complex sample to interleaved IQ 16-bit values. + The default scale factor is 1.0 for backward compatibility, however if + the outputs should be signed voltage style, some care needs to be taken + with the scale factor. For a 12-bit output (-2047 to 2047), the + scale factor should be 2047.0. For a full 16-bit output, the + scale factor should be 32767.0. + + Also note that this block can inherently cause a loss of precision as it + maps the scaled inputs to integer outputs using an lrintf function. So + if you overlay a complex-to-ishort into a ishort-to-complex and overlay it + on the original signal, you can notice variation due to the integer + rounding. + file_format: 1 diff --git a/gr-blocks/grc/blocks_interleaved_char_to_complex.block.yml b/gr-blocks/grc/blocks_interleaved_char_to_complex.block.yml index 39f747a981..46d01b79c3 100644 --- a/gr-blocks/grc/blocks_interleaved_char_to_complex.block.yml +++ b/gr-blocks/grc/blocks_interleaved_char_to_complex.block.yml @@ -3,6 +3,10 @@ label: IChar To Complex flags: [ python, cpp ] parameters: +- id: scale_factor + label: Scale Factor + dtype: float + default: '1.0' - id: vector_input label: Vector Input dtype: enum @@ -23,14 +27,24 @@ outputs: templates: imports: from gnuradio import blocks - make: blocks.interleaved_char_to_complex(${vector_input}) + make: blocks.interleaved_char_to_complex(${vector_input},${scale_factor}) + callbacks: + - set_scale_factor(${scale_factor}) cpp_templates: includes: ['#include <gnuradio/blocks/interleaved_char_to_complex.h>'] declarations: 'blocks::interleaved_char_to_complex::sptr ${id};' make: 'this->${id} = blocks::interleaved_char_to_complex::make(${vector_input});' + callbacks: + - set_scale_factor(${scale_factor}) translations: 'True': 'true' 'False': 'false' +documentation: |- + This block converts interleaved IQ bytes to a float complex data type. + The default scale factor is 1.0 for backward compatibility, however if + the inputs are signed voltage style bytes (-127 to 127) the scale factor + should be set to 127.0 (SCHAR_MAX). + file_format: 1 diff --git a/gr-blocks/grc/blocks_interleaved_short_to_complex.block.yml b/gr-blocks/grc/blocks_interleaved_short_to_complex.block.yml index f96960ad56..5904ed76b1 100644 --- a/gr-blocks/grc/blocks_interleaved_short_to_complex.block.yml +++ b/gr-blocks/grc/blocks_interleaved_short_to_complex.block.yml @@ -3,6 +3,10 @@ label: IShort To Complex flags: [ python, cpp ] parameters: +- id: scale_factor + label: Scale Factor + dtype: float + default: '1.0' - id: vector_input label: Vector Input dtype: enum @@ -30,9 +34,10 @@ outputs: templates: imports: from gnuradio import blocks - make: blocks.interleaved_short_to_complex(${vector_input}, ${swap}) + make: blocks.interleaved_short_to_complex(${vector_input}, ${swap},${scale_factor}) callbacks: - set_swap(${swap}) + - set_scale_factor(${scale_factor}) cpp_templates: includes: ['#include <gnuradio/blocks/interleaved_short_to_complex.h>'] @@ -40,8 +45,18 @@ cpp_templates: make: 'this->${id} = blocks::interleaved_short_to_complex::make(${vector_input}, ${swap});' callbacks: - set_swap(${swap}) + - set_scale_factor(${scale_factor}) translations: 'True': 'true' 'False': 'false' +documentation: |- + This block converts interleaved 12/16-bit IQ samples to a float complex data + type. The default scale factor is 1.0 for backward compatibility, however if + the inputs are signed voltage style, some attention needs to be + paid to the scale factor to get the correct scaling. If the input is + 12-bit represented in a 16-bit number (-2047 to 2047), the scale factor + should be 2047.0. If the input is a full 16-bit sample (-32767 to 32767) + the scale factor should be set to 32767.0 (SHRT_MAX). + file_format: 1 |