# Generate a specific wave form

**URL:** <https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512>\
**Category:** GNU Radio\
**Created:** [June 29, 2015, 4:23pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512 "2015-06-29T16:23:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 29, 2015, 4:23pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/1 "2015-06-29T16:23:50Z")

</div>

Hello, guys.

I need a help, please. I need to generate the kind of wave showned in  
the picture attached, but I don’t know which are the proper blocks.  
Can anyone help me, please?

Image’s credits:  
[http://www.ece.uvic.ca/~elec350/lab\_manual/ar01s04s05.html](http://www.ece.uvic.ca/~elec350/lab_manual/ar01s04s05.html)

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 29, 2015, 4:37pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/2 "2015-06-29T16:37:06Z")

</div>

Hi Antonny,

There’s the CPFSK block; If your picture is actually showing the  
frequency domain representation of the signal you want to get, then this  
is most likely what you directly want to use.

By the way, I do recommend you just sign up to the GNU Radio mailing  
list with a proper email address under:  
[https://lists.gnu.org/mailman/listinfo/discuss-gnuradio](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)  
Going through ruby-forum (which we don’t have any affiliation too, as  
far as I can tell) is more than bothersome, as replies tend to get lost.

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 29, 2015, 4:50pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/3 "2015-06-29T16:50:32Z")

</div>

If those overshoots are unwanted but inevitable due to hardware  
characteristics and limitations,

you can generate a wave form with vector source with input sequence  
1010010000111…

Then, the output will be HLHLLHLLLLHHH… (H = HIGH, LOW = LOW)

Regards,  
Jeon.

2015-06-29 23:23 GMT+09:00 Antonny C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 30, 2015, 2:53pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/4 "2015-06-30T14:53:14Z")

</div>

Jeon wrote in post #1175836:

> If those overshoots are unwanted but inevitable due to hardware  
> characteristics and limitations,
> 
> you can generate a wave form with vector source with input sequence  
> 1010010000111…
> 
> Then, the output will be HLHLLHLLLLHHH… (H = HIGH, LOW = LOW)
> 
> Regards,  
> Jeon.
> 
> 2015-06-29 23:23 GMT+09:00 Antonny C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

Well, I don’t think this solution using vector works (I might be wrong,  
of course). I tried to build it in Gnuradio 3.7.2.1 (Ubuntu 14.04 LTS).  
The prints are shown below:

Blocks:  
[http://i62.tinypic.com/i2ppjl.png](http://i62.tinypic.com/i2ppjl.png)

Input signal:  
[http://i61.tinypic.com/29zy7ft.png](http://i61.tinypic.com/29zy7ft.png)

Output Signal:  
[http://i60.tinypic.com/rjjy9u.png](http://i60.tinypic.com/rjjy9u.png)

Vector created:  
[http://i57.tinypic.com/2efru6o.png](http://i57.tinypic.com/2efru6o.png)

What I need to do is a kind of “switch”. With this vector in the Ctrl  
Port of the Sample & Hold, I want the same wave of the input in the  
output, but appearing and desappearing according to the Vector Source (0

- no signal, 1 - entire signal).

If the signal in the Input Port is a square wave, then I want the same  
wave but appearing and desappearing in a random way according to the  
vector I created, but It isn’t happening.

I don’t know if I was clear enough. Please, help me and tell me if you  
need more details about my problem.

Sorry and thank you.

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 30, 2015, 7:48pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/5 "2015-06-30T19:48:16Z")

</div>

Marcus, I’m using it because the vector isn’t the signal I want. The  
vector is just to control when a signal goes to the output and when it  
doesn’t. Like I said: 0 - no signal, 1 - entire signal.

The sample and Hold block should pass the signal to the output when ctrl  
= 1 and hold the output when ctrl = 0, but it doesn’t happen and I don’t  
know why.

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 30, 2015, 8:02pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/6 "2015-06-30T20:02:13Z")

</div>

Have you tried to miltuply the signals?  
Because your vector source outputs ones and zeros it will not change the  
shape of the signal but it will enable (.1) or disable (.0) the original  
signal.

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 30, 2015, 4:25pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/7 "2015-06-30T16:25:28Z")

</div>

Why do you use the sample and hold block?  
You could use  
vector\_source-\>(throttle)-\>QT time sink

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 30, 2015, 8:11pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/8 "2015-06-30T20:11:55Z")

</div>

Rafael,

Yes, I have… It didn’t work either and I don’t know why. The first  
thing I tried was multiply the signals. It’s really strange.

There are some blocks in GNURadio that don’t do what they say they do,  
like this Sample and Hold block. This block don’t “hold” the samples,  
like it should do.

The implementation of Sample and Hold, for example, in another softwares  
work perfectly, but in GNURadio it doesn’t and it is a standard block.  
It’s very strange.

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 30, 2015, 8:26pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/9 "2015-06-30T20:26:46Z")

</div>

* * *

Discuss-gnuradio mailing list  
removed\_email\_address@domain.invalid  
[https://lists.gnu.org/mailman/listinfo/discuss-gnuradio](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [June 30, 2015, 9:17pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/10 "2015-06-30T21:17:36Z")

</div>

0= no signal, 1 = full signal:  
then just use a multiplier!

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 4:59am UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/11 "2015-07-01T04:59:39Z")

</div>

Rafael and Marcus,

I see what you mean, but you didn’t understand what I wanna do.  
Using a multiplier you are modificating the original signal. I don’t  
want to multiply the samples, I want nothing or the entire signal.

What I mean is:  
0 = no signal at all, everything is 0 and not only a piece of the  
signal. The entire sine wave times 0 -\> sine x 0 = 0.  
1 = the entire signal, but not only a sample x 1, like you showed. I  
need to multiply everything by 1 and leave the signal pass.

Abstract:

“Nothing” if the control is 0, and “EVERYTHING” if the control is 1. I  
don’t need pieces of wave times 0 or 1, I need the whole signal times 0  
or 1, like a switch. Did you get it? It’s hard to build it here.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 6:05am UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/12 "2015-07-01T06:05:41Z")

</div>

Dear Caesar,

If there’s a certain purpose of this work but that is not explained this  
post, it’s better for us to know the purpose.  
But, you might not want to explain that if it is confidential.

Anyway,  
The original signal stays unmodified. You can get the original signal by  
connecting the original source block to another block.  
And you can get the whole part of the the original signal or nothing by  
setting duration, repetition or interpolation of each bit from a vector  
stream, which will be a multiplier.

You can easily set a length/duration of each sample from a vector source  
by  
using repeat block.  
The figure above will generates 200 zeros, 200 ones, 200 zeros and 200  
ones.  
It is equivalent to a vector source with (0, 0, 0, …, 1, 1, 1, …, 0,  
0,  
0, …, 1, 1, 1, …)

But, if you want something different,  
for example, if you want to pause/stop the signal source block (or USRP  
source block, etc.) temporarily when the switch block (the vector source  
block or other trigger blocks) give zero  
and resume the source block when the switch block gives one,  
it seems you need to approach the problem in a different way.

As I read your question again, it seems that you want a flow graph to  
output literally ‘nothing’ not even zero, is it right?  
In other words, you want to drop a part of the original signal when the  
switch value is zero.  
In that case, a valve block might help you. But I doubt that a vector  
source can be an argument of the valve block.  
(I might be wrong. There can be a block can do what you want, but not  
sure  
about it.)

I recommend you to build a pass-or-drop, pass-or-block block.

Regard,  
Jeon.

2015-07-01 11:59 GMT+09:00 Antonny C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 9:05am UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/13 "2015-07-01T09:05:37Z")

</div>

Hi Antonny,  
I might really just have misunderstood what you want.  
If Jeon’s reply didn’t solve your problem, I’d like to ask you to draw a  
proper diagram, with labeled axes, and your signal, and when and why  
that signal has a specifix value, and what kind of things you want to  
feed in and what kind of things you want to get out.

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 2:30pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/14 "2015-07-01T14:30:00Z")

</div>

Hi Antonny,

> A primary user might be sending a signal all the time (this is my signal  
> source block). During this event, my Energy Detector will analyse the  
> spectro and pass or not the signal of my primary user (the entire  
> signal, everything that is being sent),  
> That is exactly the functionality of the power\_squelch block 🙂  
> because that’s what a cognitive radio does.  
> Well, yours 🙂  
> So, when it’s possible, I will use the spectro to send a few  
> informations.  
> I’m still not totally clear on what kind of _signal_ you want to  
> produce, or whether you describe a temporal _behaviour_ of your system.

What aspect of your implementation are you currently working on? The  
Energy Detector/pass-through functionality?

Best regards,  
Marcus

PS: I think you’ve described your thing pretty well, I’m just not  
getting it, sorry.  
I think at this point, a drawing with a few annotations of what your  
system should do would do wonders, because then we’d have something  
clear to refer to when discussing!

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 2:20pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/15 "2015-07-01T14:20:11Z")

</div>

Jeon and Marcus,

I’m very happy you’re helping me. This is the first time I use  
GNURadio and it’s very different of other softwares I usually work.

I can tell you my purpose, no problem at all. I’m trying to start a  
project about Cognitive Radio. For now, I want to build an Energy  
Detector.

A primary user might be sending a signal all the time (this is my signal  
source block). During this event, my Energy Detector will analyse the  
spectro and pass or not the signal of my primary user (the entire  
signal, everything that is being sent), because that’s what a cognitive  
radio does. So, when it’s possible, I will use the spectro to send some  
information.  
When the spectro is being used (vector = 0, for example), I can’t send  
information, because it would damage the signal of other person. I just  
want to send data, when the spectro is not being used (vector = 1).

