Question Concerning Custom Modulator Block

Dear List,

I am writing a custom QPSK modulator block (demod is next) and I am
caught
up on figuring out the output.

I am taking the byte data type (which I am using C++ char) and for each
bit
of the byte I would have a custom symbol per bit rate. For an absolute
minimum in a successful PSK system, I would need about two symbols per
bit.
So the sequence of data to be passed through is growing.

Now for where I am getting confused, when I come up with the I and Q
data
as a complex number I can only send out one sample at a time, right? So
for
each time my general_work executes it can send out only one sample at a
time while having even more samples calculated representing just one
value
of input_items which upon modulation would have quite a bit output
samples.
At least that is how I am interpreting the process.

How do I get out all these samples before I get the next value of the
input? Should I write the sample values to a buffer that the block
should
check whether it is full before processing the next char sample? Anyone
with experience writing modulator code have any tips? Can I keep
updating
the value of out in the general_work and it will pass on to the
flowgraph?

I have tried looking at what I believe is the PSK modulator source code,
gr_constellation.cc but it is a pretty hard piece of code to follow.

I appreciate any help and feedback.

Jon

On 02/18/2014 12:28 AM, Jonathan F. wrote:

Dear List,

I am writing a custom QPSK modulator block (demod is next) and I am
caught up on figuring out the output.

I am taking the byte data type (which I am using C++ char) and for each
bit of the byte I would have a custom symbol per bit rate. For an
absolute minimum in a successful PSK system, I would need about two
symbols per bit. So the sequence of data to be passed through is growing.

Always use uint8_t or unsigned char when handling bytes. I don’t
understand the rest–minimum for PSK would be 1 bit/byte (BPSK). Are you
adaptively changing the modulation?

Now for where I am getting confused, when I come up with the I and Q
data as a complex number I can only send out one sample at a time,
right? So for each time my general_work executes it can send out only
one sample at a time while having even more samples calculated
representing just one value of input_items which upon modulation would
have quite a bit output samples. At least that is how I am interpreting
the process.

Have you read the tutorial on how to write a block?
I don’t understand what you’re writing. In any block, you can output as
much items as is space in the output buffer (and should).

How do I get out all these samples before I get the next value of the
input? Should I write the sample values to a buffer that the block
should check whether it is full before processing the next char sample?
Anyone with experience writing modulator code have any tips? Can I keep
updating the value of out in the general_work and it will pass on to the
flowgraph?

OK, I really don’t know what you’re trying to do. Can you please make
sure you’ve read the tutorial on how to write blocks, and then tell us
exactly what your application is meant to do. Code snippets would also
help.

I have tried looking at what I believe is the PSK modulator source code,
gr_constellation.cc but it is a pretty hard piece of code to follow.

gr_constellation is just the mapping logic bits <-> symbols.

I appreciate any help and feedback.

MB

On Tue, Feb 18, 2014 at 5:30 AM, Martin B.
[email protected]wrote:

the process.
flowgraph?

I appreciate any help and feedback.

MB


Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page

Thank you for the response, I apologize, I wasn’t very clear at all in
explaining my problem and I can see that I came across confusing. Let me
quickly re-explain.

I am creating a QPSK modulator. I have a variable duration/sample rate
(stretching out the bit sequence, incase my terminology is incorrect).
The
minimum of it should be about two samples per input bit. I am also
having a
minimum two samples/symbol (just like the stock PSK modulator). I am
taking
the bit sequence of the input char and I am using unsigned char datatype
like the one block example from the tutorial unpack_k_bits_bb. Now I am
modulating the bit sequence into a waveform that has a set number of
samples as a result of the duration that is specified. So in the end I
have
N number of samples generated for every byte that is received from the
input buffer.

My confusion is the output_buffer. I look at the squarer code from the
tutorial and see general_work() and think of one input sample comes in,
one
output sample comes out for each execution of the routine. Lets just say
after processing 1 byte from the input, I have 800 samples of I and Q
data that make up the modulated waveform. Those 800 samples need get out
to
the flow graph before the next input comes in.

I don’t understand what you’re writing. In any block, you can output as
much items as is space in the output buffer (and should).

So I can write to the output buffer as much as I need to do, does it
involve set_output_multiple()?

Do I make sure noutput_items is equal to number of samples I wish to
output? I always though nouput_items equals 1 for non-vector data, and
d_vlen for any vectors whose size is d_vlen.

Would that change the output from a single sample to a vector of
samples?

I am going to feed directly to the USRP sink, so a vector output is not
what I want, just a continuous stream of samples.

Also, where can I see the source code for the PSK modulator block? When
I
type “PSK” in Nautilus’ search function, the only C++ code I see the
receiver, snr estimator. I see python scripts for it qpsk and dpsk, that
have calls for constellation. If that is it, I apologize for my
ignorance,
I thought it would be a normal C++ block.

Again, thank you very much, you have no idea how grateful I am for this
help.

Jon

On 02/19/2014 12:23 AM, Jonathan F. wrote:

Thank you for the response, I apologize, I wasn’t very clear at all in
explaining my problem and I can see that I came across confusing. Let me
quickly re-explain.

I am creating a QPSK modulator. I have a variable duration/sample rate
(stretching out the bit sequence, incase my terminology is incorrect).

Is your sampling rate variable, or the symbol rate? Where in the
modulation process should it vary?

The minimum of it should be about two samples per input bit. I am also
having a minimum two samples/symbol (just like the stock PSK
modulator). I am taking the bit sequence of the input char and I am
using unsigned char datatype like the one block example from the
tutorial unpack_k_bits_bb. Now I am modulating the bit sequence into a
waveform that has a set number of samples as a result of the duration
that is specified. So in the end I have N number of samples generated
for every byte that is received from the input buffer.

OK, but how is N calculated? At runtime, or at initialization?

My confusion is the output_buffer. I look at the squarer code from the
tutorial and see general_work() and think of one input sample comes in,
one output sample comes out for each execution of the routine. Lets just
say after processing 1 byte from the input, I have 800 samples of I and
Q data that make up the modulated waveform. Those 800 samples need get
out to the flow graph before the next input comes in.

Still don’t know how you’d get 800 samples from 1 byte, but let’s say
that is correct: In this case, you consume() 1 item (byte) and produce()
800 items (samples).

I don’t understand what you’re writing. In any block, you can output as
much items as is space in the output buffer (and should).

So I can write to the output buffer as much as I need to do, does it
involve set_output_multiple()?

You can write to the output buffer equal to or less than noutput_items
items.

Do I make sure noutput_items is equal to number of samples I wish to
output? I always though nouput_items equals 1 for non-vector data, and
d_vlen for any vectors whose size is d_vlen.

You only read from noutput_items, it’s how the scheduler tells you much
space there is in the buffer.

Would that change the output from a single sample to a vector of samples?

The i/o signature.

I am going to feed directly to the USRP sink, so a vector output is not
what I want, just a continuous stream of samples.

Also, where can I see the source code for the PSK modulator block? When
I type “PSK” in Nautilus’ search function, the only C++ code I see the
receiver, snr estimator. I see python scripts for it qpsk and dpsk, that
have calls for constellation. If that is it, I apologize for my
ignorance, I thought it would be a normal C++ block.

We don’t need a PSK modulator as such. Open the grc-examples for PSK,
and you will see we connect a “chunks to symbols” block to the pulse
shaping filter.

M