Jump to content
  • 0

Generating a travelling wave


jfdo

Question

Hi All,

I wonder whether we can generate a travelling wave using Analog Discovery? or crate beats in some wave.

My  intention is to  wave beating with two waves with slightly different frequencies. 

I did a Python animation to show the students of wave beating. But it would be more relevant if I can show with real world experiment with sound waves. 

I appreciate if anyone can shed some light.

I was thinking to set a fixed frequency (say 500Hz) in one channel and sweep the frequency in the other channel around 500Hz (say. 490Hz to 510Hz). Not sure whether this will produce beating and whether one can hear the beat sound (tone).

Thank you.

 Awaiting to hear!

Best Wishes

Fernando

 

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

Hi @jfdo

1. Zoom in the FFT, adjust start and stop. 
2. Leave the default Flat-Top Window, the Kaiser makes wide lobes.
3.a Increase the Time base to have lower frequency resolution in the FFT, to be able the distinguish the peaks.
3.b You can also perform a Record with more samples to have even better FFT resolution, lower noise floor.

image.thumb.png.f81b3c29db7657162730966e269e9bf6.png

image.thumb.png.3a808279685985f0d968d4203972732c.png

Link to comment
Share on other sites

... and for the sake of completeness: one way to calculate the envelope.

This uses a concept called "Hilbert Transform" or "analytical signals". It's probably too far out for an entry level lecture but at least you get pretty plots out of it ?

image.png.d44b355270837e42861cca1a7640d176.png

% Envelope via Hilbert transform
sig4 = sig1+sig2;
% factor 2 because half of the signal magnitude is held (redundantly) in 
% negative frequencies, which will soon go overboard
sig4 = 2*fftshift(fft(sig4)); % to frequency domain
sig4(f_Hz < 0) = 0; % discard negative frequencies
sig4 = ifft(fftshift(sig4)); % back to time domain

figure(); hold on;
plot(t_s, sig1+sig2, 'k');
plot(t_s, abs(sig4), 'b');
legend('original 2-tone sig', 'envelope');

 

Link to comment
Share on other sites

Well it's easy to get lost in the math and specialist "shortcuts" like the idea of amplitude modulation (in a sense that the concept is useful to an electrical engineer who sees through to the bottom but may leave the audience utterly confused if not. Think of a squirrel that only knows how to hop from one tree to the next. It hops and hops and eventually ends where it started and exclaims "wow what a huge forest". But look it up on a map and the 'forest' becomes a tiny little park. The AM concept is like one jump between two specific trees. But, I digress - yes you can formally write it as AM with 100 % modulation index but I don't see how this would help my understanding here, intuitively)