To simulate this analysis, I was trying to use a vector source or a  
random source, because it’s impossible to know when the spectro will be  
free; it’s random.

I think it’s easier to understand now. Thank you a lot for helping me  
here, guys.

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 2:35pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/16 "2015-07-01T14:35:51Z")

</div>

On 01/07/15 14:20, Antonny C. wrote:

> A primary user might be sending a signal all the time (this is my signal  
> source block). During this event, my Energy Detector will analyse the  
> spectro and pass or not the signal of my primary user (the entire  
> signal, everything that is being sent), because that’s what a cognitive  
> radio does. So, when it’s possible, I will use the spectro to send a few  
> informations.  
> When the spectro is being used (vector = 0, for example), I can’t send  
> information, because it would damage the signal of other person. I just  
> want to send data, when the spectro is not being used (vector = 1).

Do you mean that you want to “pause” the transmission or that you want  
to “mute” the transmission?

Cheers,  
Daniele

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 3:22pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/17 "2015-07-01T15:22:54Z")

</div>

Daniele,

Mute the transmission is closer to the reality, because when the  
spectrum is being used by another person, the signal I’m sending will be  
lost.

Thank you.

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 3:08pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/18 "2015-07-01T15:08:31Z")

</div>

Marcus,

Yes! For now, the pass-through functionality is fine for me. I saw the  
Power Squelch block but it doesn’t have a “control input” to decide when  
my signal will pass through.

This signal can be a sine, square wave, etc, but I think it isn’t  
important, because if I have the Energy Detector working fine, it will  
always do its function, right?

The Detector can’t decide according to the signal I want to send. The  
decision is made according to the spectrum, that is, my vector (0 or 1).

Like a tap: I have a control(vector) and the water (my signal) goes down  
according to the opening (vector = 0 or vector = 1). The amount of water  
that goes down doesn’t need to “analyse the water”, just the control  
(vector) and then, leave the water pass.

Using a tap was my best explanation for now haha

Again, thank you a lot.

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 1, 2015, 3:31pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/19 "2015-07-01T15:31:57Z")

</div>

Antonny,

On 07/01/2015 03:08 PM, Antonny C. wrote:

> Marcus,
> 
> Yes! For now, the pass-through functionality is fine for me. I saw the  
> Power Squelch block but it doesn’t have a “control input” to decide when  
> my signal will pass through.  
> Well, the job of the power squelch _is_ to figure out whether the signal  
> should be passed through, based on the signal itself.  
> This signal can be a sine, square wave, etc, but I think it isn’t  
> important, because if I have the Energy Detector working fine, it will  
> always do its function, right?  
> Well, if that signal has energy (as defined by your Energy detector),  
> yes, I guess.  
> The Detector can’t decide according to the signal I want. The decision  
> is made according to the spectrum, that is, my vector (0 or 1).  
> I don’t understand. “The spectrum”: What does this mean to you?  
> Spectrum is usually used as a expression describing the wholeness of  
> signals in a given frequency range.  
> Like a tap: I have a control(vector) and the water (my signal) goes down  
> according to the opening. The amount of water that goes down doesn’t  
> need to “analyse the water”, just the control (vector) and then, leave  
> the water pass.  
> So the question is: Your control can be 0 or 1, right? (Please reply  
> in-line)

Let’s define:  
n\_in = samples going into your “tap”  
n\_out = samples coming out of your “tap”  
n\_ctrl = control values going into your “tap”

While the control is 0, do you  
a) want your samples coming out of the “tap” to be constant 0, meaning  
that n\_in=n\_out=n\_ctr, OR  
b) want the samples to just be dropped, n\_in = n\_ctrl, n\_in \< n\_out;  
c) you want your tap to just let samples through when control is 1, so  
that it behaves like a real water tap, holding water back, meaning that  
n\_in = n\_out \> n\_ctrl

> Using a tap was my best explanation for now haha  
> That’s why I still ask you for a quick drawing 🙂

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![pgpab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/13edae/32.png) [@pgpab](https://www.ruby-forum.com/u/pgpab)\
**Post date:** [July 2, 2015, 2:28pm UTC](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512/20 "2015-07-02T14:28:12Z")

</div>

Marcus,

I made the drawing; it’s attached. I want the entire signal or “nothing”  
in the output.  
It’s the same of multiplying my signal by 0 or 1. The problem is: these  
factors (0 and 1) have to appear in a random way. I can’t predict it,  
that is, I don’t know when the output is “nothing” or the entire signal,  
that’s what I need.

I think it’s easier now.

Thank you.

[Next page](https://www.ruby-forum.com/t/generate-a-specific-wave-form/242512.md?page=2)
