Forum: GNU Radio uses gr.file_sink 32 bit or 64 bit

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-03-26 12:14
(Received via mailing list)
Hi All again, :-)

i want to save some output from the usrp and watch it with octave.
Therefor i know is something written at,
http://gnuradio.org/trac/wiki/Octave
quotation:
"Data captured directly from the USRP is stored as 32-bit complex,
rather than
64-bit complex (gr.sizeof_gr_complex)"
So i think,
gr.file_sink(gr.sizeof_gr_complex*1, "capture.dat")
is to save 64 bit data and,
gr.file_sink(gr.sizeof_short*1, "capture.dat")
is to save 32 bit data.
Is that correct ?
But therefor i have to set the output type of my USRP
to short(is not default) ?
If i set the output type to complex then i would get
64 bit ?
USRP source Ouput Type complex --> 64 bit
USRP source Ouput Type short --> 32 bit
Is this correct ?

Regards Markus
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-03-26 12:25
(Received via mailing list)
I also want to save only as much data as needed to
create ONE FFT-Plot in octave.
My FFT-sink has got a fft-size of 1024.

How to cut the stream for a fft-size of 1024 ?

Regards Markus
D0072e69d706bb3ca211d33a1b536e2c?d=identicon&s=25 Johnathan Corgan (Guest)
on 2009-03-26 15:32
(Received via mailing list)
On Thu, Mar 26, 2009 at 4:12 AM, feldmaus <feldmann_markus@gmx.de>
wrote:

> i want to save some output from the usrp and watch it with octave.

The usrp.source_c(...) block generates IQ data as pairs of 32-bit
floating point values.

Use gr.file_sink(gr.sizeof_gr_complex, "filename.dat") to write these
samples to disk.

Inside Octave, use read_complex_binary('filename.dat') to load the
saved samples into an array of complex numbers.

Johnathan
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-03-26 17:55
(Received via mailing list)
On Thu, Mar 26, 2009 at 07:32:09AM -0700, Johnathan Corgan wrote:
> On Thu, Mar 26, 2009 at 4:12 AM, feldmaus <feldmann_markus@gmx.de> wrote:
>
> > i want to save some output from the usrp and watch it with octave.
>
> The usrp.source_c(...) block generates IQ data as pairs of 32-bit
> floating point values.

Or to avoid any confustion about how many samples are getting
generated, I think it's easier to think that it generates samples that
are of type std::complex<float>.

Eric
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 Markus Feldmann (Guest)
on 2009-03-26 22:57
(Received via mailing list)
Eric Blossom schrieb:
>
> Eric
Thanks for your posts,

so if i really want to plot this data
in octave i have to collect every 32bit samples ?

If i only plot the vector containnig the float samples:
c=read_complex_binary('usrp_output_64bit_complex_only_sin_signal.dat');
t=1:1:100;
plot([real(c(t)), imag(c(t))])
i got for the beginning,
http://img90.imageshack.us/my.php?image=from1to100bits.jpg

And if i do,
t=100:1:164;
plot([real(c(t)), imag(c(t))])
http://img90.imageshack.us/my.php?image=from100to164bits.jpg

