Upload
siva-raman
View
233
Download
0
Embed Size (px)
Citation preview
8/18/2019 Program for Low Pass Filter
1/63
PROGRAM FOR LOW PASS FILTER
%Program – Hamming Window
%Low Pass Filter clear all;
Fcut = 1000;
Fsamp = 7500;
N = 0; % !rder o" t#e "ilter
d="design$lowpass&N'"c&'N'Fcut'Fsamp(;
Hd=windowd'&window&')#amming(;"*toolHd(;
8/18/2019 Program for Low Pass Filter
2/63
OUTPUT:
0 0.5 1 1.5 2 2.5 3 3.5
-80
-70
-60
-50
-40
-30
-20
-10
0
Frequency (kHz)
M a g n i t u d e ( d B )
Magnitude Response (dB)
8/18/2019 Program for Low Pass Filter
3/63
PROGRAM FOR HIGH PASS FILTER:
%Program – Hamming Window%Hig# Pass Filter
clear all;
Fcut = 1000;
Fsamp = 7500;
N = 0; % !rder o" t#e "ilter
d= "design$#ig#pass&N'"c&'N'Fcut'Fsamp(
Hd=windowd'&window&')#amming(;
"*toolHd(;
8/18/2019 Program for Low Pass Filter
4/63
OUTPUT:
0 0.5 1 1.5 2 2.5 3 3.5
-60
-50
-40
-30
-20
-10
0
Frequency (kHz)
M a g n i t u d e ( d B )
Magnitude Response (dB)
8/18/2019 Program for Low Pass Filter
5/63
PROGRAM FOR LOW PASS FILTER:
%Program + ,utterwort# Filter
%Low Pass Filter
rp = -; % pass.and ripplers = 0; % stop.and attenuation
"s = /0000; % sampling "reuenc
wp = 2/00 3 10000;
ws = 5000 3 10000;
4n' wn = .uttordwp' ws' rp' rs(;
4.' a = .uttern' wn'&low&(; % 6alculate "ilter coe""icients
"*tool.' a(;
8/18/2019 Program for Low Pass Filter
6/63
OUTPUT:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
-400
-350
-300
-250
-200
-150
-100
-50
0
Normalized Frequency (×π rad/sample)
M a g n i t u d e ( d B )
Magnitude Response (dB)
8/18/2019 Program for Low Pass Filter
7/63
PROGRAM FOR HIGH PASS FILTER:
%Program + ,utterwort# Filter
%Hig# Pass Filter rp = -; % pass.and ripple
rs = 0; % stop.and attenuation
"s = /0000; % sampling "reuenc
wp = 2/00 3 10000;
ws = 5000 3 10000;
4n' wn = .uttordwp' ws' rp' rs(;
4.' a = .uttern' wn' ig#&(; % 6alculate "ilter coe""icients
"*tool.' a(;
8/18/2019 Program for Low Pass Filter
8/63
OUTPUT:
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
-250
-200
-150
-100
-50
0
Normalized Frequency (×π rad/sample)
M a g n i t u d e ( d B )
Magnitude Response (dB)
8/18/2019 Program for Low Pass Filter
9/63
PROGRAM:
Decimation using TMS320C6745 DSP
Generate sine a!eInitial Command (Closing and Clearing)clc; % clears the command windowclose all; % closes all the previously open windowclear all; % clears previously stored valuesGenerating Input Sequencefm = !; % input signal frequency"s = #!; % sampling frequencyt = !$"s$!&'; % time range for the input sequence = sin(*pi*fm*t); % input sinusoidal signal+gure()su,plot(#--)stem(); % .iscrete plot of the input sequence-&&& &&& where /ais corresponds to the num,er ofsamplesla,el(01o& of samples0); % la,elling /aisyla,el(02mplitude0); % la,elling y/aistitle(0input discrete sinusoidal sequence0); % giving title to the plot
8/18/2019 Program for Low Pass Filter
10/63
Decimation o" t#e $n%ut Se&uence3 = ; % factor ,y which the input sequence is decimatedd = decimate(-3); % resamples the sample in with a rate (3)times the original ratesu,plot(#--)stem(d) % .iscrete plot of the input sequence-&&& &&& where /ais corresponds to the num,er of samplesla,el(01o& of samples0); % la,elling /ais
yla,el(02mplitude0); % la,elling y/aistitle(0.ecimated Sinusoidal Sequence0); % giving title to the plot
8/18/2019 Program for Low Pass Filter
11/63
$ntero'ation o" t#e $n%ut Se&uence4 = ; % factor ,y which the input sequence is interpolatedI = interp(-4); % resamples the sample in with a rate 4 times the
8/18/2019 Program for Low Pass Filter
12/63
original ratesu,plot(#--5);stem(I); % .iscrete plot of the input sequence-&&& &&& where /ais corresponds to the num,er of samplesla,el(01o& of samples0); % lae,lling /ais
yla,el(02mplitude0); % la,elling y/aistitle(0Interpolated Sinuoidal Sequence0) % giving title to the plot
8/18/2019 Program for Low Pass Filter
13/63
$nter%o'ation o" t#e Decimate( Signa'
8/18/2019 Program for Low Pass Filter
14/63
4 = ; % coe6cient ,y which the singal is interpolatedI = interp(d-4); % resamples the sample in with a rate 4 times theoriginal ratesu,plot(#--#)stem(I); % .iscrete plot of the input sequence-&&&
&&& where /ais corresponds to the num,er of samplesla,el(01o& of samples0); % la,elling /aisyla,el(02mplitude0); % la,elling y/aistitle(07riginal Signal 7,tained 2fter Interpolating the .ecimatedSignal0); % giving title to the graph
8/18/2019 Program for Low Pass Filter
15/63
8/18/2019 Program for Low Pass Filter
16/63
Ex.No.8 Study and compa!"on o# d!##$$nt non%paam$t!c "p$cta&
$"t!mat!on t$c'n!(u$"
AIM:
o stud and compare t#e di""erent non+parametrical spectral estimationtec#niues$
TOOL RE)UIRE*:
P6' 89L9, so"tware
THEOR+:
P!W: !N P
8/18/2019 Program for Low Pass Filter
17/63
Pn t#is paper' it is assumed t#at t#e window is small enoug# so t#at t#eassumption o" stationar #olds' allowing t#e autocorrelation and t#e power spectrum to .e aFourier rans"orm pair$
,., P$!odo-am
9 simple+minded met#od o" estimating t#e autocorrelation o" a signal o"
"inite lengt# is called t#e Periodogram 8et#od$ #is estimation met#odassumes t#e o.ser*ed signal x n( N is a truncated *ersion o" t#e originallintended signal xn($#e spectral resolution can .e de"ined . t#e "reuenc at w#ic# t#e powero" t#e low pass "ilter drops to #al" o" t#e total power$
8/18/2019 Program for Low Pass Filter
18/63
amplitudes o" t#e side lo.es determine t#e "p$cta& ma"/!n- e""ect$ #e#ig#er t#e amplitudes o" t#e side lo.es' t#e more masCing e""ect o" t#e powerspectrum at a gi*en "reuenc #as on t#e near. "reuencies$
a.le 1 s#ows se*eral common truncation windows w#ic# are de"ined o*ert#e "inite inter*al0 n N E1' t#ere is a trade+o"" .etween t#e widt# o" t#e main lo.e and t#eamplitudes o" t#e side lo.e$ 9lt#oug# t#e ectangular Window pro*ides t#e
.est spectral resolution wit# t#e narrowest -d, .andwidt# "or t#e main lo.e'it also gi*es t#e worst spectral masCing e""ect$, c#anging t#e truncation window' t#e spectral resolution is sacri"iced "or asmaller spectral masCing e""ect$ #e "p$cta& $"o&ut!on o" t#e 8odi"iedPeriodogram 8et#od depends o" t#e truncation window$
#e resolutions "or t#e "i*e windows are s#own in a.le 1$ #e spectralresolution is in t#e "ormA pW e j con*erges to animpulse as N ' t#e desira.le conditionlim I jw ( jw (
N Modified
,.0 1at&$tt2" M$t'od
,ot# t#e Periodogram 8et#od and 8odi"ied Periodogram 8et#od do not
gi*e ?ero *ariances as t#e data lengt# approac#es in"init$ !ne wa toen"orce ?ero *ariance is . a*eraging$ #e ,artlettBs 8et#od di*ides t#esignal o" lengt# N into J segments' wit# eac# segment #a*ing lengt#
L N 3 K $ #e Periodogram 8et#od is t#en applied to eac# o" t#e Jsegments$ #e a*erage o" t#e resulting estimated power spectra is taCen ast#e estimated power spectrum o" t#e ,artlettBs #us' as K ' t#e *ariance
I jw ( Bartlett Var P e approac#es ?ero$ >n summar' t#e *alue o" K can .e used todesign t#e trade+o"" .etween spectral resolution and*ariance$ Wit# a larger num.er o" segments' t#e *ariance is reduced .ut at
t#e e@pense o" spectral resolution$ 6on*ersel' wit# a smaller num.er o"segments' t#e spectral resolution i$e$ t#e
.andwidt# o" t#e main lo.e( is reduced at e@pense o" larger *ariance$#e comp&$x!ty can .e anal?ed . inspecting t#e loop structure o" t#eimplementation$ #e ,artlettBs 8et#od can .e implemented as "ollowsA-( :stimate t#e power spectra o" t#e K segments using t#e Periodogram8et#od$
8/18/2019 Program for Low Pass Filter
19/63
2( 6ompute t#e a*erage o" t#e estimates o" all t#e segments w#ic# is an On(operation$#us' t#e o*erall comple@it o" t#e ,artlettBs 8et#od is On- (
K On( On- ( $
,.3 W$&c'2" M$t'od
#e Welc#Bs 8et#od eliminates t#e trade o"" .etween spectral resolution and*ariance in t#e ,artlettBs 8et#od . allowing t#e segments to o*erlap$Furt#ermore' t#e truncation window can also *ar$ :ssentiall' t#e 8odi"iedPeriodogram 8et#od instead o" t#e Periodogram 8et#od( isapplied to eac# o" t#e o*erlapping segments$ 8at#ematicall' t#e estimated
power spectrum K is t#e num.er o" segments' L is t#e lengt# o" eac#segment' n:ac# o" t#e J segments is simpl t#e 8odi"ied Periodogram estimate w#ic#is asmptoticall un.iased$ 6onseuentl' t#e estimated power spectrum I
jw (Welch P e ' w#ic# is t#e a*erage o" t#e Periodogram estimates o" t#e Jsegments' is also a"ymptot!ca&&y un4!a"$d$ #e 5a!anc$ o" t#e estimated
power spectrum I jw ( Welch P e is more di""icult to compute since t#ere iscorrelation .etween o*erlapping segments$ Howe*er' it is s#own in 41 t#atwit# 50% o*erlap D L / 1 (' t#e *ariance o" t#e estimated power spectrum I jw (Welch P e is a.out #us' as N ' t#e *ariance I jw (
Bartlett Var P e approac#es ?ero$
>n summar' t#e lengt# o" eac# segment' L
N
E D
K
E 1( ' can .e used toimpro*e .ot# t#e spectral resolution and t#e *ariance$ , allowing moreo*erlapping larger D(' more segments larger J( or longer segments larger
L ( can .e o.tained to impro*e .ot# t#e spectral resolution and t#e *ariance$Howe*er' o*erlapping introduces correlations .etween segments$ >n practice't#eamount o" o*erlapping is tpicall .etween 50% to 75% 41$#e comp&$x!ty can .e anal?ed . inspecting t#e loop structure o" t#eimplementation$ #eWelc#Bs 8et#od can .e implemented as "ollowsA
1( :stimate t#e power spectra o" t#e K segments using t#e 8odi"iedPeriodogram 8et#od$
8/18/2019 Program for Low Pass Filter
20/63
6ompa!"on o# PSE M$t'od"
#ere were 7- cancerous !>s and 5/0 .enign !>s in t#e test image$ :ac#!> was onedimensional and was 1 pi@els long$ #e 7-M5/0=5- !>swere mapped to 5- "eature *alues using t#e Periodogram 8et#od$ #e"eature *alues were normali?ed to t#e inter*al 0'1($ #e median "eature*alue o" t#e "eature *alues o" eac# class o" eac# "eature was used as t#e$xp$ct$d #$atu$ 5a&u$ "or t#e class$Wit# t#e e@pected "eature *alues' t#e mean+suared+error 8
8/18/2019 Program for Low Pass Filter
21/63
)*+,O:- ST.D/ O A1$S$,G ))CTS A,D
.A,T$SAT$O, ))CTS
AIM:
o stud t#e e""ects o" aliasing and uanti?ation$
THEOR+A
9liasing arises w#en a signal is discretel sampled at a rate t#at isinsu""icient to capture t#e c#anges in t#e signal$ 6onsider t#e "ollowingconte@ts in w#ic# signals are discretel sampledA
etinal images are sampled in space . p#otoreceptors$Film and *ideo are sampled in time . discrete "rames$
8/18/2019 Program for Low Pass Filter
22/63
at an point in t#e image plane t#ere are "reuenc components' or lig#t+darC transitions' t#at occur "aster t#an " s=/' w#ic# in t#is case is 1/"rames3sec$ ,ut in man situations t#e lig#t+darC transitions ma .eoccurring "aster t#an t#is suc# as a wagon w#eel or propeller rotating at #ig#speed$
)uant!7at!on
First' a .it o" tri*ia$ 9s ou Cnow' it is a digital computer' not a digitcomputer$ #e in"ormation processed is called digital data' not digit data$W# t#en' is analog+to+digital con*ersion generall calledA digiti?e anddigiti?ation' rat#er t#an digitali?e and digitali?ationO #e answer is not#ingou would e@pect$ W#en electronics got around to in*enting digitaltec#niues' t#e pre"erred names #ad alread .een snatc#ed up . t#e medicalcommunit nearl a centur .e"ore$ igitali?e and digitali?ation mean to
administer t#e #eart stimulant digitalis$Notice t#at we care"ull a*oidcomparing a( and c(' as t#is would lump t#e sampling and uanti?ationtoget#er$ >t is important t#at we anal?e t#em separatel .ecause t#edegrade t#e signal in di""erent was' as well as .eing controlled . di""erent
parameters in t#e electronics$ #ere are also cases w#ere one is used wit#outt#e ot#er$ For instance' sampling wit#out uanti?ation is used in switc#edcapacitor "ilters$
RESULTA
8/18/2019 Program for Low Pass Filter
23/63
#us we #a*e studied t#e e""ects o" aliasing and uanti?ation$
E.NO: STU*+ OF A**RESSING MO*ES USING TMS096;3<
Aim
8o Study the various addressing mode of 83S5!C9:#' .S
processor&
A((ressing Mo(es
8he addressing modes in 83S5!C9:#'
& move address
register (?32
8/18/2019 Program for Low Pass Filter
24/63
Memor ma%%e( register a((ressing mo(e:
3emory mapped register addressing is used to access
e6ciently the C and on chip peripheral registers& It
operates li>e the direct addressing ecept that the upper @/
,its of the address that is accessed are assumed to ,e
!s&8his allows us to address the memory mapped registers of
data page ! directly without the overhead of changing the
.S or auiliary register& 7nly the seven lower ,its of the
complete code- including opcode can ,e represented using a
single 9/,it word&
1inear A((ressing Mo(e
1D an( ST $nstructions
"or load and store instructions- linear mode simply
shifts the oAsetcst operand to the left ,y 5- - - or ! for
dou,le word- word- halfword- or ,yte access- respectively;
and then performs an add or a su,tract to ,ase< (depending
on the operation speci+ed)& 8he 4.1.B and S81.B
instructions also support nonscaled oAsets& In nonscaled
8/18/2019 Program for Low Pass Filter
25/63
mode- the oAset
8/18/2019 Program for Low Pass Filter
26/63
2s with linear address arithmetic- oAset
8/18/2019 Program for Low Pass Filter
27/63
,its 5 through 1 E unchanged after address arithmetic&
8he resulting address is ,ounded to (1 E ) range-
regardless of the sie of the oAset sie of F is F ,ytes- not F times the data sie (,yte-
halfword- word)& So- to perform circular addressing on an
array of F words- a sie of 5 should ,e speci+ed- or 1 = #&
ample shows an 2..2H performed with register 2# in
circular mode and ?D! = #- so the ,uAer sie is 5 ,ytes- 9
halfwords- or F words& 8he value in 23< for this eample is
!!!# !!!h&
ASM G$n$a& Poc$du$ to =o/ 6;3Space 4auncher&
a& ROS) Select the proect location and ma>e one new
folder- MA) ,) O1D)R 8ype the Bor>space name-
O O &
5& $1) ,) CCS PRO)CT
a& roect name$ 8ype your proect name&
,& 8ic> use default location& ,)*T
c& roect type$ C9!!!&
8/18/2019 Program for Low Pass Filter
28/63
d& 8ic> .e,ug 2nd & 8arget content$ none& $,$S8
#& $1) ,) SO.RC) $1)
a& Source +le$ 8ype your add&asm( &asm etension is must )&
,& 8ype the program&
c& $1) SA9)+
'& aste the following ,oard li,rary +les in wor>space location&
a& Common folder (contains header +les)
,& Gel folder (contains gel +le)
c& 4i,rary folder(contains li,rary +les)
9& aste the asm lin>er +le and vectors&asm in the proect
location&(asm lin>er +le and vectors&asm is availa,le in cd)
1ote$ 8hose folders and lin>er +le are avail,le at cd&
:& PRO)CT PROP)RT$)S CC;; .$1D AS$C
OPT$O,
8/18/2019 Program for Low Pass Filter
29/63
a& 8arget processor version(//silicon version- /mv) $ 9#!!E
,& I1 CCEE ?I4.- I1C4. 78I71S (2dd dir to Linclude
search path(//includeMpath-/I)) select this add icon and add
the following three path ,y indivdually
NOP.iagQ&&&&commonheaderN
NOPK.2ISMCGMagestidaisN
NOPC9!!!MCS4MCGMit&
& TARG)T D).G ACT$9) PRO)CT&(8hen see out at
corresponding place after run)
8/18/2019 Program for Low Pass Filter
30/63
& 9$) M)MOR/
5& In right side- memory window will open& 8ype the output
adrress !C!!!!!!
#& TARG)T R.,+
'& TARG)T 8A1T+
See the 7utput at articular location$
!C!!!!!!! R @@C#C!?&&&&&&&&
8/18/2019 Program for Low Pass Filter
31/63
Resu't:
8he study of various addressing modes of 83S5!C9:#' .S
processor was veri+ed&
LINEAR 6ON>OLUTION USING TMS096;3< *SP
Po-am
QincludeRstdio$#S
Qde"ine@n 2Qde"ine#n 2
*oid main(T
int U@'U#'U'i'n'C;
@ = int U(0@c0001000;# = int U(0@c00010-0; = int U(0@c0001050;
"ori=0;iR@nM#n+1(;iMM(T
4i=0;@4@nMi=0;#4#nMi=0;
V
"orn=0;nR@nM#n+1(;nMM(
T"orC=0;CR=n;CMM(
4n = 4n( M @4C(U#4n+C((;Vw#ile1(;
V
8/18/2019 Program for Low Pass Filter
32/63
6IR6ULAR 6ON>OLUTION USING TMS096;3< *SP
Po-am
QincludeRstdio$#Sint rotint U@(;*oid main(T
int Uin1'Uin/'Uout'Utemp'i'sum=0'D;in1 = int U(0@c0001000;
in/ = int U(0@c00010-0;out = int U(0@c0001050;temp = int U(0@c000/000;"ori=0;iR2;iMM(T
i"i == 1(temp4iM/ = in14i;
elsei"i == -(temp4i+/ = in14i;
elsetemp4i = in14i;
V"ori=0;iR2;iMM(
Tsum = 0;"orD=0;DR2;DMM(T
sumM=in/4D U temp4D(;Vout4i = sum;rottemp(;
Vw#ile1(;
Vrotint U@(T
int t;t = @40;@40 = @4-;@4- = @4/;@4/ = @41;@41 = t;
V
8/18/2019 Program for Low Pass Filter
33/63
FF P!>N > NX 8W-/06725
inc'u(e math&hT>(e?ne I 5&#'@@oat UFV-tUFV-sUFV-srUFV-siUFV-KrUFV-KiUFV-WrUFV-WiUFV;const @oat B!r = -
B!i = !-Br = !&:!:-Bi = /!&:!:-
Br = !- Bi = /-
B5r = /!&:!:-B5i = /!&:!:;
!oi( main()P
int *Input-*
8/18/2019 Program for Low Pass Filter
34/63
sU!V = (int)(U!V E (UV * B!r));sUV = (int)(U!V / (UV * B!r));sUV = (int)(UV E (U5V * B!r));sU5V = (int)(UV / (U5V * B!r));
sU#V = (int)(U#V E (U'V * B!r));sU'V = (int)(U#V / (U'V * B!r));sU9V = (int)(U9V E (U:V * B!r));sU:V = (int)(U9V / (U:V * B!r));
stage two processsrU!V = (sU!V E (sUV * B!r));siU!V = !;
srUV = sUV;siUV = (sU5V * Bi);
srUV = (sU!V / (sUV * B!r));siUV = !;
srU5V = sUV;siU5V = / (sU5V * Bi);
srU#V = (sU#V E (sU9V * B!r));siU#V = !;
srU'V = sU'V;siU'V = (sU:V * Bi);
srU9V = (sU#V / (sU9V * B!r));siU9V = !;
srU:V = sU'V;siU:V = /(sU:V * Bi);
output comple multiplication for ? * Bn
WrU!V = (srU#V * B!r) / (siU#V * B!i); WiU!V = (srU#V * B!i) E (siU#V * B!r);
WrUV = (srU'V * Br) / (siU'V * Bi); WiUV = (srU'V * Bi) E (siU'V * Br);
8/18/2019 Program for Low Pass Filter
35/63
WrUV = (srU9V * Br) / (siU9V * Bi); WiUV = (srU9V * Bi) E (siU9V * Br);
WrU5V = (srU:V * B5r) / (siU:V * B5i);
WiU5V = (srU:V * B5i) E (siU:V * B5r);
WrU#V = (srU#V * B!r) / (siU#V * B!i); WiU#V = (srU#V * B!i) E (siU#V * B!r);
WrU'V = (srU'V * Br) / (siU'V * Bi); WiU'V = (srU'V * Bi) E (siU'V * Br);
WrU9V = (srU9V * Br) / (siU9V * Bi); WiU9V = (srU9V * Bi) E (siU9V * Br);
WrU:V = (srU:V * B5r) / (siU:V * B5i); WiU:V = (srU:V * B5i) E (siU:V * B5r);
comple addition for 2 E ?Bn
=!;"or(i=!;i#;iEE)P
KrUiV = srUV E WrUiV;KiUiV = siUV E WiUiV; EE;
Q
comple su,traction for 2 / ?Bn
=!;"or(i=#;iF;iEE)P
KrUiV = srUV / WrUiV;KiUiV = siUV / WiUiV; EE;
Q
sending output array to memory location
"or(i=!;iF;iEE)P
8/18/2019 Program for Low Pass Filter
36/63
*
8/18/2019 Program for Low Pass Filter
37/63
!oi( main()P
int *Input-*
8/18/2019 Program for Low Pass Filter
38/63
siU#V = (siU#V E siU9V);srU'V = (srU'V E srU:V);siU'V = (siU'V E siU:V);srU9V = (srU#V / srU9V) * ;
siU9V = (siU#V / siU9V) * ;
WrU!V = srU'V / srU:V; WiU!V = siU'V / siU:V;
WrUV = ((WrU!V * Br) / (WiU!V * Bi)); WiUV = ((WrU!V * Bi) E (WiU!V * Br));
srU:V = WrUV;siU:V = WiUV;
outputKrU!V = (srU!V E srUV);KiU!V = (siU!V E siUV);KrUV = (srU!V / srUV);KiUV = (siU!V / siUV);KrUV = (srUV E srU5V);KiUV = (siUV E siU5V);KrU5V = (srUV / srU5V);KiU5V = (siUV / siU5V);
KrU#V = (srU#V E srU'V);KiU#V = (siU#V E siU'V);KrU'V = (srU#V / srU'V);KiU'V = (siU#V / siU'V);KrU9V = (srU9V E srU:V);KiU9V = (siU9V E siU:V);KrU:V = (srU9V / srU:V);KiU:V = (siU9V / siU:V); ,it reversaltrU!V = KrU!V;
tiU!V = KiU!V;trUV = KrU#V;tiUV = KiU#V;trUV = KrUV;tiUV = KiUV;trU5V = KrU9V;tiU5V = KiU9V;trU#V = KrUV;tiU#V = KiUV;
8/18/2019 Program for Low Pass Filter
39/63
trU'V = KrU'V;tiU'V = KiU'V;trU9V = KrU5V;tiU9V = KiU5V;
trU:V = KrU:V;tiU:V = KiU:V; sending output array to memory location
"or(i=!;iF;iEE)P
*
8/18/2019 Program for Low Pass Filter
40/63
*(sinoutEi)=!;"or(count=!;countnsamp;countEE)P
teta = ( * I * inpf * sampt * count);
printf(NXnteta = %lfN-teta);(t value=sin(teta)*!#;Set amplitude ,y
varying the value ! to !#printf(NXt sin %lf Jalue is $ %dN-teta-value);
value = valueY!!!!!"""";*sinoutEE = value;
QQ!N NX 8
8/18/2019 Program for Low Pass Filter
41/63
>9NXL: W9Y: X:N:9>!N NX 8
8/18/2019 Program for Low Pass Filter
42/63
S2B8778H G1inc'u(e math&hT!oi( main()P
int *Sawtooth;int i=!-=!;Sawtooth = (int *)!C!!!!!!!;
#i'e()P
"or(i=!;i!!;iEE) set the frequency valueP
=E; set the amplitude value*SawtoothEE = ;
Q
=!;i=!;*SawtoothEE = ;
>> L!W P9L: NX 8
8/18/2019 Program for Low Pass Filter
43/63
Program
Linclude stdio&hTLinclude math&hT
Linclude Nc9:#'&hNLinclude Nspiadc&hNLinclude Nspidac&hN
Lde+ne .2CMCSM47B(); SI!MSIC5 =!!; (CS=4ow$na,le)Lde+ne .2CMCSMHIGH(); SI!MSIC5 =!; (CS=High$.isa,le)Lde+ne G2I1 !&!5FF!::
void SIMBrite(unsigned short .ata);
static Zoat vU5V- yvU5V;
int Che,yshev(int input);
4 co/e6cient samp fr=9>h pass,and fr=#!!hZoat a!=-a=/F!55!9-a= !&95955:59#;
Zoat ,!=-,=-,=;
void main( void )P
static intF spiadc,ufU5V;int adcMvalue-vout=!;
C9:#'Minit();
spiadcMinit();spidacMinit();
while()P
spiadc,ufU!V = !!; setupcommand
spiadc,ufUV = !?";spiadc,ufUV = !!!;
8/18/2019 Program for Low Pass Filter
44/63
spiadcMcycle(spiadc,uf- 5); ecutespiadc read cycle
adcMvalue = ((spiadc,ufUVY!!f) F)[spiadc,ufUV;
vout = Che,yshev(adcMvalue);SIMBrite(vout);
***************************** G4C. SI Sent .ata F ,it *
****************************void SIMBrite(unsigned short .ata)P
unsigned short receive-;
.2CMCSM47B();
.ata = ( !5!!! [ .ata );
* Clear any old data *receive = SI!MSI?";
Bait for transmit ready while( SI!MSI?" Y !!!!!!!! );
* Brite ,yte *SI!MSI.28 = .ata;while((SI!MSI?" Y !!!!!!!!)==);
*
8/18/2019 Program for Low Pass Filter
45/63
vUV = vUV;vUV = input;yvU!V = yvUV;yvUV = yvUV;
yvUV = (,!*vU!V E ,*vUV) E , * vUV / (a * yvU!V) / ( a * yvUV);vout = yvUV*G2I1;return vout;
Q
$n%ut:
8/18/2019 Program for Low Pass Filter
46/63
Out%ut:
8/18/2019 Program for Low Pass Filter
47/63
8/18/2019 Program for Low Pass Filter
48/63
>> H>XH P9L: NX 8
8/18/2019 Program for Low Pass Filter
49/63
Lde+ne G2I1 !&:!#'FF'void SIMBrite(unsigned short .ata);
static Zoat vU5V- yvU5V;
int Che,yshev(int input);
H co/e6cient samp fr=9>h pass,and fr=9!!hZoat a!=-a=/&:#5F-a= !&'###5'5;Zoat ,!= -,=/-,=;
void main( void )
Pstatic intF spiadc,ufU5V;int adcMvalue-vout=!;
C9:#'Minit();spiadcMinit();spidacMinit();
while()
Pspiadc,ufU!V = !!;
setup commandspiadc,ufUV = !?";spiadc,ufUV = !!!;
spiadcMcycle(spiadc,uf- 5);
ecute spiadc read cycle
adcMvalue = ((spiadc,ufUVY!!f) F)[spiadc,ufUV;
vout = Che,yshev(adcMvalue);vout = vout E .C7""S8;if(voutT#!@') vout=#!@';SIMBrite(vout);
8/18/2019 Program for Low Pass Filter
50/63
***************************** G4C. SI Sent .ata F ,it *****************************void SIMBrite(unsigned short .ata)
P unsigned short receive-;
.2CMCSM47B();
.ata = ( !5!!! [ .ata );
* Clear any old data *receive = SI!MSI?";
Bait for transmit ready
while( SI!MSI?" Y !!!!!!!! );* Brite ,yte *SI!MSI.28 = .ata;while((SI!MSI?" Y !!!!!!!!)==);
*
8/18/2019 Program for Low Pass Filter
51/63
$n%ut
out%ut
8/18/2019 Program for Low Pass Filter
52/63
8/18/2019 Program for Low Pass Filter
53/63
FIR LOW PASS FILTER USING TMS096;3< *SP ?IT
ProgramLinclude stdio&hT
Linclude math&hTLinclude Nc9:#'&hNLinclude Nspiadc&hNLinclude Nspidac&hN
Lde+ne .2CMCSM47B(); SI!MSIC5 =!!; (CS=4ow$na,le)Lde+ne .2CMCSMHIGH(); SI!MSIC5 =!; (CS=High$.isa,le)
void SIMBrite(unsigned short .ata);
unsigned short i-=!-High-Jalue=!;signed int adcMvalue;
4ow ass samp fr=9>h s,f=!! p,f=#!!
Zoat hU'V = P !&!!9!'@'#'- !&!!#:F5'@-!&!!#!:@F@#95- !&!!55'5!:9!'9-!&!!F'5!#9@- /!&!!!#!9'@'9!'-/!&!!55F#5-/!&!!999!F5#9- /!&!!!#!:9!-/!&!5@:5F- /!&!'':!'9@#- /!&!9955:!#-/!&!'@:!5@'- /!&!5!F9F:-/!&!!F5'##-
/!&!!!9#9'@!@:- !&!!@!FF'#:@-!&!!:5@!9- !&!55:'#5@:-!&!#:#9@@@@- !&!9!:'9- !&!:5:@5F9-!&!F#'F:5F5- !&!@@5'9''#-!&!@FF9'F@:F- !&!@@@:@5955F- !&!@FF9'F@:F-!&!@@5'9''#- !&!F#'F:5F5-!&!:5:@5F9-
8/18/2019 Program for Low Pass Filter
54/63
!&!9!:'9- !&!#:#9@@@@-!&!55:'#5@:- !&!!:5@!9-!&!!@!FF'#:@- /!&!!!9#9'@!@:-/!&!!F5'##-
/!&!5!F9F:- /!&!'@:!5@'-/!&!9955:!#- /!&!'':!'9@#- /!&!5@:5F-/!&!!!#!:9!-/!&!!999!F5#9-/!&!!55F#5- /!&!!!#!9'@'9!'- !&!!F'5!#9@-!&!!55'5!:9!'9- !&!!#!:@F@#95-!&!!#:F5'@- !&!!9!'@'#'Q;
void main( void )P
intF spiadc,ufU5V;int i-valU!V->;Zoat temp-sum;
C9:#'Minit();spiadcMinit();
spidacMinit();
for(i=!;i';iEE)P
valUiV=!;Q
while()P
spiadc,ufU!V = !!; setup
commandspiadc,ufUV = !?";spiadc,ufUV = !!!;
spiadcMcycle(spiadc,uf- 5); ecutespiadc read cycle
adcMvalue = ((spiadc,ufUVY!!f) F)[spiadc,ufUV;
valU!V = adcMvalue;
8/18/2019 Program for Low Pass Filter
55/63
sum = !; for(>=!;>';>EE) P
temp = (valU>V)*(hU>V); sum = sum E temp; Q
SIMBrite(sum);
for(i='!;iT=!;i//) P valUiEV = valUiV; Q
***************************** G4C. SI Sent .ata F ,it *****************************void SIMBrite(unsigned short .ata)P
unsigned short receive;
.2CMCSM47B();
.ata = ( !5!!! [ .ata );
* Clear any old data *receive = SI!MSI?";
Bait for transmit ready while( SI!MSI?" Y !!!!!!!! );
* Brite ,yte *SI!MSI.28 = .ata;while((SI!MSI?" Y !!!!!!!!)==);
*
8/18/2019 Program for Low Pass Filter
56/63
$n%ut:
out%ut
8/18/2019 Program for Low Pass Filter
57/63
FIR HIGH PASS FILTER USING TMS096;3< *SP ?IT
Program
8/18/2019 Program for Low Pass Filter
58/63
Linclude stdio&hTLinclude math&hTLinclude Nc9:#'&hN
Linclude Nspiadc&hNLinclude Nspidac&hN
Lde+ne .2CMCSM47B(); SI!MSIC5 =!!; (CS=4ow$na,le)Lde+ne .2CMCSMHIGH(); SI!MSIC5 =!; (CS=High$.isa,le)
void SIMBrite(unsigned short .ata);
unsigned short i-=!-High-Jalue=!;signed int adcMvalue;
High ass sf=9>h s,f=!! p,f=#!!
Zoat hU'V =P /!&!!9!'@'#'-/!&!!#:F5'@-/!&!!#!:@F@#95-/!&!!55'5!:9!'9-/!&!!F'5!#9@-
!&!!!#!9'@'9!'- !&!!55F#5-!&!!999!F5#9- !&!!!#!:9!-!&!5@:5F- !&!'':!'9@#- !&!9955:!#-!&!'@:!5@'- !&!5!F9F:-!&!!F5'##- !&!!!9#9'@!@:- /!&!!@!FF'#:@-/!&!!:5@!9- /!&!55:'#5@:-/!&!#:#9@@@@- /!&!9!:'9- /!&!:5:@5F9-/!&!F#'F:5F5- /!&!@@5'9''#-/!&!@FF9'F@:F- !&@!!!!9'@- /!&!@FF9'F@:F-/!&!@@5'9''#- /!&!F#'F:5F5-/!&!:5:@5F9- /!&!9!:'9- /!&!#:#9@@@@-/!&!55:'#5@:- /!&!!:5@!9-/!&!!@!FF'#:@-
8/18/2019 Program for Low Pass Filter
59/63
!&!!!9#9'@!@:- !&!!F5'##-!&!5!F9F:- !&!'@:!5@'-!&!9955:!#- !&!'':!'9@#- !&!5@:5F-
!&!!!#!:9!- !&!!999!F5#9-!&!!55F#5- !&!!!#!9'@'9!'-/!&!!F'5!#9@-/!&!!55'5!:9!'9-/!&!!#!:@F@#95-/!&!!#:F5'@- /!&!!9!'@'#'Q;void main( void )P
intF spiadc,ufU5V;
int i-valU!V->;Zoat temp-sum;
C9:#'Minit();spiadcMinit();spidacMinit();
for(i=!;i';iEE)P
valUiV=!;Q
while()P
spiadc,ufU!V = !!; setupcommand
spiadc,ufUV = !?";spiadc,ufUV = !!!;
spiadcMcycle(spiadc,uf- 5); ecutespiadc read cycleadcMvalue = ((spiadc,ufUVY!!f) F)[
spiadc,ufUV;
valU!V = adcMvalue;
sum = !; for(>=!;>';>EE) P
8/18/2019 Program for Low Pass Filter
60/63
temp = (valU>V)*(hU>V); sum = sum E temp; Q
SIMBrite(sumE9');
for(i='!;iT=!;i//) P valUiEV = valUiV; QQ
Q
****************************
* G4C. SI Sent .ata F ,it *****************************void SIMBrite(unsigned short .ata)P
unsigned short receive;
.2CMCSM47B();
.ata = ( !5!!! [ .ata );
* Clear any old data *
receive = SI!MSI?";
Bait for transmit ready while( SI!MSI?" Y !!!!!!!! );
* Brite ,yte *SI!MSI.28! = .ata;while((SI!MSI?" Y !!!!!!!!)==);
*
8/18/2019 Program for Low Pass Filter
61/63
Out%ut
8/18/2019 Program for Low Pass Filter
62/63
8/18/2019 Program for Low Pass Filter
63/63