On Wed, Jun 15, 2011 at 03:27:18PM -0700, Henry M. wrote:
two output samples at the same time but what I want from scheduler is to
compute a single output sample, no less and no more. So, if the input to the
custom block is coming at a rate of 20 samples/sec, how frequent will work() or
general_work be called? Also, if during a call to work(), noutput_items comes
out to be “n” (more than 1) then it computes “n” output samples at the same
time which I do not want. I want to generate 1 sample, send it, wait for the
feedback, and then after arrival of feedback compute the new output sample from
custom block and so on. How to do it? Any ideas?
Hi Henry,
some thoughts:
noutput_items is the number of items your block is expected to
produce. You can always choose to translate 1 input sample into 1
output sample and then exit the work() function. Simply end your
work() function with ‘return 1;’.
(You should be using a gr_sync_block, not a gr_block, for this!)
Something like:
int block::work(…)
{
const unsigned char *in = &input_items[0];
unsigned char *out = &output_items[0];
*in = f(*out); // Where f(x) is what you do
return 1;
}
Still, I don’t think this will help you and actually, I’m not sure you
understood what Colby and John have been trying to say.
GNU Radio does not have a concept of time and sampling frequencies.
You make it sound like precisely clocked elements in digital circuitry,
but GNU Radio kind of randomly assigns processor time to each block, you
have no real way to influence when it is actually run!
So, to say your block has a sampling rate of x is completely
meaningless for its guts. This is what you need for most kind of signal
processing, anyway.
So, to answer your question: work() or general_work() are called at
random times, whenever the GNU Radio scheduler decides there’s enough
stuff in the input buffer of your block. You won’t know when. Neither in
sample time, nor in real time.
For this reason, feedback loops are very difficult to implement. A
feedback loop inside a flow graph is not even possible.
Via air, it might be doable–but I don’t recommend actually using GNU
Radio for this, at least not at this state of the code.
If you’re familiar with real-time programming (i.e. writing code where
instructions get executed at a guaranteed timing) you might even write a
custom application that uses UHD.
If you’re not used to doing this, the only other option I can think of
is a pact with the devil: Matlab/Simulink has realtime capabilities and
supports feedback loops.
Good luck,
MB
From: John A. [email protected]
output rate of my custom block to exactly 20 samples/sec? That is, the
out every 4th input sample to the output, and effectively reducing the sampling
unsigned char *out = (unsigned char *)output_items[0];
int
for (int j=0;j<4;j++){
consume(noutput_items);
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page
–
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)
Dipl.-Ing. Martin B.
Research Associate
Kaiserstraße 12
Building 05.01
76131 Karlsruhe
Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu
KIT – University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association