Regards Markus
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 Markus Feldmann (Guest)
on 2009-03-26 23:26
(Received via mailing list)
Eric Blossom schrieb:
>
> Eric
Yes its confusing me. :-(

Ok, here is a clipping from the data at the beginning:
        0 +     0i
        0 +     0i
       -1 +     0i
        0 -     1i
      -13 +     2i
       65 -    32i
     -183 +    98i
      412 -   233i
     -831 +   478i
     1572 -   918i
    -3050 +  1745i
     8314 -  4139i
   -12548 -  5491i
     3899 + 10329i
     3523 -  2748i
    -1791 +  1379i
      951 -   738i
     -484 +   378i
      219 -   176i
      -84 +    69i
       19 -    20i
        0 +     0i
        0 -     1i
        0 +     0i
        0 -     1i
        0 +     0i
        0 -     1i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 +     0i
        0 -     1i
        0 +     0i
       -1 -     1i
        0 +     0i
       -1 -     1i
        0 +     0i
       -1 -     1i
        0 +     0i
       -1 +     0i
        0 -     1i
        0 +     0i
       -1 -     1i
        0 +     0i
       -1 +     0i
        0 -     1i
       -1 +     0i

How can i collect bits from the I or Q Signal ?
So the first 16 bits from the left side are the I Signal ?
And the first 16 bits from the right side are the Q Signal ?
Where is the beginning of the samples ?
Maybe the curious values at the beginning is the
start point ?

Regards Markus
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-03-27 16:59
(Received via mailing list)
Eric Blossom <eb <at> comsec.com> writes:

> Or to avoid any confustion about how many samples are getting
> generated, I think it's easier to think that it generates samples that
> are of type std::complex<float>.
So you mean:

I(32 bit) --> real(16 bit) + imag(16 bit)
and
Q(32 bit) --> real(16 bit) + imag(16 bit)

So I+Q is 64 bit ???

Regards Markus
D0072e69d706bb3ca211d33a1b536e2c?d=identicon&s=25 Johnathan Corgan (Guest)
on 2009-03-27 17:17
(Received via mailing list)
Just to make this completely clear:

The complex baseband samples that come from the USRP1 source block
usrp.source_c(), and the from USRP2 source block usrp2.source_32fc(),
are complex numbers.  The real portion of the sample (the "in-phase",
or "I" portion), is a 32-bit floating point number.  The imaginary
portion of the sample ("quadrature", or "Q" portion) is also a 32-bit
floating point number.

The sample, then, is a vector quantity.  While there is a "total" of
64 bits between the two numbers, when one uses bit depth to describe
these, one still refers to the bit depth of the individual dimensions,
not the aggregate.  To describe the storage requirements of a sample,
in memory or on a block device, one typically uses bytes.  Thus, it is
correct to say, "a 32-bit complex floating point sample takes 8 bytes
of storage, 4 for the I portion and 4 for the Q portion."

Your earlier post showing the captured samples from the USRP as an
array in Octave was correct.  (The magnitude spike in the first 20 or
so samples is an artifact of the the USRP when it is first enabled,
and can be ignored.)

Hope this helps.

Johnathan
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-03-27 20:54
(Received via mailing list)
Johnathan Corgan <jcorgan <at> corganenterprises.com> writes:

>
> Just to make this completely clear:
Very very thank you Johnathan.

Ok, so i think the gnuradio docu should be updated, because there is
written:
"Data captured directly from the USRP is stored as 32-bit complex,
rather than
64-bit complex (gr.sizeof_gr_complex)."

But I+Q is 64 bit complex as you said.

So i have to use the read_complex_binary() function which has
gr.sizeof_gr_complex(64 bit) . So the docu should write:
"Data captured directly from the USRP is stored as 64-bit complex,
rather than
32-bit complex."

Further on my graphic does not look like my spectrum in the
FFT-sink.
Therfore should something added, like
how to show this correctly:
c=read_complex_binary('data')
t=100:1:length(c)
f=20*log10(fft(t,c(t)))
plot([real(f), imag(f)])

But this sentences doesn't work correcctly.
I am working on this.

How ever the above has another error???
The <plot> command mixes the real part from I and Q together as
the imag part from I and Q too.
Is this correct ???
Further on the data should go through a fft() and a 20*log()
function ???
My FFT has a size of 1024 is this relevant for the fft() function ?

Regards Markus
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-03-28 01:37
(Received via mailing list)
Markus Feldmann <feldmann_markus <at> gmx.de> writes:

>
> Ok, here is a clipping from the data at the beginning:
>         0 -     1i
>        -1 +     0i

As you said the Output is stored as 64 bit value, 32bit I and 32 bit Q,
but I and Q do have bot real and complex values ?!
As you can see, every line consists only one real and one complex value.

Wherefor is the first line ?
For the I part or the Q part ?
Does the lines of the I and Q part change from line to line ?
  0 - 1i --> real(I) - imag(I)
 -1 + 0i --> real(Q) + imag(Q)

Is this mapping correct ?

Regards Markus
79723aa1b24981dcec2dbf7fd59403c1?d=identicon&s=25 Brian Padalino (Guest)
on 2009-03-28 01:59
(Received via mailing list)
On Fri, Mar 27, 2009 at 8:36 PM, feldmaus <feldmann_markus@gmx.de>
wrote:
>
> Wherefor is the first line ?
> For the I part or the Q part ?
> Does the lines of the I and Q part change from line to line ?
>  0 - 1i --> real(I) - imag(I)
>  -1 + 0i --> real(Q) + imag(Q)

You may want to refresh your knowledge of complex numbers:

    http://en.wikipedia.org/wiki/Complex_number
    http://www.dspguru.com/info/tutor/QuadSignals.pdf

Brian
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-03-28 15:11
(Received via mailing list)
Brian Padalino <bpadalino <at> gmail.com> writes:

>
Thanks Brian for your nice link,

but if you only post a link and do not wrote a simple
answer like yes or no to my question, then i will be
confused.
Or is there something totally wrong i wrote ?
Then please also wrote my mistake !

How ever do you have also a good link or answer, why this
http://img90.imageshack.us/my.php?image=from100to164bits.jpg

doesn't looks like the FFT-Spectrum we get in gnuradio in
the FFT-sink.
The Howto <http://gnuradio.org/trac/wiki/Octave>is incomplete !?

Thanks and Regards Markus
79723aa1b24981dcec2dbf7fd59403c1?d=identicon&s=25 Brian Padalino (Guest)
on 2009-03-28 15:45
(Received via mailing list)
On Sat, Mar 28, 2009 at 10:09 AM, feldmaus <feldmann_markus@gmx.de>
wrote:
> Thanks Brian for your nice link,
>
> but if you only post a link and do not wrote a simple
> answer like yes or no to my question, then i will be
> confused.
> Or is there something totally wrong i wrote ?
> Then please also wrote my mistake !

As the old proverb goes:

    "Give a man a fish and you feed him for a day. Teach a man to fish
and you feed him for a lifetime."

You seem to have a grave misunderstanding of what complex numbers are
and how they are represented.  I highly recommend you brush up on your
knowledge.  Said links should be sufficient for you to correct your
own mistakes.

> How ever do you have also a good link or answer, why this
> http://img90.imageshack.us/my.php?image=from100to164bits.jpg
>
> doesn't looks like the FFT-Spectrum we get in gnuradio in
> the FFT-sink.

Unfortunately, this plot does not indicate how to interpret the data I
am reading.  Moreover, you did not supply the means of how you created
the graph with both the script or the source data.  On top of that, I
have no idea how the data was captured or what the expected result
should be.  There are a lot of holes here when it comes to the simple
question: "why this?"

Please take the time to read:

    http://astro.uchicago.edu/cara/outreach/resources/...

Please, don't forget to perform "Step 6" before mailing the list for
help.

> The Howto <http://gnuradio.org/trac/wiki/Octave>is incomplete !?

Think of this as a learning opportunity as to both learn and teach
others.  Feel free to complete the howto on the wiki once you have
gained adequate knowledge and if you still feel the wiki is still
incomplete.

There has been plenty of information given in this thread to
understand how numbers are represented using the file_sink.  It's now
up to you to learn from the posts and gain that knowledge for
yourself.

Good luck!

Brian
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-03-28 16:55
(Received via mailing list)
I also stored another files with data captured from my signal generator.
To store the data i used the Gnuradio companion with a USRP source
(complex output) and a file_sink(complex input). The usrp source gets
the data from my external signal-generator.
But this time i increased the amplitude of my sinus signal periodically.
So i can easily verify that i stored data from my signal generator and
nothing else.

I executed the following octave commands:
c=read_complex_binary('usrp_output_64bit_complex_only_sin_signal.dat');
plot(real(c(1:600)))
<http://img17.imageshack.us/my.php?image=realfrom1t...
plot(real(c(601:length(c)))
<http://img12.imageshack.us/my.php?image=realfrom60...
plot(imag(c(1:600)))
<http://img217.imageshack.us/my.php?image=imagfrom1...
plot(imag(c(601:length(c)))
<http://img21.imageshack.us/my.php?image=imagfrom60...

As you can see the amplitude will be increased over time.

However this doesn't looks like as in my FFT-Plot Software !
http://img135.imageshack.us/my.php?image=originalg...

Therfor i sink each wave is one sample and each sample has all the
information to build one displayed spectrum in my FFT-Plot ???

But how can i do this with octave ?
I doesn't understand FFT completely. But i think i need the FFT function
to display the data as shown in my FFT-Plot ???

Now i post the Real+Imag Values from (600:700):
   24 +  5i
    1 + 24i
  -23 + 10i
  -19 - 18i
    9 - 24i
   24 +  1i
    5 + 23i
  -21 + 13i
  -21 - 15i
    6 - 25i
   24 -  2i
    8 + 23i
  -19 + 16i
  -23 - 13i
    2 - 26i
   24 -  5i
   12 + 21i
  -16 + 19i
  -25 -  9i
    0 - 26i
   23 -  9i
   16 + 18i
  -13 + 21i
  -25 -  5i
   -4 - 25i
   22 - 13i
   18 + 15i
  -10 + 23i
  -26 -  2i
   -8 - 25i
   19 - 17i
   20 + 12i
   -6 + 24i
  -26 +  1i
  -12 - 23i
   17 - 18i
   22 +  9i
   -2 + 24i
  -25 +  5i
  -15 - 21i
   13 - 21i
   23 +  6i
    1 + 24i
  -24 +  8i
  -18 - 19i
   11 - 23i
   24 +  2i
    3 + 24i
  -23 + 12i
  -20 - 16i
    7 - 25i
   24 -  1i
    7 + 23i
  -20 + 15i
  -23 - 13i
    3 - 25i
   24 -  4i
   11 + 22i
  -18 + 18i
  -24 - 10i
    0 - 26i
   23 -  8i
   14 + 19i
  -14 + 20i
  -25 -  6i
   -3 - 26i
   22 - 11i
   17 + 17i
  -10 + 23i
  -26 -  2i
   -7 - 25i
   20 - 14i
   20 + 15i
   -7 + 23i
  -26 +  0i
  -10 - 24i
   18 - 18i
   21 + 11i
   -3 + 24i
  -25 +  3i
  -14 - 22i
   15 - 20i
   23 +  7i
    0 + 24i
  -24 +  8i
  -17 - 20i
   12 - 22i
   24 +  3i
    2 + 24i
  -23 + 12i
  -20 - 17i
    8 - 24i
   24 +  0i
    6 + 23i
  -21 + 14i
  -21 - 14i
    4 - 25i
   24 -  2i
   10 + 21i
  -18 + 17i
  -24 - 11i

Regards Markus
3e5d1707dd5f4807ed9938d5c37b2649?d=identicon&s=25 Patrick Strasser (Guest)
on 2009-03-30 12:45
(Received via mailing list)
feldmaus wrote am 2009-03-27 20:52:

> Further on my graphic does not look like my spectrum in the
> FFT-sink.

A FFT sink displays the frequency domain, it's amplitude versus
frequency.
Printing the samples shows the time domain, amplitude versus time.

The FFT sink feeds the samples through a FFT-block, resulting in its
name.
A scope sink just plots the samples, as you try with Matlab/Octave.

Patrick
--
Engineers motto: cheap, good, fast: choose any two
Patrick Strasser <patrick dot strasser at student dot tugraz dot at>
Student of Telematik, Techn. University Graz, Austria
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 Markus Feldmann (Guest)
on 2009-03-30 17:58
(Received via mailing list)
Patrick Strasser schrieb:
> feldmaus wrote am 2009-03-27 20:52:
>
>> Further on my graphic does not look like my spectrum in the
>> FFT-sink.
>
> A FFT sink displays the frequency domain, it's amplitude versus frequency.
> Printing the samples shows the time domain, amplitude versus time.
>
> The FFT sink feeds the samples through a FFT-block, resulting in its name.
> A scope sink just plots the samples, as you try with Matlab/Octave.
You are right, thats also what i am thinking, but to these
samples through a fft, i have to know what is a sample !

Thats the topic of this post.
Thats what i not understand.

What is a sample ?
For example, is this ONE sample ?
    24 +  5i

The left is a 32bit I part and the right is the Q part ?
But as i read I and Q are complex, so i sink I and Q will
be changed from line to line ?
If i need more than one line for one sample, how many lines
do i need for the fft ?

Regards Markus
3e5d1707dd5f4807ed9938d5c37b2649?d=identicon&s=25 Patrick Strasser (Guest)
on 2009-03-31 11:37
(Received via mailing list)
Markus Feldmann wrote am 2009-03-30 17:54:
 >
> You are right, thats also what i am thinking, but to these
> samples through a fft, i have to know what is a sample !
>
> Thats the topic of this post.
> Thats what i not understand.
>
> What is a sample ?
> For example, is this ONE sample ?
>    24 +  5i

Yes.

> The left is a 32bit I part and the right is the Q part ?

Yes! The I(nphase)-part is the real component of the complex number, the
Q(uadrature)-part is the imaginary component of the complex number

> If i need more than one line for one sample, how many lines
> do i need for the fft ?

One "line" in your output is one complex sample.

You really should read up about complex numbers and FFT, as Brian
mentioned. Please do your homework before asking questions. If you do
not understand how complex numbers work, you will not find too much
people here teaching you such things.

Patrick
--
Engineers motto: cheap, good, fast: choose any two
Patrick Strasser <patrick dot strasser at student dot tugraz dot at>
Student of Telematik, Techn. University Graz, Austria
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-04-03 14:26
(Received via mailing list)
Patrick Strasser <patrick.strasser <at> tugraz.at> writes:

> Q(uadrature)-part is the imaginary component of the complex number
>
> > If i need more than one line for one sample, how many lines
> > do i need for the fft ?
>
> One "line" in your output is one complex sample.
Yes but one line doesn't suffices for one FFT-Plot !
Or do you want to say that one line as for example,
0+1i
should result in one of my complete spectrum ???
I doesn't think so. Ok the FFT-Plot uses a average algorithm so
it is not very fatal if there are some zero lines, because they
are not weighted because of the average algorithm, but i doens't
believe this.

However i found a link where is more information.
The subject is <data types and other questions>.
The data Type changes. From Usrp to Host it is 8bit or 16bit short
and will be converted at the Host to 32bit float, so that or apllication
only compute with 32bit float values.

Regards Markus
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-04-03 18:13
(Received via mailing list)
On Fri, Apr 03, 2009 at 12:25:41PM +0000, feldmaus wrote:
> >
> should result in one of my complete spectrum ???
>
> Regards Markus

Marcus,

I know that some of us are starting to sound like broken records, but
you seem to be missing some of the basics.  This is OK, we all started
out knowing nothing.

We've got many books and papers on the
http://gnuradio.org/trac/wiki/SuggestedReading page.  I particularly
recommend "Understanding Digital Signal Processing" by Richard Lyons.
He works through the basics of DSP with complete examples, including
sampling, aliasing, DFT / FFT, filtering, digital data formats, complex
numbers, etc.  It's a great introductory book for autodidacts.

http://www.amazon.com/Understanding-Digital-Signal...

Eric
85ffd97bae0e78056e1d06312744d7d1?d=identicon&s=25 feldmaus (Guest)
on 2009-04-06 13:10
(Received via mailing list)
Eric Blossom <eb <at> comsec.com> writes:

>
>
http://www.amazon.com/Understanding-Digital-Signal...

At this time i am doing my diploma and have not much money, so
i have to thing about where my money goes. But i will still buy
some nice books after this. :-)

I which "*.cc" file is the algorithm written for applying the fft ?

Regards Markus
This topic is locked and can not be replied to.