# How to reset the phase for subsequent sweeps from VCO?

**URL:** <https://www.ruby-forum.com/t/how-to-reset-the-phase-for-subsequent-sweeps-from-vco/230889>\
**Category:** GNU Radio\
**Created:** [July 10, 2014, 7:29pm UTC](https://www.ruby-forum.com/t/how-to-reset-the-phase-for-subsequent-sweeps-from-vco/230889 "2014-07-10T19:29:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 10, 2014, 7:29pm UTC](https://www.ruby-forum.com/t/how-to-reset-the-phase-for-subsequent-sweeps-from-vco/230889/1 "2014-07-10T19:29:17Z")

</div>

Hi,

I am using the VCO block in GRC to generate complex-valued sweeps with  
BW  
of 50 KHz and a sweep time of 1 second. The VCO is driven by the  
sawtooth  
signal generator in GRC.

The problem I am facing is that subsequent sweeps do not start at the  
same  
time. Each new sweep seems to have a random phase shift relevant to the  
other. Please see the attached figure which demonstrates the case for  
seven  
subsequent sweeps. This figure was generated in Matlab after saving the  
output of VCO to a binary file in GRC. Then, for the sampling frequency  
of  
50 KHz, individual sweeps were resolved and superimposed on each other.

My question is, how do I reset the phase of the VCO at the beginning of  
each new sweep?

Thank you.

Best regards,  
Khalid

---

<div class="post-metadata">

**Author:** ![khalid.el-darymli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/6a8cbe/32.png) [@khalid.el-darymli](https://www.ruby-forum.com/u/khalid.el-darymli)\
**Post date:** [July 11, 2014, 12:59am UTC](https://www.ruby-forum.com/t/how-to-reset-the-phase-for-subsequent-sweeps-from-vco/230889/2 "2014-07-11T00:59:17Z")

</div>

On 07/10/2014 07:27 PM, khalid.el-darymli wrote:

> saving the output of VCO to a binary file in GRC. Then, for the sampling  
> frequency of 50 KHz, individual sweeps were resolved and superimposed on  
> each other.
> 
> My question is, how do I reset the phase of the VCO at the beginning of  
> each new sweep?

The block doesn’t let you do that, and it probably shouldn’t – a “VCO”  
has, by definition, a continuous phase.  
If you want full control, you could use the phase\_modulator block; but  
remember you need to calculate what the phase is for a sweep beforehand  
(you know integrate and that math stuff).

M

---

<div class="post-metadata">

**Author:** ![khalid.el-darymli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/6a8cbe/32.png) [@khalid.el-darymli](https://www.ruby-forum.com/u/khalid.el-darymli)\
**Post date:** [July 10, 2014, 9:58pm UTC](https://www.ruby-forum.com/t/how-to-reset-the-phase-for-subsequent-sweeps-from-vco/230889/3 "2014-07-10T21:58:51Z")

</div>

Hi Khalid,

the VCO is phase-continous, so the starting phase of your sweep should  
be continous with the end phase of your last sweep.  
The block does not offer a way to reset its phase; out of the top of my  
head there’s also no easy “workaround” for this, only rather complex  
solutions like constantly calculating the argument of the vco output,  
sample\_and\_hold that argument on the sawtooth minimum, and dividing the  
VCO output by the output of phase\_modulator with the sampled value as  
input (which should shift everything by the -phase(t=t\_sawtooth\_minimum)  
).

I think it might be easier for you to just copy the functionality of  
vco\_fc, but that would require programming a block in C++ or python  
(preferably C++, because you could just copy&paste 90% of the  
functionality from the original vco\_fc.h, vco\_fc\_impl.{cc,h}), and I  
don’t know if that suits your level of GNU Radio knowledge.

With best regards,  
Marcus M?ller

---

<div class="post-metadata">

**Author:** ![khalid.el-darymli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/6a8cbe/32.png) [@khalid.el-darymli](https://www.ruby-forum.com/u/khalid.el-darymli)\
**Post date:** [July 11, 2014, 3:06am UTC](https://www.ruby-forum.com/t/how-to-reset-the-phase-for-subsequent-sweeps-from-vco/230889/4 "2014-07-11T03:06:18Z")

</div>

Hi Martin and Marcus,

Thank you for your response.

Martin,

> > The block doesn’t let you do that, and it probably shouldn’t – a “VCO”  
> > has, by definition, a continuous phase.

Yes, this should be the case within the sweep time (say t\_m=1 sec),  
which is defined by the period (i.e., t\_m) of the sawtooth signal that  
drives the VCO. This is not my question. The issue I am having is  
pertinent to the beginning of each new sweep. Each new sweep should be  
identical replica of the first sweep. So, for the second sweep, a  
typical VCO would give me a chirp with the exact same phase as the first  
sweep, and so on. In the case of GNURadio, the VCO block doesn’t do  
that as shown in the attachment above.

Thanks,  
Khalid

---

<div class="post-metadata">

**Author:** ![khalid.el-darymli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/6a8cbe/32.png) [@khalid.el-darymli](https://www.ruby-forum.com/u/khalid.el-darymli)\
**Post date:** [July 11, 2014, 4:31am UTC](https://www.ruby-forum.com/t/how-to-reset-the-phase-for-subsequent-sweeps-from-vco/230889/5 "2014-07-11T04:31:01Z")

</div>

Hi again,

Based on the links below, there seems to be an option in the VCO block  
(the C++ code) to reset and the adjust the phase,  
[http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/4389b769891283face9aa397bd4d736f478e97e4/entry/gr-blocks/include/blocks/vco.h](http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/4389b769891283face9aa397bd4d736f478e97e4/entry/gr-blocks/include/blocks/vco.h)

[http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/4389b769891283face9aa397bd4d736f478e97e4](http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/4389b769891283face9aa397bd4d736f478e97e4)

Can I get to this from Python? and can it work while feeding the VCO  
with a sawtooth which has a particular period t\_m (i.e., sweep time) and  
run for a total time equivalent to a number of desired sweeps n\*t\_m?

Thanks,  
Khalid