The "envelope" concept is not completely straightforward if you want to close all the gaps - you can show the blur on a scope screen but this visual approach will leave many possible questions unanswered ("how can the envelope be non-zero at zero crossings of the signal?"). I think this requires complex numbers.  My "window" was meant to cheat around that by looking at a short piece of signal (100 ms is already on the long side, make it so short that the "envelope" isn't strongly visible to the eye over the window length) and looking at how large and small magnitude values are distributed - a histogram over abs(sig). This histogram will periodically change with the beat tone, and it is ultimately what the ear responds to.

You might have a look at open-source "Octave" - both for this problem and in general if you're teaching. Python can do probably everything better but I tend to see a trend that it's mostly used by people showing what they "could" do while those who actually "do for a living" stick to Octave (or Matlab) to get the work done. It was obsolete decades ago so there's a pretty good chance that my scripts will still work next month when I need them e.g. no one would break compatibility in the name of security etc. I'm not saying it's perfect but it's been "good enough" for me since, don't know, 1999 or so.

Below a quick example (some details e.g. "minus one" may look weird but they enable an exact result).

First, the two-tone signal: Run the script yourself and you can zoom in as you like etc.

image.png.e08d9fb6648d445035649adeb79943db.png

Then, its spectrum. The magnitude 1/2 comes from Demoivre's expansion cos(x) = 1/2(exp(ix) + exp(-ix)). Lines in the FFT correspond to one exp() so there is always a pair of positive / negative frequency components. The advantage of Octave over test instruments is that you can get exact results (within about 30 orders of magnitude in this example), which are easier to interpret. You can see lines at 150 and 155 Hz and nothing at all at 5 Hz.

image.png.d7205bba11ef6b9abfbe7d496210412d.png

Then, I square the signal, modelling the nonlinearity.

image.png.38187809edbc6f2c6b2147dbd80deeba.png

And here is the result - nothing at 150 / 155 Hz (for simplicity I used an ideal x^2 without any linear term at all). But, double frequency products and, most importantly, the nonlinear product at +/- 5 Hz.

image.png.07063d9994e8df7105af70b67f4b312e.png

 

close all;
nEval = 10000; % number of points to compute
tEval_s = 1; % length of signal in seconds
% calculate time base
t_s = linspace(0, tEval_s, nEval+1)(1:end-1); % avoid duplicate start point (exactly full # cycles)
phi = t_s*2*pi;

% calculate frequency base for FFT
f_Hz = (-nEval/2:(nEval/2-1))/tEval_s;

% two-tone signal
sig1=cos(150*phi); 
sig2=cos(155*phi); 

figure(); hold on;
plot(t_s, sig1+sig2, 'k+-');
xlabel('time/s'); ylabel('s(t)');
title('two-tone signal');
figure(); hold on;
stem(f_Hz, fftshift(abs(fft(sig1+sig2)/nEval)));
title('spectrum two-tone signal');
xlabel('frequency/Hz'); ylabel('magnitude');

% ideal square nonlinearity
sig3 = (sig1 + sig2).^2;

figure(); hold on;
plot(t_s, sig3, 'k+-');
xlabel('time/s'); ylabel('s(t)');
title('two-tone signal squared');
figure(); hold on;
stem(f_Hz, fftshift(abs(fft(sig3)/nEval)))
title('spectrum two-tone signal squared');
xlabel('frequency/Hz'); ylabel('magnitude');

 

Link to comment
Share on other sites

Thank you again. I was stuck in some work and could not write earlier.

Yes, that's correct, it is the 5Hz periodic modulation of the signal amplitude that I have heard.  That means it is not a basic 5Hz sin or cosine.

It is the amplitude modulation of the 155Hz and 150Hz signals. 

In that case can we say  periodicity of the beating is  200ms  (1/5 Hz) and  therefore frequency of the beating is  5Hz?

Frequency of the actual signal  (modulation) is 152.5 Hz. 

In that case can I say it was the 152.5 Hz amplitude modulated signal with 5Hz envelop (5Hz periodicity) that I heard?  Please  see attached.

In that case if I take FFT, shouldn't I expect to see  the frequencies of original signals (150, 155 Hz) , modulated signals (152.5Hz and 2.5Hz ) and the frequency of the envelope (ie. 5Hz)?

Last thing you suggested to do the convolution of modulated signal and 100ms signal? 

Thanks

5Hz_Envelope.png

Link to comment
Share on other sites

yes, it's such a simple experiment but pretty difficult to explain when you really dig into the details...

The 5 Hz is a periodic shift in perception, not a tone itself. For the ear, the amplitude statistics of the signal vary with time, and this is what we hear.

If you define a histogram of the signal magnitude in some short e.g. 100 ms window and slide it along the time axis, you'd see that it changes periodically at 5 Hz. This (again, possibly more "story" than rigid science even though I guess it comes close) modulates the bias point of our nonlinear detector, so to speak.

 

Link to comment
Share on other sites

Hi @ xc6lx45,

Thank you for the detail and nice feedback. 

Yes, sure, I agree that the beat tone we hear due to the interference of the two sounds (tones) at the ear. This is similar to two coherent light pulses (or signals) interfere at some location in space or at the photo-diode or photo detector. 

What I did was, I combined the two signals (150Hz and 155Hz)  from W1 & W2 (wave generator 1 & 2) and fed into an mono audio amplifier. I was able to hear some periodic tone with much higher amplitude (sound intensity). I guess, higher amplitude indicates some sort of  interference of the two sound frequencies. 

The puzzle:

The beat frequency is defined f_beat = | 155 - 150| = 5Hz. 
Technically I should not be able to hear 5Hz sound as our ear is not sensitive to frequencies below 20Hz.
In that case what was to tone/sound I heard when combined the two signals? In that case what was the frequency of the sound I heard?

Mathematically, as you have pointed out,  when I combined the two signals, we can write;
Sin(A) + Sin(B)= 2 Cos[ ( A+B)/2 ] * Sin [ ( A-B)/2 ]

In this case shouldn't we have two frequencies , (150+155)/2 and (155-150)/2 in the FFT spectrum?

(155-150)/2 = 2.5 Hz
(150+155)/2 = 152.5 Hz

So I might have heard the 152.5Hz and not the 2.5Hz! Is that correct?

Shouldn't we able to see these frequencies in the  FFT spectrum?

 

  

Link to comment
Share on other sites

Hi,

you're missing one detail (which is BTW also a critical "piece in the puzzle" in the classroom):

Our ear is only able to perceive the beat because it is nonlinear. If it were a perfectly linear receiver (and an oscilloscope with FFT is pretty close to that), there will be nothing at 5 Hz because the "beat note" does not physically exist (yet). It is created in the ear.

Most likely you will be able to demonstrate that when you put tone 1 on a first small loudspeaker, tone 2 on a second loudspeaker.

Hold them both to one ear => you should hear the beat note

Hold each to its own ear => you should not hear the beat note.

The technical term is "intermodulation" (each tone has a positive and a negative frequency component, and "minus 150 Hz" will modulate "plus 155 Hz" down to "plus 5 Hz" at a nonlinearity.

If you want to show it on electric signals, grab a 1N4148 diode with 50 ohms in series and connect it from the (50 ohms) generator output to ground. This is an electrical nonlinearity similar to what happens in the ear that makes the 5 Hz signal visible when you probe it with an FFT-mode scope.

Classroom hint: The ear spans a dynamic range of 12 orders of magnitude (0 dB hearing threshold to 120 dB damage level is a factor of 1 000 000 000 000 in terms of power or still of 1 000 000 in terms of sound pressure / displacement). It is intuitive that some kind of nonlinearity as mentioned above needs to be involved to compress it so it can be handled by "biological means". I guess this may not be strictly academically correct as an argument, but it's useful to tell a story.

To prove it mathematically without complex numbers, I would use y = x^2 as a prototype nonlinearity and x = cos a + cos b as signal, using cos (u) cos(v) = (cos u-v)/2 + cos(u+v) / 2 from a table of trigonometric identities.

 

Link to comment
Share on other sites

Hi Attila,

Input to the scope channel 1 is the combined outputs (through two 10k resistors) from W1 and W2. is was the same output fed to the home made mono audio amplifier,. I can hear the beat signal. Can not see that in the attached FFT spectrum.

I increased the time base to 6ms/div. I can see the two peaks corresponding to 150Hz AND 155 Hz. But I thought should e able to see the 5Hz frequency line(peak) in the FFT.

Do you think the time/frequency resolution is not enough?

Thanks

FFT_BeatSignal4.jpg

Link to comment
Share on other sites

Thanks. Actually it is a good idea to create using the basic functions than custom. I had two signals with 150 and 155Hz. But still the FFT did not show this. But I calculated the beat frequency by measuring the period of the beat signal in the scope channel 1 (please see the attached) and that provided the answer. But not the FFT? Any idea?

Thanks

FFT_BeatSignal3.jpg

Link to comment
Share on other sites

Many Thanks Attila.

I tried with two 5 kOhms  resistors to combine the two signals from the W1 and W2 (wave generators of Analog Discovery) and fed into my home made  audio amplifier (LM386). 

It worked well producing the beat note. The Audio output from Analog Discovery  was fed into the external audio amplifier.

I used two custom made signals using the following equations

W1 sin(2*PI*30*X)

W2: sin(2*PI*31*X)

X was set to 0 to 1. 

And the Frequency was set to 5Hz.

In this way should the frequency of W1, f1= 150Hz signal and frequency of W2, f2=155Hz? Therefore the beat frequency is f2-f1 = 5Hz?

To see the beat frequency, fed the combined signal to Scope channel 1 and selected FFT. But could not see the beat frequency in the FFT window.

I have attached the print screen of the scope. Please let me know whether my settings are correct!

ThankFFT_BeatSignal2.thumb.jpg.7ec212ae996dc249ad67d2f93931686d.jpgs.

Link to comment
Share on other sites

Hi @jfdo

I would suggest to try which resistor or capacitor offers best results or you can try even directly connecting it.
You should use ceramic/non-polarized capacitor or use Wavegen offset for electrolytic/polarized capacitor. These probably won't blow up at such low power but it could be damaged by reverse polarity.

Link to comment
Share on other sites

Thank you Attila. So I can use either two 5kOhms resistors in series with w1 and w2 or  two 1uF capacitor? Does the capacitor needs to be electrolytic (with +/- terminals)?

thanks again.

Link to comment
Share on other sites

Hi @jfdo

In this respect AD1 is identical to AD2:
https://reference.digilentinc.com/reference/instrumentation/analog-discovery-2/reference-manual#audio
https://reference.digilentinc.com/reference/instrumentation/analog-discovery/reference-manual#audio

You can use the AC coupled stereo audio outputs or Wavegen outputs, with nF-uF ceramic capacitor or 10-10k Ohms resistor, depending on the speaker...
Or you can use two speakers to have the beating in audio wave rather than electric...

Link to comment
Share on other sites

Thank you Attila for the suggestion. 

Yes, that's right I can generate the FM signal and 500Hz signals using Analog Discovery. I have the Analog Discovery.
To generate the beat we need to combine the two signals from wave Generator 1 and 2, isn't it? Can I just combine the two outputs from W1 and W2 or do I need any resistors (as I have indicated in the attached schematic?) or impedance matching circuit or any proactive circuit to protect the Analog Discovery? If so what would be the best circuit that I should use?

Any suggestions or practical circuits you may know?

By the way what is the output power of the Analog Discovery (older version) headphone output?

Thank you.

2001421287_BeatSignal.thumb.jpg.b8a3e16188a0b30e2030415f67b64231.jpg

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...