FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2004, 02:51 PM
Me
Guest
 
Posts: n/a
Default Re: mixing sine waves

viswanath wrote:

> Hi,
> I have a question regarding mixing discrete sine waves. If you have
> two sine waves sin(w1*t) and sin(w2*t) and they are sampled at the
> same rate. If you are mixing them in a receiver operation, we are
> supposed to get at the output of the mixer the sum and difference of
> frequencies. But it is just the values that we are multiplying isn't
> it, at the sampled time instants?


word a, b;
float c;

...
while (1) // do forever
{
while (noInterrupt) // wait for ADC interrupt
;
a = inword (ADC1); // read ADC1 data sample (signed binary)
b = inword (ADC2); // and ADC2 data sample

#ifdef DOUBLESIDEBANDSUPPRESSEDCARRIER
c = a * b; // change this line for different types
// of modulation
#endif
#ifdef DOUBLESIDEBANDAM
c = a * (0.5 * b + 0.5); // typecasting can be tricky here
#endif

outword (DAC1, c/65536.0); // 65536 ~~> 16 bit right shift
} // then send AM'd result o/p sample
...

/* I hope I have the shift values correct */


> How do we end up getting a difference frequencies and sum frequencies
> which have to be low pass filtered?


This may seem tedious, but it is really worth the effort as it will lay all
sorts of questions to rest in your mind.

Plot at least 10 cycles each of 3 sine waves (Fc-Fm=900Hz, Fc=1000Hz,
Fc+Fm=1100Hz) which start initially in phase. The peak amplitudes of plots
1 & 3 each being half the peak amplitude of plot 2.

Add up the time-corresponding instantaneous values, you will get a result
wave which appears to be AM'd at 100Hz.

At certain places the sum of the sideband points will either add to or
subtract from the carrier amplitude as the relative phase alignment of the
signals change.

You can get the same result by multiplying a 100Hz wave by a 1000Hz wave
(normal AM process). Scale the 100Hz wave to be half the amplitude of the
1000Hz wave. The 0.5 offset causes the o/p amplitude to vary around an
average value, as is typical of AM radio stations.

Setting the offset to zero will cause carrier suppresion, with only the
sidebands propagating. In this case the o/p phase will be seen to reverse
phase at 1/2 Fmod cycle periods.


> I have read from trigonometry and analog communications but somehow I
> am missing some essence here. Could you please let me know how the
> above is possible?


By perverse logic, it does not matter whether you create the sideband
signals by addition or multiplication, both results must have the same
component frequencies, and an AM demodulator will treat both cases
interchangeably.

Multiplication is the method of choice where the modulation signal is
dynamically changing (normal situation).

Now that you've got the crude picture, use the maths to prove it.

Hope this helps,
Jim A.
Reply With Quote
  #2 (permalink)  
Old 05-11-2004, 09:29 PM
viswanath
Guest
 
Posts: n/a
Default mixing sine waves

Hi,
I have a question regarding mixing discrete sine waves. If you have
two sine waves sin(w1*t) and sin(w2*t) and they are sampled at the
same rate. If you are mixing them in a receiver operation, we are
supposed to get at the output of the mixer the sum and difference of
frequencies. But it is just the values that we are multiplying isn't
it, at the sampled time instants?
How do we end up getting a difference frequencies and sum frequencies
which have to be low pass filtered?
I have read from trigonometry and analog communications but somehow I
am missing some essence here. Could you please let me know how the
above is possible?
I would greatly appreciate a response.
Thanks,
Viswanath
Reply With Quote
  #3 (permalink)  
Old 05-11-2004, 10:07 PM
Naresh
Guest
 
Posts: n/a
Default Re: mixing sine waves


2sin(w1*t)sin(w2*t) = cos[(w1-w2)t]-cos[(w1+w2)t]

On 11 May 2004, viswanath wrote:

