+ All Categories
Home > Documents > DTMF Encoder Decoder Design Using FIR Banks

DTMF Encoder Decoder Design Using FIR Banks

Date post: 07-Apr-2015
Category:
Upload: dhruba88
View: 332 times
Download: 1 times
Share this document with a friend
11
DTMF Coder / Decoder Design using FIR Banks by S.Sircar Introduction Analog DTMF telephone signaling is based on encoding standard telephone Keypad digits and symbols in two audible sinusoidal signals of frequencies FL and FH. Thus the scheme gets its name as dual tone multi frequency (DTMF). Hz 1209 1336 1477 1633 697 1 2 3 A 770 4 5 6 B 852 7 8 9 C 941 * 0 # D Figure 1 Each digit or symbol represented in figure 1 has 2 distinct high and low frequency components. Thus each high-low frequency pair uniquely identifies the corresponding telephone keypad digit or symbol. Each key pressed can be represented as a discrete time signal of form Where N is defined as number of samples taken. Typically in the sampling frequency used is 8khz. Thus if the two individual frequency components of the signal can be identified then the number dialed can be decoded. Note :- In this report I have used (dual tone and digit/symbols) interchangeably but both mean the same. Dual tone means the encoded samples of the corresponding DTMF digits/symbols. Implementation of DTMF Encoder The DTMF encoder is implemented in MATLAB function dtmfe.m. The implementation is based on a digital oscillator, that will generate sinusoidal tones at frequencies F o in response to an input signal x[n] = δ[n]. x[n] H[n] y[n] {y[n] = x[n]*H[n] d t [n] = sin[ω L n] + sin[ω L n] , 0 n N-1 (1) Consider a causal filter with y(n) - 2*cos(2*pi * f *Ts)y(n-1) + y(n-2) =0*x(n) sin(f)x(n-1) + 0*x(n-2). The impulse response of this system tells us that this indeed is a digital oscillator. 1
Transcript
Page 1: DTMF Encoder Decoder Design Using FIR Banks

DDTTMMFF CCooddeerr // DDeeccooddeerr DDeessiiggnn uussiinngg FFIIRR BBaannkkss

bbyy SS..SSiirrccaarr IInnttrroodduuccttiioonn Analog DTMF telephone signaling is based on encoding standard telephone Keypad digits and symbols in two audible sinusoidal signals of frequencies FL and FH. Thus the scheme gets its name as dual tone multi frequency (DTMF).

Hz 1209 1336 1477 1633 697 1 2 3 A 770 4 5 6 B 852 7 8 9 C 941 * 0 # D

Figure 1

Each digit or symbol represented in figure 1 has 2 distinct high and low frequency components. Thus each high-low frequency pair uniquely identifies the corresponding telephone keypad digit or symbol. Each key pressed can be represented as a discrete time signal of form

Where N is defined as number of samples taken. Typically in the sampling frequency used is 8khz. Thus if the two individual frequency components of the signal can be identified then the number dialed can be decoded. NNoottee ::-- In this report I have used (dual tone and digit/symbols) interchangeably but both mean the same. Dual tone means the encoded samples of the corresponding DTMF digits/symbols. IImmpplleemmeennttaattiioonn ooff DDTTMMFF EEnnccooddeerr The DTMF encoder is implemented in MATLAB function dtmfe.m. The implementation is based on a digital oscillator, that will generate sinusoidal tones at frequencies Fo in response to an input signal x[n] = δ[n].

