Continuous and Discrete data combine

Hello,

Is there any way to combine continuous block (like audio source) and
discrete block (like message source) ? Question 1

I using add block to add them together, but it failed. It work well when
the discrete block output data like continuous block but discrete block
means there is not output data continuous, it output data when something
trigger.

Can I write a block which input is message and output is like float, and
output will always generate like 32k samples but input doesn’t have 32k
samples suppose this block is sync. Is there any solution ? Question 2

Question 1 is the main problem and Question 2 is I think it is a
solution
but not sure it work.

Thanks,

Jeff Guo

On 08/07/2014 12:54 PM, 奕佑 wrote:

Hello,

Is there any way to combine continuous block (like audio source) and
discrete block (like message source) ? Question 1

Combine how? You can do that in your own blocks, sure. Maybe stream tags
are what you want?

I using add block to add them together, but it failed. It work well when
the discrete block output data like continuous block but discrete block
means there is not output data continuous, it output data when something
trigger.

Can I write a block which input is message and output is like float, and
output will always generate like 32k samples but input doesn’t have 32k
samples suppose this block is sync. Is there any solution ? Question 2

You can write a block who’s input is message and output is float. I
didn’t really understand the rest of the question.

M

Hello Martin,

If you create a block which input is message and output is float. And
message is arrive discrete just like packet in network, I want the block
output port will output 0 when no message arrive at input port. Can I do
that?

Why I ask this question is that I a while ago I trying to create a
communication system which I defined and there has two kinds of channel
one
is control channel and the other one is message channel like the GSM
system
I think so, and I’m using FDD. And control channel is using gmsk
modulation
and message channel is using fm modulation because I just want to
transmit
audio, I using enough BW to avoid aliasing. After gmsk mod and fm mod, I
add them together but result failed, because add block in gnuradio will
wait when two input data and add one-by-one so if if port one data is
much
more then port two, and the add will hold port one data and wait port
two
data then add one-by-one.

I have recreate the same situation and past in the mail, it is python
file
and can test it to check the problem

Here is my setting : I have two source one is audio source and the other
is
packet, and I add it together and output to audio sink. Important audio
source will generate data when program start. The first 5 second no
packet
is send. After 5 second packet source will send 1000 packets, meantime,
speaker have sound, and if you have say something in first 5 seconds,
you
will hear what you say in the first 5 second now.


#!/usr/bin/env python
##################################################

Gnuradio Python Flow Graph

Title: Top Block

Generated: Thu Aug 7 20:16:29 2014

##################################################

from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
from gnuradio import digital
from gnuradio import audio
from gnuradio import blocks
from time import sleep

class top_block(gr.top_block):

def __init__(self):
    gr.top_block.__init__(self, "Top Block1")

    ##################################################
    # Variables
    ##################################################
    self.samp_rate = samp_rate = 32000

    ##################################################
    # Blocks
    ##################################################
    self.digital_gmsk_mod_0 = digital.gmsk_mod( 

samples_per_symbol=2,
bt=0.35, verbose=False, log=False, )
self.digital_mod_pkts_0 =
digital.mod_pkts(self.digital_gmsk_mod_0,
access_code=None, msgq_limit=4, pad_for_usrp=False)
self.audio_source_0 = audio.source(samp_rate, “”, True)
self.audio_sink_0 = audio.sink(samp_rate, “”, True)
self.blocks_add_xx_0 = blocks.add_vcc(1)
self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
self.blocks_multiply_const_vxx_0 =
blocks.multiply_const_vcc((0.01,
))

    ##################################################
    # Connections
    ##################################################
    self.connect((self.blocks_add_xx_0, 0),

(self.blocks_complex_to_real_0, 0))
self.connect((self.blocks_complex_to_real_0, 0),
(self.audio_sink_0, 0))
self.connect((self.audio_source_0, 0),
(self.blocks_float_to_complex_0, 0))
self.connect((self.audio_source_0, 0),
(self.blocks_float_to_complex_0, 1))
self.connect((self.blocks_float_to_complex_0, 0),
(self.blocks_add_xx_0, 0))
self.connect((self.digital_mod_pkts_0, 0),
(self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))

def send_pkt(self, payload='', eof=False):
    self.digital_mod_pkts_0.send_pkt(payload, eof)

if name == ‘main’:
parser = OptionParser(option_class=eng_option, usage=“%prog:
[options]”)
(options, args) = parser.parse_args()
tb = top_block()
tb.start()
sleep(5)
for i in range(0, 1000):
tb.send_pkt(‘a’)
raw_input('Press Enter to quit: ')
tb.stop()
tb.wait()


Jeff Guo

2014-08-07 19:07 GMT+08:00 Martin B. [email protected]:

Hi,

If you have a hardware sink or source involved though, this is never the
correct approach, since you will end up with two competing clocks, and that
will, over a longer time, lead to over- or underflows. You can solve this
issue by either using a hardware sink that accepts bursts of data, so you
don’t have to zero pad, or by having a block that passes through input
samples (e.g. from a constant 0 source) and adds message-generated samples
when they occur.

Unfortunately that’s sometimes the only approach.

If you have a PFB synthesizer that create many parallel channels, then
relying on the sink block burst capability won’t work …
Or for cases where if you don’t have a packet to TX, then you should
TX a ‘filler’ frame rather than 0.

That limitation is pretty much a show stopper when you try to
implement TDMA system TX on gnuradio … :frowning:

For RX the streamtags now allow a good way to split them in packets,
but for TX that’s not sufficient.
Blocks should be able to get a notion of time provided by an external
device. And also monitor the buffer levels.

Cheers,

Sylvain

Hello,

I just remember my DSP teacher told me that the digital signal sample
rate
mean nothing in digital world, but in the “real” word it is important
and
sample rate is we assign the meaning to a group of data and we can to
like
fft or something needs time. So it’s my fault. Thank you for remind me
zero
padding, and I “think” I can create a block like source, because like
signal source can set the sample rate and I also create a block can set
sampling rate and give it a function that accept packet. Also I can try
bursts data, I never done before. Using constant 0 source I think I
doesn’t
work because after add message-generated the output data also same as
message-generated.

If I just connect message-generated to sink, it worked well. This
problem
will show up when discrete source and continuous source at a same time
and
trying to combine them together.

This question is from my project, but it’s finish. My solution is let
the
message-generated floating and when I need to send packet I lock the
flow
graph and reconfigure the connect and unlock, after sending the packet
also
reconfigure them.

Recently, I want to do not only physical layer but data link layer or
upper
layer and this problem just come to my mind. If I using gnu radio like
ethernet it work well because usurp sink will send data when it get
them.
But I want to create a system, so I cannot avoid to facing this problem.
Thanks for answering my question, help me a lot.

Sincerely,

Jeff Guo

Hi ??,
this question reveals that you have not considered GNU Radio to not be
bound by real time.
As samples are “bare numbers”, they don’t have a time. Thus, GNU Radio
nor any of the blocks involved care about how much time has passed in
the real world. Thus, for your block, while no message occurs time
“does not pass”. And you can only generate samples in the work function.

Therefore, yes, it can be done, but you’ll have to calculate in your
work how many samples you wanted to produce in the time since the last
call to work.

If you have a hardware sink or source involved though, this is never
the correct approach, since you will end up with two competing clocks,
and that will, over a longer time, lead to over- or underflows. You can
solve this issue by either using a hardware sink that accepts bursts of
data, so you don’t have to zero pad, or by having a block that passes
through input samples (e.g. from a constant 0 source) and adds
message-generated samples when they occur.

Greetings,
Marcus