Re: [Discuss-gnuradio] Cumsum block on GRC

2011-05-08 Thread mehmet kabasakal
Hi Nick,

I made the change you suggested and it worked, thanks a lot.

Mehmet.

2011/5/7, Nick Foster :
> On Sat, 2011-05-07 at 15:53 +0100, Tom Rondeau wrote:
>> On Sat, May 7, 2011 at 3:44 PM, mehmet kabasakal
>> <85kabasa...@gmail.com> wrote:
>> Hi List,
>>
>> I am trying to write a block, that finds the cumulative sum of
>> the points.
>> But when i run the block on GRC, the output of the block
>> becomes as in
>> the attached figure. It wraps for a period of time. I expect
>> it to go
>> negatively downwards. Because i am accumulating negative
>> values. I
>> couldn't understand the reason. Is there something missing in
>> the
>> code. The c++ code of the block is attached also.
>>
>> Thanks for the help!
>> Mehmet.
>>
>>
>>
>> Mehmet,
>> It looks like it's because you are setting out[0] = 0 before entering
>> the for loop in your work function. This will then reset the counter
>> every time you enter work.
>
> I'm pretty sure it won't work even if you remove that call. You can't
> count on out[0] having any sort of reasonable value when invoking the
> work call. Try saving the cumulative sum in a private member variable of
> your class, initialize it to 0 in your constructor, and setting out[0]
> to that saved value when starting each work function call.
>
> --n
>
>>
>>
>> Tom
>>
>>
>> ___
>> Discuss-gnuradio mailing list
>> Discuss-gnuradio@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
>

___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Cumsum block on GRC

2011-05-07 Thread Nick Foster
On Sat, 2011-05-07 at 15:53 +0100, Tom Rondeau wrote:
> On Sat, May 7, 2011 at 3:44 PM, mehmet kabasakal
> <85kabasa...@gmail.com> wrote:
> Hi List,
> 
> I am trying to write a block, that finds the cumulative sum of
> the points.
> But when i run the block on GRC, the output of the block
> becomes as in
> the attached figure. It wraps for a period of time. I expect
> it to go
> negatively downwards. Because i am accumulating negative
> values. I
> couldn't understand the reason. Is there something missing in
> the
> code. The c++ code of the block is attached also.
> 
> Thanks for the help!
> Mehmet.
> 
> 
> 
> Mehmet,
> It looks like it's because you are setting out[0] = 0 before entering
> the for loop in your work function. This will then reset the counter
> every time you enter work.

I'm pretty sure it won't work even if you remove that call. You can't
count on out[0] having any sort of reasonable value when invoking the
work call. Try saving the cumulative sum in a private member variable of
your class, initialize it to 0 in your constructor, and setting out[0]
to that saved value when starting each work function call.

--n

> 
> 
> Tom
> 
> 
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio



___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] Cumsum block on GRC

2011-05-07 Thread Tom Rondeau
On Sat, May 7, 2011 at 3:44 PM, mehmet kabasakal <85kabasa...@gmail.com>wrote:

> Hi List,
>
> I am trying to write a block, that finds the cumulative sum of the points.
> But when i run the block on GRC, the output of the block becomes as in
> the attached figure. It wraps for a period of time. I expect it to go
> negatively downwards. Because i am accumulating negative values. I
> couldn't understand the reason. Is there something missing in the
> code. The c++ code of the block is attached also.
>
> Thanks for the help!
> Mehmet.



Mehmet,
It looks like it's because you are setting out[0] = 0 before entering the
for loop in your work function. This will then reset the counter every time
you enter work.

Tom
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio