Samstag, 31. Juli 2010

EE5410 Signal Processing

EE 5410 Signal Processing
MATLAB Exercise 1
Telephone Touch-Tone Signal Encoding and Decoding
Intended Learning Outcomes:
On completion of this MATLAB laboratory exercise, you should be able to
􀂃
Generate and decode telephone touch-tone signals
􀂃
Understand the impact of additive noise in decoding touch-tone signals
Grouping and Schedule:
􀂃
One student per group
􀂃
Each student is required to submit a hardcopy answer sheet which contains answers to the questions in this manual on or before 28 June 2010.

Background:

Telephone touch-tone pads generate dual tone multiple frequency (DTMF) signals to dial a telephone. When any key is pressed, the sinusoids of the corresponding row and column frequencies, which are depicted in Figure 1, are generated and summed to give dual tone. As an example pressing the “5” key generates a signal containing the sum of the two tones at 770 Hz and 1336 Hz together, and mathematically, it can be generated as
)13362cos()7702cos()(tttx⋅π+⋅π=

In fact, the frequencies in Figure 1 are chosen to avoid harmonics. No frequency is an integral multiple of another, the difference between any two frequencies does not equal any of the frequencies, and the sum of any two frequencies does not equal any of the frequencies.

This makes it easier to detect exactly which tones are present in the dialled signal in the presence of non-linear line distortion.
Frequencies (Hz)
1209
1336
1477
697
“1”
“2”
“3”
770
“4”
“5”
“6”
852
“7”
“8”
“9”
941
“*”
“0”
“#”
Figure 1: DTMF encoding for touch-tone dialling

Decoding of DTMF signals can be achieved via using a simple finite impulse response (FIR) filter bank which is shown in Figure 2. The filter bank consists of 7 band-pass filters (BPFs) where each filter passes only one of the 7 possible DTMF frequencies.

When the input to the filter bank is a DTMF signal, the outputs from two of the BPFs should be larger than the rest. If we detect the two largest outputs, the two corresponding frequencies can be found. These frequencies are then used as row and column pointers to determine the key from the DTMF code. A good measure of the output levels can be the peak value at the filter outputs, because when the BPF is working properly it should pass only one sinusoidal signal and the peak value would be the amplitude of the sinusoid passed by the filter. ][nx
Procedure:
1. C
reate a file named “tones.m” with the following MATLAB code:
clear all;
fs = 4000;
Ts = 1/fs;
t = [0:Ts:2];
f1 = 400;
f2 = 600;
x=[cos(2*pi*f1*t), cos(2*pi*f2*t)];
soundsc(x,fs);
Type tones at the command line.
(a) What is the duration of the signal?
(b) What do you hear?
2.
Create a file named “tones2.m” with the following MATLAB code:
clear all;
x=[];
fs = 4000;
Ts = 1/fs;
t = [0:Ts:0.0205];
f = 400;
for i=1:100
x=[x,cos(2*pi*f*t)];
end
soundsc(x,fs)
2
and another file named “tones3.m” with the following MATLAB code:
clear all;
fs = 4000;
Ts = 1/fs;
t = [0:Ts:2.05];
f = 400;
x=cos(2*pi*f*t);
soundsc(x,fs)
Run the two MATLAB programs.
(a) State one difference between the two signals.
(b) Explain the difference.
3. C
reate a file named “tone.m” with the following MATLAB code:
function x = tone(frequency, observation_length);
% x=tone(frequency, observation_length) is used to generate
% a sinusoidal signal x with frequency and observation
% length specified in the arguments.
fs = 4000;
Ts = 1/fs;
t = [0:Ts:observation_length];
x = cos(2*pi*frequency*t);
Note that tone is a user-defined MATLAB function. Try the following commands: help tone, x=tone(100,0.1) and y=tone(1000,0.01). Describe the usage for each of the three commands.
4. W
rite a MATLAB function named dtmfdial.m, to implement a DTMF dialer based on the frequency table in Figure 1. A skeleton of dtmfdial.m is given as follows:
function xx=dtmfdial(keyName)
%DTMFDIAL Create a DTMF tone
%usage: xx=dtmfdial(keyName)
% keyName = character which is one of the valid key names
% xx = signal vector that corresponds to the DTMF
dtmf.keys = ['1','2','3';
'4','5','6';
'7','8','9';
'*','0','#'];
ff_cols = [1209,1336,1477];
ff_rows = [697;770;852;941];
dtmf.colTones = ones(4,1)*ff_cols;
dtmf.rowTones = ff_rows*ones(1,4);
Complete dtmfdial.m so that it implements the following:
(i)
The input to the function is one of the valid key names.
3
(ii)
The output should be a vector of samples at sampling frequency 8000 Hz containing the DTMF tone. Each DTMF signal is the sum of a pair of unity amplitude sinusoidal signals and the time duration is 0.2s.
=sf
(iii)
The frequency information is given in two 34× matrices, namely, dtmf.colTones and dtmf.rowTones. To translate a key into the correct locations of the two matrices, the find function can be used. An example of using find is:
[ii,jj] = find(‘3’==dtmf.keys)
(iv)
Play the sound of the DTMF tone using soundsc.
5. O
ne simple way to implement a band-pass FIR filter is to use the following impulse response: LnnLnh<≤ω=01),cos(][
where ω is the center frequency of the band-pass filter and L is the filter length. Use MATLAB to generate a band-pass filter with π=ω2.0.
(a)
Try the cases of 50=L and 500=L. Plot the magnitudes of the frequency spectra of the two filters using freqz. An example of using freqz is:
[a,b] = freqz(h); %h is the impulse response
plot(b,abs(a));
(b)
Compute the energies of ][nh for 50=L and 500=L. The energy of is defined as
][nh210][nhELnhΣ=−=
(c)
Which filter will give a better DTMF decoding performance, ][nh with 50=L or 500=L? Explain your answer.
Note that in general, the impulse response for this simple band-pass FIR filter is LnfnfLnhsb<≤⎟⎟⎠⎞⎜⎜⎝⎛π=021,cos][
where is the center frequency of the filter and is the sampling frequency, both in Hz. bfsf
6. W
rite a MATLAB function named dtmfdetect.m, to implement a DTMF encoder and decoder in a noisy environment. The requirements of the dtmfdetect function are given as follows:
(i)
The input to the function consists of one of the valid key names, filter length of the band-pass filters and noise power. That is, dtmfdetect(‘1’,50,1) will generate a DTMF tone ‘1’ with 50=L and the tone is corrupted by a zero-mean white Gaussian noise with power of
4

1. The output will show the result of the detection, namely, displaying a message of The detected key is 1.
(ii)
Each DTMF signal is the sum of a pair of unity amplitude sinusoidal signals and the time duration is 0.2s with sampling frequency 8000=.
sf

(iii)
To add a zero-mean white Gaussian noise to the noise-free DTMF tone, you can use the randn command. An example of using randn is:
noise = sqrt(0.1)*randn(1,10);
where a zero-mean Gaussian noise sequence of length 10 with power of will be generated. 102.=σ

(iv)
To detect the DTMF tone frequencies, you first need to pass the signal to a filter bank of 7 band-pass filters whose center frequencies are 697 Hz, 770 Hz, 852 Hz, 941 Hz, 1209 Hz, 1336 Hz and 1477 Hz. The DTMF tone can then be deduced from the two outputs with the largest energy. An example of producing the output signal given the input and FIR filter coefficients is
y=conv(x,h); % x is the input and h is the filter
% impulse response
An example of computing the energy of a signal is
energy = sum(y.*y);
(a)
Try your dtmfdetect function with various keys, different L (50=L and 500=L) and noise powers (02=σ, 12=σ and 502=σ). For each key, perform 10 trials and record the number of correct detection with the following table.
Key
50=L02=σ
500=L02=σ
50=L12=σ
500=L12=σ
50=L502=σ
500=L502=σ
1
2
3
4
5
6
7
8
9
0
*
#
(b)
Can your dtmfdetect function detect the DTMF tone accurately for all cases? Why?
5

8 Kommentare:

Anonym hat gesagt…

香港 8月1日撐粵語遊行

http://www.youtube.com/watch?v=SKGZWDyD3aA&feature=youtube_gdata


倪匡 : 佩服廣州市民挺身捍衞自己語言
http://hk.apple.nextmedia.com/template/apple/art_main.php?iss_id=20100727&sec_id=4104&subsec_id=11867&art_id=14281639

====

開卷看世界﹕快樂抗爭的靈感來源 ——弗雷勒的解放教育法

學問要用在身上,才是學問,否則只是消閒。消閒也很好,不過遇上渾濁時代,正氣不張,又容不得人偷安。寫舊書的書話,重看舊藏書,有些毫無留下閱讀痕迹的,倒是懷疑當年自己曾否讀過,例如弗雷勒(Paulo Freire,1921-1997)的《被壓迫者的教育法》(Pedagogy of the Oppressed)。快樂抗爭的一些靈感,除了來自社運同道的談話和宗教哲學之外,也源自此書。

閱讀藏書,認定源頭

此書是教英文寫作的老師Louis Crew 博士臨別香港所贈,連帶一大堆其他詩集、小說和社運書,許多看後我都轉贈其他學生了,只留下幾本。

弗雷勒的是其中之一,現在看看,原來是一九七○ 年的英文初版,翻譯自作者的葡萄牙 文手稿(一九六八年)。

弗雷勒原是巴西 教育家,負責甘蔗工人的識字教育,政變之後一度流亡智利,復定居美國,為貧困階層探索教育方法學。此書是社運的奠基之作。

前幾日重看,我才肯定,一九八六年讀過此書,當時是連住幾本黑人社運書一氣讀的,故記不清楚。書上留有老師的勾劃和筆記,珍而重之,便不自加橫批了。

弗雷勒的論述,如一些南美的思想家著作一樣,章法凌亂,喜歡用激情的對比排句和模糊的馬克思主義術語,需要理性的整理。

也許我當年心內整理過,因此忘卻了原著,有點忘恩負義了。

自壓迫之中解放出來

壓迫是什麼?壓迫就是將人變成物,不將人當作人來看待。只有當權者是人,當權者不能愛別人,只能愛自己,其餘的人都是物,可以隨便支配、勒詐和虐殺的物。

反抗壓迫,不是要將關係倒轉過來,將奴隸變成主人,而是要反省奴役,取消奴役,取消壓迫人的奴役關係,將當權者也一併從壓迫的不愉快的關係之中解放出來,大家享受平等和自由的快樂人生。

主子虐打奴隸,一樣是面容扭曲的,從虐待狂之中,得不到快樂。壓迫人的當權者,活在惶恐不安之中,用侍衛困鎖自己,毫不輕鬆。

魯迅先生講過,「 沉默呵,沉默呵!不在沉默中爆發,就在沉默中滅亡。 」

在壓迫之下沉默,是受壓迫者的特色。當權者壓迫窮人,少數人壓迫多數人,靠的是灌輸意識形態,使得窮人認命而沉默無言,不再反抗。政治解放,要由意識解放和文化分析開始,不是從武力抗爭開始。

由武力抗爭開始,只會令窮人更加絕望﹕比起當權者,自己的武備貧乏得可憐,必須鼓吹超出理性的仇恨,採取更為滅絕人性的超限戰爭(如恐怖襲擊 ),犧牲許多同道,惹來當權者更為合理的鎮壓,而無數的武力革命先輩,

最後演變成殘酷暴政的例子又太多了,怎不令人沮喪而沉默,即使智者也變得犬儒起來?

恢復人性,便是解放

壓迫的方法是去除人性,待人如物,革命就首先要人認識人性,待己如人,待人如人,重獲自己的自由、責任和愛心,活在真實之中。

社運中的民眾教育,不能用壓迫的灌輸教學法,要平等相待,尊重民眾的生活體驗和民間知識,彼此維繫對話,一同尋找問題的解決方法。

民眾不是革命的螺絲釘,而是有真性情和各種缺陷和癖好的人。當民眾簡化為螺絲釘、兌換成可以交易的籌碼,只是奪權,改換當權者,而不是革命。

革命的過程,是要以對話來啟發民眾成為自由探索真相的人,彼此締結,組織起來,抵抗當權者的分化和離間。

民眾的訴求,如爭取加薪、爭取住所之類,要尊重,但要綜合其他的訴求,令民眾認識到他們階段性的個別爭取,可以連結到整體社會的解放。

要民眾理解到什麼是整體解放,就要用文化藝術來聯繫不同的生活領域,擴大他們的同理心。

最終的革命,不是奪權,而是文化的更新﹕以對話取代灌輸,以合作取代奴役,以愛取代恨。

Anonym hat gesagt…

抗河蟹大聯盟(Anti “False Harmony” Alliance)是由一群社福界同工、大澳居民組織、服務使用者、社工學生和學者組成的網絡。

http://nofalseharmony.org/?p=782

Anonym hat gesagt…

抗河蟹大聯盟(Anti “False Harmony” Alliance)是由一群社福界同工、大澳居民組織、服務使用者、社工學生和學者組成的網絡。

http://nofalseharmony.org/?p=782

Anonym hat gesagt…

Defending Cantonese dialect and identity in Hong Kong

http://www.youtube.com/watch?v=QNsNyxyN7yg

Anonym hat gesagt…

問陳雲怎為之好的評論文章?他說:「 能帶到一些新見解,另外要有社會公義,啟發民智。」

今年 (2010 )年初,他就社運人士被告襲警寫出的《 如何毀滅一隊警隊》堪稱經典,他寫到:「 毀滅一隊警察,不須人民起義,不須槍炮刀劍,只須政府以不義之名,唆使警察陷害忠良,警察就濫權營私,不成為警察,而成為家僕與鬼卒了。」

文章被瘋狂轉載,有前警員馬上撰文回應,黃毓民更拿此文章,在立法會質問李少光,「 但李少光也不敢說我錯,他只是說文章偏激,哈哈。這文章其實幫了政府,我想警方不會再用嚴厲法例控告社運人士了,他們不敢了。」

但另一方面,他又擔心市民因為讀評論出了氣,疏導了民怨:「評論文章幫助政府恢復理性,但壓抑了社會鬥爭活動。因此我不想再寫政論,政論其實會削弱社會鬥爭,有時這是反進步的,因為評論理性,會令大家都沉溺在分析中,但真正的鬥爭動力只源於人們的非理性、衝動,評論就阻止這衝動了。」

你寧願社會谷到爆?「 對,所有文明都是源於此的。」但有人谷到爆就會去幼椎園殺小朋友,「他們殺完小朋友就會殺警察了,嘿嘿。」

我不服,評論不是有教化作用嗎?「 本來是可以的,如果社會裏有反對黨、商界聽了會改,這是有作用的。有時,評論也能取代社會運動。」陳雲決絕的說,今後他也不寫政論了,「因為我知道沒有用,我情願看它谷爆。」

Anonym hat gesagt…

atou, do you remember the voice we heard on the boat that night?

Before those words we heard come these ones: "When I WAS a child, I SPOKE as a child. I UNDERSTOOD as a child, I THOUGHT as a child. But when I became a man, I put away childish things."

Here before you is neither the program called the Puppet Master nor the woman that was called the Major.

http://strivinglife.com/words/?tag=/ghost-in-the-shell

http://www.youtube.com/watch?v=5jyRtdVbLpg&feature=player_embedded
陳雲 : 港財閥, 請「地獄式捐獻」 !


香港經典三級片60部,你又看過幾部?
http://forum2.hkgolden.com/view.aspx?type=CA&message=2633671

Anonym hat gesagt…

YOU ARE RIGHT.

哀陳雲被河蟹, 超渡地產商殺靈業障,-- 陳雲: 港財閥, 請「地獄式捐獻」 !
http://www.youtube.com/watch?v=5jyRtdVbLpg&feature=player_embedded


《吶喊》第五集: 轉念,始於足下寸土 @3:10 陳雲批評地產商
http://www.youtube.com/watch?v=zhg8Kdpkqm0&feature=related

Anonym hat gesagt…

on9仔, 去慢慢賴你個共產黨屎忽啦 ! !

Congratulations for China: Nobel Peace Prize 2010
http://www.youtube.com/watch?v=_NvUbjhx-uY&feature=player_embedded