> Hi,
> I have a question regarding mixing discrete sine waves. If you have
> two sine waves sin(w1*t) and sin(w2*t) and they are sampled at the
> same rate. If you are mixing them in a receiver operation, we are
> supposed to get at the output of the mixer the sum and difference of
> frequencies. But it is just the values that we are multiplying isn't
> it, at the sampled time instants?
> How do we end up getting a difference frequencies and sum frequencies
> which have to be low pass filtered?
> I have read from trigonometry and analog communications but somehow I
> am missing some essence here. Could you please let me know how the
> above is possible?
> I would greatly appreciate a response.
> Thanks,
> Viswanath
>


Reply With Quote
  #4 (permalink)  
Old 05-12-2004, 01:02 AM
Bhaskar Thiagarajan
Guest
 
Posts: n/a
Default Re: mixing sine waves

"viswanath" <[email protected]> wrote in message
news:[email protected] om...
> Hi,
> I have a question regarding mixing discrete sine waves. If you have
> two sine waves sin(w1*t) and sin(w2*t) and they are sampled at the
> same rate. If you are mixing them in a receiver operation, we are
> supposed to get at the output of the mixer the sum and difference of
> frequencies. But it is just the values that we are multiplying isn't
> it, at the sampled time instants?


You are multiplying time domain values to get 1 set of time values. The sum
and difference frequencies are in the frequency domain. I'm sure you agree
that a single set of time values can have multiple frequency components.
That should explain your paradox.

> How do we end up getting a difference frequencies and sum frequencies
> which have to be low pass filtered?
> I have read from trigonometry and analog communications but somehow I
> am missing some essence here. Could you please let me know how the
> above is possible?
> I would greatly appreciate a response.
> Thanks,
> Viswanath



Reply With Quote
  #5 (permalink)  
Old 05-12-2004, 05:25 PM
Tachyon
Guest
 
Posts: n/a
Default Re: mixing sine waves

When they say "mixing," it means "apply a nonlinear operation."
When you do THAT, you get sum and difference freq's like the
formula a previous reply contained.

for example, if you receive a signal consisting of a
1000 Hz waveform and a 10Hz waveform, then multiply by itself,
you'll find it contains frequencies 10,20,990,1010,2000.



On 2004-05-11, viswanath <[email protected]> wrote:
> Hi,
> I have a question regarding mixing discrete sine waves. If you have
> two sine waves sin(w1*t) and sin(w2*t) and they are sampled at the
> same rate. If you are mixing them in a receiver operation, we are
> supposed to get at the output of the mixer the sum and difference of
> frequencies. But it is just the values that we are multiplying isn't
> it, at the sampled time instants?
> How do we end up getting a difference frequencies and sum frequencies
> which have to be low pass filtered?
> I have read from trigonometry and analog communications but somehow I
> am missing some essence here. Could you please let me know how the
> above is possible?
> I would greatly appreciate a response.
> Thanks,
> Viswanath



--
different MP3 every day! http://gweep.net/~shifty/snackmaster
. . . . . . . . ... . . . . . .
"Maybe if you ever picked up a goddamn keyboard | Niente
and compiler, you'd know yourself." -Matthew 7:1 | [email protected]
Reply With Quote
  #6 (permalink)  
Old 05-12-2004, 06:44 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: mixing sine waves

Me wrote:

> ... Scale the 100Hz wave to be half the amplitude of the
> 1000Hz wave. The 0.5 offset causes the o/p amplitude to vary around an
> average value, as is typical of AM radio stations.


It's not clear from that that a DC offset is involved. An equation for
AM at m modulation factor (m = 1 is 100% modulation) and unity carrier
amplitude is
v = sin(w_c*t)*[1 + m*sin(w_m*t)]/2

(I hope it's clear that w_c and w_m are the carrier and modulating
frequencies, respectively.) The equation remains valid if either sine
is changed to cosine (or both).

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

Reply With Quote
  #7 (permalink)  
Old 05-12-2004, 07:58 PM
Fred Marshall
Guest
 
Posts: n/a
Default Re: mixing sine waves