x[n] H[n] y[n] {y[n] = x[n]*H[n]

dt[n] = sin[ωLn] + sin[ωLn] , 0 ≤ n ≤ N-1 (1)

Consider a causal filter with y(n) - 2*cos(2*pi * f *Ts)y(n-1) + y(n-2) =0*x(n) sin(f)x(n-1) + 0*x(n-2). The impulse response of this system tells us that this indeed is a digital oscillator.

1

Page 2: DTMF Encoder Decoder Design Using FIR Banks

The H[n] is plotted and is sinusoidal and hence any input to this system will oscillate as governed by the system function. The impulse response of the system is shown in the figure above. This is generated by using the MATLAB dimpulse() function for 100 points. The encoder is coded so that it inserts silence samples in between each digits/symbols so that they are separated from each other. Starting position = (total number of digits be encoded-1)*(length of each dual tone + number of silence samples to be inserted) + 1. This information is used at the decoding step to get each dual tone sample length and how many samples to skip for the next digit/symbol. The resulting waveform after encoding is shown in figure 2 below. The waveform shows an encoded sequence of my phone number 7262527. There are 7 digits in the dialed string and hence the waveform shows 7 distinct sub samples of the resulting DTMF encoded waveform.

2

Page 3: DTMF Encoder Decoder Design Using FIR Banks

The frequency spectrum is shown in the figure below of the dialed dtmf digits. The plot shows both sided frequency spectrum and is simply a mirror of the base band.

IImmpplleemmeennttaattiioonn ooff DDTTMMFF ddeeccooddeerr The input to the decoder is a vector containing DTMF tones that are encoded by the encoder. A FIR (Finite Impulse Response) band pass filter is implemented which is centered at the frequencies of interest for decoding each key pressed. The decoding process takes place in iterative form. Starting from row 1 to row 4,in each iteration a FIR band pass filter centered at each FH is implemented and the signal strength around the band is compared against a threshold. If the mean amplitude of the filter output is more than a set threshold, the frequency component tested is considered to be strong. To prevent cancellation of the sinusoids while calculating the mean, the values are squared. Similar approach is taken in order to find the FL present in the signal. Once a row-column pair has been detected the digit encoded is uniquely identified. This approach has been taken in order to suppress the effects of noise in the encoded signal. This approach has a significant advantage that is the band pass filter coefficients can be manipulated individually to produce a narrower filter and detection process can be enhanced in presence of noise.

3

Eragon
Underline
Page 4: DTMF Encoder Decoder Design Using FIR Banks

In order to decode a string of dialed symbols/digits the decoding step assumes that the encoder has inserted silence between each dual tone. Each dual tone length is tracked and silence lengths are calculated. The decoding step loops over for the number of digits to be decoded that is easily calculated from the total length of the signal divided by the sum of individual dual tone length and silence length. Thus after decoding the first digit certain number of samples are skipped and the next set of samples are decoded. This means sampling and decoding a small part of the resulting waveform in each iteration, where one iteration relates to one key pressed. CCoonncclluussiioonn No attempt has been made to test the system performance in a noisy environment. However, since I have used a band pass filter in order to decode every DTMF tone the band pass filter length can be manipulated in order to get good results in noisy environment. A filter of length L (L=128 currently used) can be used to increase the immunity of noise (type of noise). However a higher value of L would detect tones even of lower amplitude better, but also increases the chance of error in detection. This matched filter approach definitely reduces the mean square error between two bands of detection. The system has been tested and works according to specification in a noise free environment. AAnnaallyyssiiss RReessuullttss Consider Detecting digit 4 of DTMF which comprise of Fl = 770, Fh = 1209. Filter coefficients and frequency response of 770 hz center frequency band pass FIR filter.

4

Page 5: DTMF Encoder Decoder Design Using FIR Banks

Frequency response of the 770 hz band pass filter is shown in the plot below.

Filter coefficients and frequency response of 1209 hz center frequency band pass FIR filter.

5

Page 6: DTMF Encoder Decoder Design Using FIR Banks

Frequency response of the 770 hz band pass filter is shown in the plot below. Suppose the frequency we are looking for is 770hz and 1209 hz in order to detect dialed digit 4. The decoding takes place by implementing a band pass filter at every iteration step looking for a particular Fl and Fh. The decoded digit in the following diagram is 4. Take a look at how 770hz and 1209 hz are allowed to pass from the band pass filter.

6

Page 7: DTMF Encoder Decoder Design Using FIR Banks

Source Code for DTMF Encoder/Decoder Source Code for DTMF Encoder/Decoder gglloobbaall ddttmmff__rrffrreeqq gglloobbaall ddttmmff__ccffrreeqq gglloobbaall ddttmmff__kkeeyy gglloobbaall ddttmmff__ffss gglloobbaall ddttmmff__ssiilleenncceelleenn gglloobbaall ddttmmff__ttoonneelleenn %% EExxeeccuuttee tthhiiss SSccrriipptt aatt tthhee bbeeggiinniinngg ooff eennccooddiinngg aanndd ddeeccooddiinngg %% TThhiiss ssccrriipptt sseettss aallll tthhee gglloobbaall ppaarraammnneetteerr ffoorr eennccooddiinngg aanndd ddeeccooddiinngg %% DDeeffiinnee tthhee ffrreeqquueenncciieess uusseedd iinn ssyynntthheessiizziinngg aanndd ddeeccooddiinngg tthhee DDTTMMFF ssiiggnnaall %% EEaacchh ffrreeqquueennccyy ccoorrrreessppoonnddss ttoo aa rrooww oorr ccoolluummnn ooff kkeeyyss oonn tthhee kkeeyyppaadd,, %% eegg.. pprreessssiinngg ''44'' mmeeaannss tthhaatt tthhee ffrreeqquueenncciieess ffoorr rrooww 22 aanndd ccoolluummnn 11 sshhoouulldd %% bbee uusseedd.. TThhee rreessuullttiinngg DDTTMMFF ttoonnee iiss tthhee ttwwoo wwaavveeffoorrmmss ssuummmmeedd ttooggeetthheerr ddttmmff__rrffrreeqq == [[ 669977 777700 885522 994411]];; %% ffrreeqquueennccyy ccoommppoonneennttss ffoorr eeaacchh rrooww ddttmmff__ccffrreeqq == [[11220099 11333366 11447777 11663333]];; %% ffrreeqquueennccyy ccoommppoonneennttss ffoorr eeaacchh ccoolluummnn ddttmmff__kkeeyy == [[ ''11'' ''22'' ''33'' ''AA'';; ''44'' ''55'' ''66'' ''BB'';; ''77'' ''88'' ''99'' ''CC'';; ''**'' ''00'' ''##'' ''DD'']];; %% SSaammpplliinngg FFrreeqquueennccyy ddttmmff__ffss == 88000000;; ddiisspp(([[''DDTTMMFF ssaammpplleerraattee sseett ttoo '' nnuumm22ssttrr((ddttmmff__ffss)) '' HHzz'']]));; %%DDuurraattiioonn ooff tthhee TToonnee ttoo ggeenneerraattee ddttmmff__ttoonneelleenn == rroouunndd((ddttmmff__ffss ** 00..5500));; %% CCoonnvveerrtt lleennggtthh ffrroomm sseeccoonnddss ttoo ssaammpplleess ddiisspp(([[''DDTTMMFF ttoonnee lleennggtthh sseett ttoo '' nnuumm22ssttrr((ddttmmff__ttoonneelleenn)) '' ssaammpplleess'']]));; %%IInnsseerrtt SSiilleennccee lleennggtthhss bbeettwweeeenn ttoonneess ffoorr ddeetteeccttiioonn ddttmmff__ssiilleenncceelleenn == rroouunndd((ddttmmff__ffss ** 00..2200));; %% CCoonnvveerrtt lleennggtthh ffrroomm sseeccoonnddss ttoo ssaammpplleess ddiisspp(([[''DDTTMMFF bbrreeaakk lleennggtthh sseett ttoo '' nnuumm22ssttrr((ddttmmff__ssiilleenncceelleenn)) '' ssaammpplleess'']]));;

Code for Digital Oscillator to generate the sinusoids Code for Digital Oscillator to generate the sinusoids %% GGeenneerraatteess aa ssiinnoossooiiddaall oouuttppuutt aatt aa ssppeecciiffiieedd ffrreeqquueennccyy %% TThhiiss iiss ggeenneerraatteedd bbyy iimmpplleemmeennttiinngg aa ddiiggiittaall oosscciillllaattoorr uussiinngg tthhee ffoolllloowwiinngg ddiiffffeerreennccee eeqquuaattiioonn %% yy((nn)) -- 22**ccooss((22**ppii ** ff **TTss))yy((nn--11)) ++ yy((nn--22)) ==00**xx((nn)) ssiinn((ff))xx((nn--11)) ++ 00**xx((nn--22)) %% TThhee ffoolllloowwiinngg ccoo--eeffffiicciieenntt aarree aass ffoolllloowwss %% AA == [[11 --22**ccooss((22**ppii ** ff **TTss)) 11]];; %% BB == [[00 ssiinn((22**ppii ** ff **TTss)) 00 ]];; %% %% SShhiillaaddiittyyaa SSiirrccaarr 22000022 %% DDSSPP CCoouurrssee PPrroojjeecctt %% %% UUssaaggee --:: %% nn -- mmuusstt bbee aa vveeccttoorr %% TTss == 11//ddttmmff__ffss;; %% nn == 00::ddttmmff__ttoonneelleenn--11;; %% ff == ssoommee ffrreeqquueennccyy ffoorr tthhee ttoonnee ttoo bbee ggeenneerraatteedd %% YY == ggeennssiinnoo((ff,,nn,,TTss));; ffuunnccttiioonn YY == ggeennssiinnoo((ff,,nn,,TTss)) XX == zzeerrooss((11,,lleennggtthh((nn))));;XX((11)) == 11;; %% ggeenneerraattee tthhee iimmppuullsseess AA == [[11 --22**ccooss((22**ppii ** ff **TTss)) 11]];; BB == [[00 ssiinn((22**ppii ** ff **TTss)) 00 ]];; YY == ffiilltteerr((BB,,AA,,XX));;

7

Page 8: DTMF Encoder Decoder Design Using FIR Banks

Code for DTMF Encoder Code for DTMF Encoder ffuunnccttiioonn eennccooddeeddTToonneess == ddttmmffee((nnuumm)) %% TThhiiss ffuunnccttiioonn ttrraannssllaatteess kkeeyy pprreesssseedd iinn ddiiggiittaall tteelleepphhoonnee kkeeyyppaadd ttoo ccoorrrreessppoonnddiinngg %% dduuaall ttoonnee ffrreeqquueenncciieess %% EExxaammppllee eennccooddeeddTToonneess == ddttmmffee((''55667700553311'')) %% 556677003311 iiss ssttrriinngg ooff nnuummbbeerrss pprreesssseedd.. TThhee ffuunnccttiioonn ccoonnvveerrttss tthheemm ttoo tthheeiirr %% ccoorrrreessppoonnddiinngg dduuaall ttoonneess aass ppeerr ddeeffiinneedd iinn ddttmmff mmaaiinn ((FFHH,,FFLL)) %% %% SShhiillaaddiittyyaa SSiirrccaarr 22000022 %% DDSSPP CCoouurrssee PPrroojjeecctt %%BBrriinngg tthhee gglloobbaall vvaarriiaabblleess ddeeffiinneedd iinn ddttmmffmmaaiinn ttoo tthhee ssccooppee ooff tthhiiss ffuunnccttiioonn gglloobbaall ddttmmff__rrffrreeqq gglloobbaall ddttmmff__ccffrreeqq gglloobbaall ddttmmff__kkeeyy gglloobbaall ddttmmff__ffss gglloobbaall ddttmmff__ssiilleenncceelleenn gglloobbaall ddttmmff__ttoonneelleenn %% CCaann uussee tthhee sseettppaarraammeetteerr ffuunnccttiioonn iinn oorrddeerr ttoo jjuusstt eevvaalluuaattee tthhiiss ffuunnccttiioonn %% ttoo ddoo tthhiiss jjuusstt uunn--ccoommmmeenntt tthhee sseettppaarraammeetteerr.. TThhiiss ssccrriipptt wwiillll sseett uupp tthhee gglloobbaall %%vvaarriiaabbllee rreeqquuiirreedd ttoo eexxeeccuuttee ddttmmff eennccooddiinngg.. %%sseettppaarraammeetteerr;; nnuumm == sspprriinnttff((''%%ss'',,nnuumm));; TTss == 11//ddttmmff__ffss;; %% SSaammppllee lleennggtthh nn == 00::ddttmmff__ttoonneelleenn--11;; %% VVeeccttoorr ttoo ssaammppllee ffrroomm 00 << nn <<==NN--11 %%TToottaall NNuummbbeerr ooff EElleemmeennttss rreeqquuiirreedd iinn tthhee eeccooddeedd vveeccttoorr ssppaaccee nnuummccoouunntt == lleennggtthh((nnuumm));; ttlleenn == nnuummccoouunntt**((ddttmmff__ttoonneelleenn ++ ddttmmff__ssiilleenncceelleenn));; %%GGeenneerraattee tthhee vveeccttoorr ffiirrsstt tthhaatt ccoonnttaaiinnss tthhee ttoonneess eennccooddeeddTToonneess == zzeerrooss((11,,ttlleenn));; %% lloooopp tthhrroouugghh tthhee iinnddiivviidduuaall kkeeyyss iinn tthhee iinnppuutt vveeccttoorr ffoorr ii == 11::nnuummccoouunntt %% FFiinndd oouutt wwhhiicchh ccoolluummnn aanndd rrooww tthhiiss kkeeyy bbeelloonnggss ttoo [[rrooww,,ccooll]] == ffiinndd(( ddttmmff__kkeeyy ==== uuppppeerr((nnuumm((ii))))));; iiff (( iisseemmppttyy((rrooww)) )) ddiisspp((''OOnnee ooff tthhee KKeeyy PPrreesssseedd iiss nnoott aa vvaalliidd DDTTMMFF KKeeyy''));; eenndd %% ccaallccuullaattee tthhee ssttaarrtt aanndd eenndd ppoossiittiioonn ooff tthhee ccuurrrreenntt ttoonnee ssttaarrttppooss == ((ii--11))**((ddttmmff__ttoonneelleenn ++ ddttmmff__ssiilleenncceelleenn)) ++ 11;; eennddppooss == ssttaarrttppooss ++ ddttmmff__ttoonneelleenn -- 11;; eennccooddeeddTToonneess((ssttaarrttppooss::eennddppooss)) == ggeennssiinnoo((ddttmmff__ccffrreeqq((ccooll)) ,, nn ,, TTss )) ++ ggeennssiinnoo((ddttmmff__rrffrreeqq((rrooww)) ,, nn ,, TTss ));; eenndd

8

Page 9: DTMF Encoder Decoder Design Using FIR Banks

Code for DTMF Decoder Code for DTMF Decoder ffuunnccttiioonn ddiiggiittssttrr == ddttmmffdd((eennccssttrr)) %% TThhiiss ffuunnccttiioonn ttrraannssllaatteess tthhee eennccooddeedd ttoonneess ttoo ccoorrrreessppoonnddiinngg %% kkeeyyss//kkeeyy tthhaatt aarree pprreesssseedd.. %% EExxaammppllee ddiiggiittssttrr == ddttmmffdd((vveecc)) %% WWhheerree vveecc iiss tthhee vveeccttoorr tthhaatt ccoonnttaaiinnss tthhee eennccooddeedd ttoonneess %% %% SShhiillaaddiittyyaa SSiirrccaarr 22000022 %% DDSSPP CCoouurrssee PPrroojjeecctt gglloobbaall ddttmmff__rrffrreeqq gglloobbaall ddttmmff__ccffrreeqq gglloobbaall ddttmmff__ffss gglloobbaall ddttmmff__ssiilleenncceelleenn gglloobbaall ddttmmff__ttoonneelleenn gglloobbaall ddttmmff__kkeeyy %% CCaann uussee tthhee sseettppaarraammeetteerr ffuunnccttiioonn iinn oorrddeerr ttoo jjuusstt eevvaalluuaattee tthhiiss ffuunnccttiioonn %% ttoo ddoo tthhiiss jjuusstt uunn--ccoommmmeenntt tthhee sseettppaarraammeetteerr.. TThhiiss ssccrriipptt wwiillll sseett uupp tthhee gglloobbaall %%vvaarriiaabbllee rreeqquuiirreedd ttoo eexxeeccuuttee ddttmmff eennccooddiinngg.. %%sseettppaarraammeetteerr;; %% LLeennggtthh ooff BBaanndd PPaassss FFiilltteerr %% IIff tthhee bbaannddppaassss iiss ttoooo wwiiddee,, tthhiiss ccaann bbee iinnccrreeaasseedd ttoo pprroodduuccee aa mmoorree nnaarrrrooww ffiilltteerr %% ffoorr ffiinneerr pprreecciissiioonn.. HHoowweevveerr ccoommppuuttaattiioonn ttiimmee iinnccrreeaasseess aa vvaalluuee LL == 6644 ggiivveess %% ssaattiissffaaccttoorryy rreessuullttss ffoorr nnoo nnooiissee eennvviirroonnmmeenntt LL == 6644;; ffiilltt__nn == 00::LL--11;; ddttmmff__ddiiggiilleenn == lleennggtthh((eennccssttrr))//((ddttmmff__ttoonneelleenn++ddttmmff__ssiilleenncceelleenn));; ffoorr ddeeccoo__sseeqq == 11::ddttmmff__ddiiggiilleenn %% LLoooopp tthhrroouugghh eeaacchh rrooww aanndd CChheecckk iiff tthhee rrooww--ii ffrreeqquueennccyy eexxiisstt iinn tthhee ssiiggnnaall %% DDeeffiinnee tthhee ppooiinntteerr aatt ssttaarrtt ooff tthhee sseeqquueennccee ssttaarrttppooss == ((ddeeccoo__sseeqq -- 11))**((ddttmmff__ttoonneelleenn ++ ddttmmff__ssiilleenncceelleenn)) ++ 11;; eennddppooss == ssttaarrttppooss ++ ddttmmff__ttoonneelleenn -- 11;; eennccssttrr__ffrraagg == eennccssttrr((ssttaarrttppooss::eennddppooss));; ffoorr ii == 11::44 %% CCaallccuullaattee ffiilltteerr ccooeeffffiicciieennttss ffoorr tthhee bbaannddppaassss ffiilltteerr ffoorr rrooww ffrreeqquueenncciieess %% ggiivveenn tthhee cceenntteerr ffrreeqquueennccyy hhhh == 22//LL**ccooss((22**ppii**ddttmmff__rrffrreeqq((ii))**ffiilltt__nn//ddttmmff__ffss));; ssss == mmeeaann((ccoonnvv((eennccssttrr__ffrraagg,,hhhh))..^̂22)) >> mmeeaann((eennccssttrr__ffrraagg..^̂22))//55;;%% ccoommppaarree mmeeaann aammpplliittuuddee aanndd iiff %% mmoorree tthhaann 2200%% (( //55 )),, tthhee ffrreeqquueennccyy %% ccoommppoonneenntt iiss ccoonnssiiddeerreedd ttoo bbee ssttrroonngg iiff ((ssss)) rrooww == ii;; bbrreeaakk %% wwee aallrreeaaddyy hhaavvee oouurr rrooww -- nnoo nneeeedd ttoo cchheecckk tthhee rreesstt eenndd eenndd %% LLoooopp tthhrroouugghh eeaacchh ccoolluummnn aanndd cchheecckk iiff tthhee ccoolluummnn--ii ffrreeqquueennccyy eexxiisstt iinn tthhee ssiiggnnaall ffoorr ii == 11::44 %% CCaallccuullaattee ffiilltteerr ccooeeffffiicciieennttss ffoorr tthhee bbaannddppaassss ffiilltteerr ffoorr ccoolluummnn ffrreeqquueenncciieess %% ggiivveenn tthhee cceenntteerr ffrreeqquueennccyy hhhh == 22//LL**ccooss((22**ppii**ddttmmff__ccffrreeqq((ii))**ffiilltt__nn//ddttmmff__ffss));; ssss == mmeeaann((ccoonnvv((eennccssttrr__ffrraagg,,hhhh))..^̂22)) >> mmeeaann((eennccssttrr__ffrraagg..^̂22))//55;; iiff ((ssss)) ccooll == ii;;

9

Page 10: DTMF Encoder Decoder Design Using FIR Banks

bbrreeaakk %% wwee aallrreeaaddyy hhaavvee oouurr ccoolluummnn -- nnoo nneeeedd ttoo cchheecckk tthhee rreesstt eenndd eenndd nnuummssttrr((11,,ddeeccoo__sseeqq)) == ddttmmff__kkeeyy((rrooww,,ccooll));; eenndd ddiiggiittssttrr == nnuummssttrr;;

Code for DTMF main Code for DTMF main ffuunnccttiioonn rreettuurrnn__ddiiggiittss == ddttmmffmmaaiinn((nnuumm22eennccooddee)) %% TThhiiss pprrooggrraamm ssiimmuullaatteess tthhee tteelleepphhoonnee DDTTMMFF DDiiaalliinngg SScchheemmee %% PPlleeaassee SSeeee ddttmmffee..mm ffoorr hhooww eennccooddiinngg iiss ddoonnee %% PPlleeaassee SSeeee ddttmmffdd..mm ffoorr hhooww ddeeccooddiinngg iiss ddoonnee %% UUssaaggee EExxaammpplleess %% rreettuurrnn__ddiiggiittss == ddttmmffmmaaiinn((''112233AA##**'')) %% %% SShhiillaaddiittyyaa SSiirrccaarr 22000022 %% DDSSPP CCoouurrssee PPrroojjeecctt %%DDeeffiinnee GGlloobbaall vvaarriiaabbllee uusseedd bbyy ddttmmffee aanndd ddttmmffdd ffuunnccttiioonnss gglloobbaall ddttmmff__rrffrreeqq gglloobbaall ddttmmff__ccffrreeqq gglloobbaall ddttmmff__kkeeyy gglloobbaall ddttmmff__ffss gglloobbaall ddttmmff__ssiilleenncceelleenn gglloobbaall ddttmmff__ttoonneelleenn %% DDeeffiinnee tthhee ffrreeqquueenncciieess uusseedd iinn ssyynntthheessiizziinngg tthhee DDTTMMFF ssiiggnnaall %% EEaacchh ffrreeqquueennccyy ccoorrrreessppoonnddss ttoo aa rrooww oorr ccoolluummnn ooff kkeeyyss oonn tthhee kkeeyyppaadd,, %% eegg.. pprreessssiinngg ''**'' mmeeaannss tthhaatt tthhee ffrreeqquueenncciieess ffoorr rrooww 44 aanndd ccoolluummnn 11 sshhoouulldd %% bbee uusseedd.. TThhee rreessuullttiinngg DDTTMMFF ttoonnee iiss tthhee ttwwoo wwaavveeffoorrmmss ssuummmmeedd ttooggeetthheerr ddttmmff__rrffrreeqq == [[ 669977 777700 885522 994411]];; %% ffrreeqquueennccyy ccoommppoonneennttss ffoorr eeaacchh rrooww ddttmmff__ccffrreeqq == [[11220099 11333366 11447777 11663333]];; %% ffrreeqquueennccyy ccoommppoonneennttss ffoorr eeaacchh ccoolluummnn %% DDeeffiinnee tthhee tteelleepphhoonnee kkeeyyppaadd aass aa 22dd mmaattrriixx ddttmmff__kkeeyy == [[ ''11'' ''22'' ''33'' ''AA'';; ''44'' ''55'' ''66'' ''BB'';; ''77'' ''88'' ''99'' ''CC'';; ''**'' ''00'' ''##'' ''DD'']];; %% SSaammpplliinngg FFrreeqquueennccyy ddttmmff__ffss == 88000000;; ddiisspp(([[''DDTTMMFF ssaammpplleerraattee sseett ttoo '' nnuumm22ssttrr((ddttmmff__ffss)) '' HHzz'']]));; %%DDuurraattiioonn ooff tthhee TToonnee ttoo ggeenneerraattee ddttmmff__ttoonneelleenn == rroouunndd((ddttmmff__ffss ** 00..5500));; %% CCoonnvveerrtt lleennggtthh ffrroomm sseeccoonnddss ttoo ssaammpplleess ddiisspp(([[''DDTTMMFF ttoonnee lleennggtthh sseett ttoo '' nnuumm22ssttrr((ddttmmff__ttoonneelleenn)) '' ssaammpplleess'']]));; %%IInnsseerrtt SSiilleennccee lleennggtthhss bbeettwweeeenn ttoonneess ffoorr ddeetteeccttiioonn ddttmmff__ssiilleenncceelleenn == rroouunndd((ddttmmff__ffss ** 00..0011));; %% CCoonnvveerrtt lleennggtthh ffrroomm sseeccoonnddss ttoo ssaammpplleess ddiisspp(([[''DDTTMMFF bbrreeaakk lleennggtthh sseett ttoo '' nnuumm22ssttrr((ddttmmff__ssiilleenncceelleenn)) '' ssaammpplleess'']]));; %% CCaallll EEnnccooddeerr FFuunnccttiioonn eennccooddeeddTToonneess == ddttmmffee((nnuumm22eennccooddee));; %%ssoouunndd((eennccooddeeddTToonneess,,ddttmmff__ffss));; %%PPlloott tthhee eennccooddeedd TToonneess XX == fffftt((eennccooddeeddTToonneess));; NN == lleennggtthh((eennccooddeeddTToonneess));; ff == ((00::NN--11))//NN**ddttmmff__ffss;; ffiigguurree((11)),,pplloott((ff,, aabbss((XX)),,''gg''))

10

Page 11: DTMF Encoder Decoder Design Using FIR Banks

xxllaabbeell((''FFrreeqquueennccyy ((HHzz))'')) yyllaabbeell((''AAmmpplliittuuddee'')) ttiittllee((''FFFFTT AAmmpplliittuuddee SSppeeccttrruumm'')) %%RReettuurrnn TThhee DDeeccooddeedd TToonneess DDeeccooddeedd__DDiiggiittss == ddttmmffdd((eennccooddeeddTToonneess));; iiff ((ssttrrnnccmmpp((DDeeccooddeedd__DDiiggiittss,,nnuumm22eennccooddee,,lleennggtthh((nnuumm22eennccooddee)))) ==== 11)) ddiisspp(('' ''));; ddiisspp((''SSuucccceessffuullllyy ddeeccooddeedd tthhee ddiiaalleedd nnuummbbeerr''));; ddiisspp(('' ''));; ddiisspp((''TThhee ddiiaalleedd TTeelleepphhoonnee NNuummbbeerr wwaass''));; nnuumm22eennccooddee ddiisspp(('' ''));; ddiisspp((''TThhee DDeeccooddeedd TTeelleepphhoonnee NNuummbbeerr iiss ''));; DDeeccooddeedd__DDiiggiittss eellssee ddiisspp((''EErrrroorr IInn DDeeccooddiinngg''));; DDeeccooddeedd__DDiiggiittss eenndd

11


Recommended