Two sine waves
First post and very new in the dsp world but I'm learning.
For a small project I need two sine waves, e.g. 10 and 20khz. I placed a sine tone of 10khz and used the multiplication block to get the 20khz tone. Obeserving both waves on a oscillioscope I discovered that they seemed to be phase locked (prob are) but the sine waves don't cross the zero axis at the same point. My guess is that they are 45 deg shifted. Of course I can use a delay or all pass filter to correct this but rather not. Is there any simple solution to this? Why are they shifted?
Simon
Hello Simon,
Squaring the sine wave is a good way to get a synchronized double-frequency wave, as this uses the trig identity:
sin^2(theta) = 0.5*(1-cos(2*theta))
Problem is, since the result includes a cosine, it's phase shifted 90 degrees from where you want it (or, 45 degrees from the original sine wave). To fix this, you'll need to do a 45 degree shift ahead of the square. As you pointed out, a delay or filter would work but would not be preferable. The method shown below avoids these, and in addition it keeps the two outputs correctly phased even with an adjustable frequency.
Recent versions of SigmaStudio include a Quadrature VCO block; version 3.9 Beta added this feature to the ADAU1701/2.. It outputs both a sine and a cosine wave. Adding these together provides a 45-degree shifted wave. This in turn can be squared to provide your double-frequency output. Fundamental frequency is set by the DC source:
V = 2* f / fs
In the above example, I set the frequency to only 0.1 Hz, to view the outputs on two Real-Time Displays. To make this run at 10KHz, set the DC source to 0.41667
When I tried this the two Real-Time Displays did appear to go through zero simultaneously, although the real test will be when you run it full speed and view the results on your scope.
Best regards,
Bob
Excellent solution, Bob! Thanks for sharing!
(By the way, I just returned from a 2 week business trip - I should be more active on the forums now...)
Brett
Brett, Welcome back!
Simon, Welcome aboard!
Bob
Hi Bob,
Sorry for the late response but we finally had some good summer days!! I tried your solution and it works perfect!
I had only one issue when I executed the code. Looking at both sine waves on the scope they apear to be 180 deg. shifted. I couldn't understand why but then I realised that the vco produced a sine and consine but which output is which? I couldn't find any info in the help section about this new vco and the symbol wasn't much help either. So I just swapped the ouputs and voila the two sine waves are starting at the same zero degs.
Thanks again for this quick fix it helped me a lot!
regards,
Simon
Found it! If you hover over the output pins of the vco then it shows which pin is sine and cosine.............
Simon
Hi Simon,
Glad to know the idea was of help. Thanks for the tip on the VCO outputs, I didn't know which was which either. Often the SigmaStudio Toolbox wiki is more up-to-date than the help file, see
https://wiki.analog.com/resources/tools-software/sigmastudio/toolbox
Bob
Thank you for your support, Bob!
Please log in to reply.

