Sign in

username:

password:



Not a member?

Search compdsp



Search tips

comp.dsp by Keywords

Adaptive Filter | ADPCM | ADSP | ADSP-2181 | Aliasing | AMR | Anti-Aliasing | ARMA | Autocorrelation | AutoCovariance | Beamforming | Bessel | Blackfin | Butterworth | C6713 | CCS | Chebyshev | CIC Filter | Circular Convolution | Code Composer Studio | Comb Filter | Compression | Convolution | Cross Correlation | DCT | Decimation | Deconvolution | Demodulation | DM642 | DSP Boards | DSP/BIOS | DTMF | Echo Cancellation | Equalization | Equalizer | ETSI | EZLITE (Ez-kit Lite) | FFT | FFTW | FIR Filter | Fixed Point | FSK | G.711 | G.723 | G.729 | Gaussian Noise | Goertzel | GPIO | Hilbert Transform | IFFT | IIR Filter | Interpolation | Invariance | JTAG | Kalman | Laplace Transform | Levinson | LPC | McBSP | MIPS | Modulation | MPEG | Multirate | Notch Filter | Nyquist | OFDM | Oversampling | Pink Noise | Pitch | PLL | Polyphase | QAM | QDMA | Quantization | Quantizer | Radar | Random Noise | Reed Solomon | Remez | Resampling | RTDX | Sampling | Sharc | TI C6711 | Undersampling | Viterbi | Wavelets | White Noise | Wiener Filter | Windowing | XDS510PP | Z Transform


Discussion Groups

Free Online Books

See Also

Embedded SystemsFPGAElectronics

Discussion Groups | Comp.DSP | Re: mixing sine waves

There are 10 messages in this thread.

You are currently looking at messages 0 to 10.


Re: mixing sine waves - Me - 2004-05-11 08:51:00

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.
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

mixing sine waves - viswanath - 2004-05-11 15:29:00



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
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: mixing sine waves - Naresh - 2004-05-11 16:07:00

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
> 

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: mixing sine waves - Bhaskar Thiagarajan - 2004-05-11 19:02:00

"viswanath" <d...@eng.usf.edu> wrote in message
news:7...@posting.google.com...
> 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


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: mixing sine waves - Tachyon - 2004-05-12 11:25:00

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 <d...@eng.usf.edu> 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 | s...@gweep.net
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: mixing sine waves - Jerry Avins - 2004-05-12 12:44:00

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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: mixing sine waves - Fred Marshall - 2004-05-12 13:58:00

"viswanath" <d...@eng.usf.edu> wrote in message
news:7...@posting.google.com...
> 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


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: mixing sine waves - Richard Dobson - 2004-05-12 16:14:00

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.
> 
> 
> 

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: mixing sine waves - Tachyon - 2004-05-13 16:07:00

On 2004-05-12, Richard Dobson <r...@blueyonder.co.uk> 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 | s...@gweep.net
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: mixing sine waves - glen herrmannsfeldt - 2004-05-16 04:32:00

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

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.