"viswanath" <[email protected]> wrote in message
news:[email protected] om...
> Hi,
> I have a question regarding mixing discrete sine waves. If you have
> two sine waves sin(w1*t) and sin(w2*t) and they are sampled at the
> same rate. If you are mixing them in a receiver operation, we are
> supposed to get at the output of the mixer the sum and difference of
> frequencies. But it is just the values that we are multiplying isn't
> it, at the sampled time instants?
> How do we end up getting a difference frequencies and sum frequencies
> which have to be low pass filtered?
> I have read from trigonometry and analog communications but somehow I
> am missing some essence here. Could you please let me know how the
> above is possible?


Is it possible that you are really concerned about various kinds of
aliasing?

Let's take a simple case:

sin(2*pi*100*t) and sin(2*pi*120*t)

We will assume that these are sampled at 300Hz (which is 2.5 times 240Hz
which is 2 times 120Hz, the highest frequency component. The sample
interval is then T=1/300 seconds.

We will assume that the record of samples of temporal length NT encompasses
some integral number of seconds NT so that N must be some integral multiple
of 300. This way we can assume that the record of N samples is a single
period of a periodic waveform with no transients at the edges. That way we
don't have to worry about frequency components that approach 2 times 120Hz -
240Hz, the Nyquist limit for the highest frequency component.

The original 100Hz waveform has components at +/-100Hz and repeats at
+/-200Hz and +/-400Hz (mirrored around +/-300Hz), etc. ad infinitum.
The original 120Hz waveform has components at +/-120Hz and repeats at
+/-180Hz and +/-420Hz (mirrored around +/-300Hz), etc. ad infinitum.
So, there are already components at sum and difference frequencies of the
original sinusoids and the sample rate - before any mixing is done.
We note that this spectrum is periodic at 300Hz.

Because the time record is discrete, it implies the spectrum is periodic as
above. So, if you choose to conveniently show only one period of the
spectrum as would be done with a DFT pair then the 200Hz component and
the -100Hz component are coincident and you don't see any of the higher
frequencies. You only see them if you plot the peridic spectrum
from -infinity to +infinity or if you plot the periodic spectrum in a
"super" period say from zero to 3000Hz where 10 periods of the spectrum are
shown. This changes nothing, it's just how you decide to look at it.

OK.

Now we will conceptually prepare to "mix", i.e. multiply, the two records of
samples together.
We note that multiplying in time is equivalent to convolving in frequency.
Let us assume that we are starting with N samples in time and, thus, N
samples in frequency over a single spectral period.
In order to do a circular convolution in frequency without overlap, the
frequency samples need to be zero-extended so there are 2*N samples.
This means adding 300 zeros from where the existing samples lie at 150Hz to
450Hz which has the effect of increasing the spectral period. The temporal
sample rate thus changes to 600Hz and there are 2x the number of samples.
There remain to be N*T seconds in the temporal record.

Now the spectra have terms at 100 and 500Hz (-100Hz) and at 120 and 480Hz
(-120Hz).

When the circular frequency convolution is done, you get spectral components
at:
20Hz = 120 - 100,
220Hz = 120 + 100,
380Hz = 480 - 100,
580Hz = 480 + 100

Had the zero-extension from 150 to 450Hz not been done, the components at
380Hz and 580Hz would be aliased such that there would only be terms at:
20Hz, 80Hz, 220Hz and 280Hz.
20Hz = 120 - 100 as before
80Hz = 180 - 100 which is an aliased version of the 380Hz term
220Hz = 120 + 100 as before
280Hz = 180 + 100 which is an aliased version of the 580Hz term

So, in order to multiply two temporal records, it appears that you need to
increase the sample rate by a factor of 2 before you do it. Or maybe the
rule is more complicated but I don't see that right now.

Fred


Reply With Quote
  #8 (permalink)  
Old 05-12-2004, 10:14 PM
Richard Dobson
Guest
 
Posts: n/a
Default Re: mixing sine waves

Not quite as many a that! This is what music synthesists call "ring
modulation". In the days of analogue subtractive synthesis, this was just about
the only way to obtain inharmonic sounds (also famed as the method for turning
the speaking voice into a Dalek). You get (just) the sum and difference
frequencies, but neither of the input frequencies. So, with inputs at 1000 and
10, you will get (just) 900 and 1010. The difference of these is 20Hz, which you
may hear as a roughness in the sound. This is audible beating right at the
threshold of becoming a pitched tone; but this is an artefact of the human
hearing mechansim, it will not show up as a frequency component using FFT, for
example.

Richard Dobson


Tachyon wrote:

> When they say "mixing," it means "apply a nonlinear operation."
> When you do THAT, you get sum and difference freq's like the
> formula a previous reply contained.
>
> for example, if you receive a signal consisting of a
> 1000 Hz waveform and a 10Hz waveform, then multiply by itself,
> you'll find it contains frequencies 10,20,990,1010,2000.
>
>
>


Reply With Quote
  #9 (permalink)  
Old 05-13-2004, 10:07 PM
Tachyon
Guest
 
Posts: n/a
Default Re: mixing sine waves

On 2004-05-12, Richard Dobson <[email protected]> wrote:
> Not quite as many a that! This is what music synthesists call "ring
> modulation". In the days of analogue subtractive synthesis, this was just about
> the only way to obtain inharmonic sounds (also famed as the method for turning
> the speaking voice into a Dalek). You get (just) the sum and difference
> frequencies, but neither of the input frequencies. So, with inputs at 1000 and
> 10, you will get (just) 900 and 1010.


Oops, I changed the discussion a little bit. The OP was talking about
mixing two separate signals, then I started talking about non-linear
operations on a signal containing two frequencies. Nevertheless,
though, there is still an error in my post:

>> for example, if you receive a signal consisting of a
>> 1000 Hz waveform and a 10Hz waveform, then multiply by itself,
>> you'll find it contains frequencies 10,20,990,1010,2000.


It should read "...it contains frequencies 20,990,1010,2000."

-N



> Tachyon wrote:
>
>> When they say "mixing," it means "apply a nonlinear operation."
>> When you do THAT, you get sum and difference freq's like the
>> formula a previous reply contained.
>>
>> for example, if you receive a signal consisting of a
>> 1000 Hz waveform and a 10Hz waveform, then multiply by itself,
>> you'll find it contains frequencies 10,20,990,1010,2000.
>>
>>
>>

>



--
different MP3 every day! http://gweep.net/~shifty/snackmaster
. . . . . . . . ... . . . . . .
"Maybe if you ever picked up a goddamn keyboard | Niente
and compiler, you'd know yourself." -Matthew 7:1 | [email protected]
Reply With Quote
  #10 (permalink)  
Old 05-16-2004, 10:32 AM
glen herrmannsfeldt
Guest
 
Posts: n/a
Default Re: mixing sine waves

Richard Dobson wrote:

> Not quite as many a that! This is what music synthesists call "ring
> modulation". In the days of analogue subtractive synthesis, this was
> just about the only way to obtain inharmonic sounds (also famed as the
> method for turning the speaking voice into a Dalek). You get (just) the
> sum and difference frequencies, but neither of the input frequencies.


Otherwise, it is called a doubly balanced mixer.

> So, with inputs at 1000 and 10, you will get (just) 900 and 1010. The
> difference of these is 20Hz, which you may hear as a roughness in the
> sound. This is audible beating right at the threshold of becoming a
> pitched tone; but this is an artefact of the human hearing mechansim, it
> will not show up as a frequency component using FFT, for example.


One use they have been put to is voice scrambling. Not so secure,
but it works well enough for some uses.

Also in the demodulator for FM stereo signals.

-- glen

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SDIO CRC7 + VCD waves [email protected] FPGA 1 05-09-2008 09:14 AM
free SDIO CRC7 + VCD waves [email protected] Verilog 0 05-08-2008 06:03 PM
How to generate sine or cosine waves in Verilog HDL mike83 Verilog 1 02-14-2007 10:13 AM
mixing sampled sine waves viswanath VHDL 1 05-12-2004 08:02 AM
Virtual Waves 2.2 by (Synoptic) rlawns DSP 1 09-07-2003 04:51 PM


All times are GMT +1. The time now is 01:14 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved