[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Discuss-gnuradio] Recovering x(t) from IQ samples
From: |
Bahn William L Civ USAFA/DFCS |
Subject: |
RE: [Discuss-gnuradio] Recovering x(t) from IQ samples |
Date: |
Fri, 17 Aug 2007 17:23:06 -0600 |
> From: Johnathan Corgan [mailto:address@hidden
>
> Bahn William L Civ USAFA/DFCS wrote:
>
> > Please tell me there is a better way.
>
> I didn't follow the start of this thread, but can you reiterate what
> you're trying to accomplish, vs. alternative ways of getting there? It
> does seem like things are getting overcomplicated, and some times it's
> useful to go back to a high-level description of the problem.
Sure - that sounds like a good idea.
I'm asking the question for several reasons - some theoretical and others
practical. The basic driving force is as follows:
I have the following processing chain:
BBC -> FILE -> GR -> USRP -> RF -> USRP -> GR -> FILE -> BBC
SENDER:
1) An external program (called BBC) takes messages from the user and produces
the waveform data that we want to transmit from the sender to the receiver.
2) The data is written to a file in a format that GNU Radio can read.
3) GNU Radio reads the data from the file and sends it to the USRP.
4) The USRP upconverts it and transmits it via RF.
5) The (other) USRP receives the RF signal, downconverts it, and sends the data
to GNU Radio.
6) GNU Radio receives the data from the USRP and writes it to a file.
7) The BBC program reads the data file and extracts the messages.
It would be very nice if the two files, the one being read by GNU Radio and the
one being written by GNU Radio, used the same format. If I leverage the
existing usrp_rx_cfile.py program, then the data written by GR is in IQ data
pairs and BBC will need to convert this to a stream of real-valued data
samples. Conversely, BBC will need to convert the real-valued data stream that
it generates into IQ data before writing it to the file that GR will later read
and transmit via the USRP.
This raises the following questions:
Q1) One of the formats in which I can send data to the USRP is as IQ data. What
does the USRP do with IQ data pairs? In the USRP documentation there is a block
diagram of the Digital Down Converter, but there is no diagram of the Digital
Up Converter.
Q2) If I have x(t) data (just time-domain data samples that have been generated
by an external program that is completely unrelated to GNU Radio) that I want
to transmit, how do I convert it to the necessary IQ data? What frequency do I
use in the calculations?
Q3) Given a stream of IQ data pairs, how do I convert them to plain-ole vanilla
x(t) time-domain samples?
Supposedly, as near as I can tell, there is a direct equivalency between data
represented as time-domain samples and the same data represented as IQ data
pairs. Is this true? If so, then it should be possible to convert back and
forth between the two representations? Is this the case?
Here is what I see from where I am sitting:
There is a time domain signal at the front of the Digital Down Converter (DDC)
in the USRP that I will call x(t). This signal (assuming the same signal is
applied to both DDC inputs) follows two paths to produce the i(t) and q(t)
samples that are delivered to the user over the USB interface.
Therefore the relationship between x(t), the signal that I am interested in,
and the i(t) and q(t) samples that I actually get to see are:
i(t) = x(t) * sin(wt)
q(t) = x(t) * cos(wt)
Now, I know that there is also the decimation low pass filter which, up to this
point, I have been ignoring but may actually hold the key. I don't know.
Assuming that x(t) has no frequency components that are going to get aliased,
how do I recover x(t) from the i(t) and q(t) samples?
Several people have responded, some to the list and some to me privately, that
you just treat i(t) and q(t) and the components of a complex number and use the
four-quadrant arctangent function. Typical of these responses has been:
=====================================================
Interpret I and Q as real and imaginary part of a complex number:
R = I + jQ.
Then |R| = sqrt(I^2 + Q^2) and ang(R) = atan2(imag(z),real(z)), where "atan2"
(four-quadrant inverse tangent, a Matlab function, to get the signs right).
You're simply looking for magnitude and phase (angle) of a complex number.
======================================================
But that doesn't work because there is, as I am looking at things, a
fundamental sign ambiguity involved. I tried to make that clear in my original
post and obviously failed to do so, hence I will be explicit in my reasoning
here. If I am wrong at some step, perhaps someone can spot it and point it out.
First off, R is not the x(t) I am looking for. R is a complex sequence. So
unless there is an unambiguous mapping between R and x(t), then it doesn't help.
Second, the closest mapping is not R = I + jQ, but rather R = Q + jI. To see
this, consider:
Z(t) = x(t) * e^(jwt)
Z(t) = x(t) * (cos(wt) + j*sin(wt))
Z(t) = x(t)*cos(wt) + j*x(t)*sin(wt)
Z(t) = q(t) + j*i(t)
Now, finding the magnitude of x(t) is very straightforward since:
|Z(t)| = sqrt(q^2(t)+i^2(t))
|Z(t)| = sqrt(x^2(t)*cos^2(wt) + x^2(t)*sin^2(t))
|Z(t)| = sqrt(x^2(t)*[cos^2(wt) + sin^2(t)])
|Z(t)| = sqrt(x^2(t)*[cos^2(wt) + sin^2(t)])
|Z(t)| = sqrt(x^2(t))
|Z(t)| = |x(t)|
Fine so far, but now I need to determine if x(t) is positive or negative.
IF I know what the phase of (wt) is, then I can trivially determine the sign of
x(t). A couple of responses I have gotten basically tell me to use this
information even though the original post specifically stated that all I have
are the i(t) and q(t) data.
What people keep suggesting is to use the four-quadrant arctangent, but the
problem is that knowing which quadrant an i(t),q(t) data pair is in does not
tell me which quadrant (wt) is in. It only allows me to determine which of two
possible quadrants (wt) is in and I need to know the sign of x(t) in order to
distinguish between them.
phi(Z(t)) = atan2(q(t), i(t))
phi(Z(t)) = atan2(x(t)*cos(wt), x(t)*sin(wt))
As a specific example of this ambiguity, let's say that sample number 34765
yields the following for i(t) and q(t) at that point:
i(34765) = 0.500
q(34765) = 0.866
What is x(34765)?
Well, if (w*34765) = 30 deg, then we have the following:
x(t) = 1.0
wt = 30 degrees
sin(wt) = 0.500
cos(wt) = 0.866
i(t) = 0.500
q(t) = 0.866
But if (w*34765) = 210 deg, then we have:
x(t) = -1.0
wt = 210 degrees
sin(wt) = -0.500
cos(wt) = -0.866
i(t) = 0.500
q(t) = 0.866
So the problem remains: Given only the i(t) and q(t) samples, which is all the
USRP gives back, how do I reconstruct x(t)?
- [Discuss-gnuradio] Recovering x(t) from IQ samples, Bahn William L Civ USAFA/DFCS, 2007/08/16
- RE: [Discuss-gnuradio] Recovering x(t) from IQ samples, Bahn William L Civ USAFA/DFCS, 2007/08/16
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Johnathan Corgan, 2007/08/17
- RE: [Discuss-gnuradio] Recovering x(t) from IQ samples,
Bahn William L Civ USAFA/DFCS <=
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Jens Elsner, 2007/08/18
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Jonathan P Jacky, 2007/08/18
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Jeff Brower, 2007/08/18
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Jonathan Jacky, 2007/08/20
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Chris Stankevitz, 2007/08/20
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Brian Padalino, 2007/08/20
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Jens Elsner, 2007/08/18
- [Discuss-gnuradio] Problem with the FPGA firmware (getting clock like output only), eenrti, 2007/08/19
- Re: [Discuss-gnuradio] Recovering x(t) from IQ samples, Jeff Brower, 2007/08/17