Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
OUTPUT:
Magnitude Response (dB)
0
-10
Magnitude (dB)
-20
-30
-40
-50
-60
-70
-80
0
0.5
1.5
2
Frequency (kHz)
2.5
3.5
OUTPUT:
Magnitude Response (dB)
0
Magnitude (dB)
-10
-20
-30
-40
-50
-60
0
0.5
1.5
2
Frequency (kHz)
2.5
3.5
OUTPUT:
Magnitude Response (dB)
0
-50
Magnitude (dB)
-100
-150
-200
-250
-300
-350
-400
0
0.1
0.2
0.3
0.4
0.5
0.6
Normalized Frequency ( rad/sample)
0.7
0.8
0.9
OUTPUT:
Magnitude Response (dB)
0
Magnitude (dB)
-50
-100
-150
-200
-250
0
0.1
0.2
0.3
0.4
0.5
0.6
Normalized Frequency ( rad/sample)
0.7
0.8
0.9
PROGRAM:
Decimation using TMS320C6745 DSP
Generate sine wave
Initial Command (Closing and Clearing)
clc;
% clears the command window
close all;
% closes all the previously open window
clear all;
% clears previously stored values
Generating Input Sequence
fm = 10;
% input signal frequency
Fs = 140;
% sampling frequency
t = 0:1/Fs:0.5;
% time range for the input sequence
x = sin(2*pi*fm*t); % input sinusoidal signal
figure(1)
subplot(4,1,1)
stem(x);
% Discrete plot of the input sequence,...
... where x-axis corresponds to the number of
samples
xlabel('No. of samples'); % labelling x-axis
ylabel('Amplitude');
% labelling y-axis
title('input discrete sinusoidal sequence'); % giving title to the plot
original rate
subplot(4,1,3);
stem(xI);
% Discrete plot of the input sequence,...
... where x-axis corresponds to the number of samples
xlabel('No. of samples'); % laeblling x-axis
ylabel('Amplitude');
% labelling y-axis
title('Interpolated Sinuoidal Sequence') % giving title to the plot
L = 2;
% coefficient by which the singal is interpolated
xI = interp(xd,L); % resamples the sample in x with a rate L times the
original rate
subplot(4,1,4)
stem(xI);
% Discrete plot of the input sequence,...
... where x-axis corresponds to the number of samples
xlabel('No. of samples'); % labelling x-axis
ylabel('Amplitude');
% labelling y-axis
title('Original Signal Obtained After Interpolating the Decimated
Signal'); % giving title to the graph
Ex.No.8
AIM:
To study and compare the different non-parametrical spectral estimation
techniques.
TOOL REQUIRED:
PC, MATLAB software
THEORY:
POWER SPECTRUM ESTIMATION (PSE)
There are two purposes for this paper. One purpose is to analyze several
common non-parametric power spectrum estimation (PSE) methods.
Another purpose is to analyze how power spectrum can be used for feature
extraction to detect cancer in an ultrasound image of a prostate. This paper
first analyzes five non-parametric PSE methods. They are: Periodogram
Method, Modified Periodogram Method, Bartletts Method, Welchs
Method, and Blackman-Tukey Method.
The methods are evaluated and compared by four characteristics: spectral
resolution, asymptotic bias, variance, and complexity. The five PSE methods
were implemented in Matlab and were applied to a test ultrasound image.
The resulting estimated power spectrum was linearized. The slope and the yintercept of the linearized power spectrum were used as two feature values.
The mean-squared-error was calculated in order to evaluate the performance
of the five methods for this feature extraction. It was found that this
particular feature extraction does not depend much on the spectral resolution
and the variance of the power spectrum. Consequently, the Periodogram
Method, which has the lowest complexity, is best for this feature extraction.
Lastly, the texture and the overall brightness of the image are reflected on
the slope and the yinterceptof the linearized power spectrum. This paper
proposes a simple but effective approach which uses these two features
jointly to detect the cancerous part of the prostate. There are mainly two
types of power spectrum estimation (PSE) methods: parametric and
nonparametric. In contrast to parametric methods, non-parametric methods
do not make any assumptions on the data-generating process or model (e.g.
autoregressive model). This paper analyzes five common non-parametric
.
(Note this definition of spectral resolution might be counter-intuitive since
one would normally expect the higher the spectral resolution, the sharper the
spectrum would be.) the exact derivation of this spectral resolution is not
important since the spectral resolutions of all other methods are derived from
this for comparison.
amplitudes of the side lobes determine the spectral masking effect. The
higher
the amplitudes of the side lobes, the more masking effect of the power
spectrum at a given frequency has on the nearby frequencies.
Table 1 shows several common truncation windows which are defined over
the finite interval
0 n
N
1, there is a trade-off between the width of the main lobe and the
amplitudes of the side lobe. Although the Rectangular Window provides the
best spectral resolution with the narrowest 3dB bandwidth for the main lobe,
it also gives the worst spectral masking effect.
By changing the truncation window, the spectral resolution is sacrificed for a
smaller spectral masking effect. The spectral resolution of the Modified
Periodogram Method depends of the truncation window.
The resolutions for the five windows are shown in Table 1. The spectral
resolution is in the form:
pW e j converges to an
impulse as N , the desirable condition
lim ( jw )( jw )
N Modified
1.3 Bartletts Method
Both the Periodogram Method and Modified Periodogram Method do not
give zero variances as the data length approaches infinity. One way to
enforce zero variance is by averaging. The Bartletts Method divides the
signal of length N into K segments, with each segment having length
L N
/K . The Periodogram Method is then applied to each of the K
segments. The average of the resulting estimated power spectra is taken as
the estimated power spectrum of the Bartletts Thus, as K , the variance
( jw )
Bartlett Var P e approaches zero. In summary, the value of K can be used to
design the trade-off between spectral resolution and
variance. With a larger number of segments, the variance is reduced but at
the expense of spectral resolution. Conversely, with a smaller number of
segments, the spectral resolution (i.e. the
bandwidth of the main lobe) is reduced at expense of larger variance.
The complexity can be analyzed by inspecting the loop structure of the
implementation. The Bartletts Method can be implemented as follows:
3) Estimate the power spectra of the K segments using the Periodogram
Method. Since the Periodogram Method is an O(n2 ) operation (as described
in Section 1.1.4) and is repeated K times, the complexity of this step is n
O(n2 ) O(n3
).
4) Compute the average of the estimates of all the segments which is an O(n)
operation.Thus, the overall complexity of the Bartletts Method is O(n3 )
O(n) O(n3
).
1.4 Welchs Method
The Welchs Method eliminates the trade off between spectral resolution and
variance in the Bartletts Method by allowing the segments to overlap.
Furthermore, the truncation window can also vary. Essentially, the Modified
Periodogram Method (instead of the Periodogram Method) is
applied to each of the overlapping segments. Mathematically, the estimated
power spectrum K is the number of segments, L is the length of each
segment, n
Each of the K segments is simply the Modified Periodogram estimate which
is asymptotically unbiased. Consequently, the estimated power spectrum (
jw )
Welch P e , which is the average of the Periodogram estimates of the K
segments, is also asymptotically unbiased. The variance of the estimated
power spectrum ( jw ) Welch P e is more difficult to compute since there is
correlation between overlapping segments. However, it is shown in [1] that
with 50% overlap
( D L 2 1 ), the variance of the estimated power spectrum ( jw )
Welch P e is about Thus, as N , the variance ( jw )
Bartlett Var P e approaches zero.
In summary, the length of each segment, L N
D(K 1) , can be used to
improve both the spectral resolution and the variance. By allowing more
overlapping (larger D), more segments (larger K) or longer segments (larger
L ) can be obtained to improve both the spectral resolution and the variance.
However, overlapping introduces correlations between segments. In practice,
the
amount of overlapping is typically between 50% to 75% [1].
The complexity can be analyzed by inspecting the loop structure of the
implementation. The
Welchs Method can be implemented as follows:
1) Estimate the power spectra of the K segments using the Modified
Periodogram Method. Since the Modified Periodogram Method is an O(n2 )
operation (as described in Section 1.2) and is repeated K times, the
complexity of this step is n O(n2 ) O(n3
).
2) Compute the average of the estimates of all the segments which is an O(n)
operation. Thus, the overall complexity of the Welchs Method is O(n3 )
O(n) O(n3
).
RESULT
Thus we have studied and compared the different non-parametric spectral
estimation techniques using MATLAB.
EX.NO:1
QUANTISATION EFFECTS
AIM:
To study the effects of aliasing and quantization.
THEORY:
Aliasing arises when a signal is discretely sampled at a rate that is
insufficient to capture the changes in the signal. Consider the following
contexts in which signals are discretely sampled:
Retinal images are sampled in space by photoreceptors.
Film and video are sampled in time by discrete frames.
Sound is commonly digitally sampled for recording and
communications.Aliasing may arise in all of these situations if sampling is
done improperly. Because the e_ects of aliasing can be rather disastrous, it is
important to understand why aliasing occurs, what its consequences are, and
how it may be avoided.
Nyquist sampling theoremThe Nyquist sampling theorem provides a
prescription for the nominal sampling in-terval required to avoid aliasing. It
may be stated simply as follows:
That this is so is really quite intuitive. Consider for example a signal
composed of a single sinewave at a frequency of 1 Hz:
If we sample this waveform at 2 Hz (as dictated by the Nyquist theorem),
that is su_cient to capture each peak and trough of the signal:If we sample at
a frequency higher than this, for example 3 Hz, then there are more than
enough samples to capture the variations in the signal:If however we sample
at a frequency lower than 2 Hz, for example at 1.5 Hz, then there are now
not enough samples to capture all the peaks and troughs in the signal:
Note here that we are not only losing information, but we are getting the
wrong infor-mation about the signal. The person receiving these samples,
without any previous knowledge of the original signal, may well be mislead
into thinking that the signal has quite a different form:
2 Effects of aliasing
2.1The wagon wheel effect
One common situation in which aliasing occurs is in _lm. This is because
continuously varying images are being discretely sampled at a rate of 24
frames/sec. The Nyquist sampling theorem tells us that aliasing will occur if
at any point in the image plane there are frequency components, or lightdark transitions, that occur faster than fs=2, which in this case is 12
frames/sec. But in many situations the light-dark transitions may be
occurring faster than this such as a wagon wheel or propeller rotating at high
speed.
Quantization
First, a bit of trivia. As you know, it is a digital computer, not a digit
computer. The information processed is called digital data, not digit data.
Why then, is analog-to-digital conversion generally called: digitize and
digitization, rather than digitalize and digitalization? The answer is nothing
you would expect. When electronics got around to inventing digital
techniques, the preferred names had already been snatched up by the medical
community nearly a century before. Digitalize and digitalization mean to
administer the heart stimulant digitalis.Notice that we carefully avoid
comparing (a) and (c), as this would lump the sampling and quantization
together. It is important that we analyze them separately because they
degrade the signal in different ways, as well as being controlled by different
parameters in the electronics. There are also cases where one is used without
the other. For instance, sampling without quantization is used in switched
capacitor filters.
RESULT:
Aim
To Study the various addressing mode of TMS320C6745 DSP
processor.
Addressing Modes
The addressing modes in TMS320C6745
1.
2.
3.
4.
register,
or
implicity,
with
instruction
that
and
then
performs
the
add
or
subtract
specified.
NEXT
NEXT NEXT.
FINISH
and add
browse the
workspace location, open the gel folder and select the GEL
file. OPEN SAVE.
9. In C/C++ Project window, Right click the project REBUILD
PROJECT.
10.
Connections :
12.
VIEW MEMORY
13.
adrress
0xC0001000
14.
TARGET RUN.
15.
TARGET HALT.
See the Output at Particular location:
0xC0000000 99CE4C0B........
Result:
The study of various addressing modes of TMS320C6745 DSP
processor was verified.
LINEAR CONVOLUTION USING TMS320C6745 DSP
Program
#include<stdio.h>
#definexn 4
#definehn 4
void main()
{
int *x,*h,*y,i,n,k;
x = (int *)0xc0001000;
h = (int *)0xc0001030;
y = (int *)0xc0001050;
for(i=0;i<(xn+hn-1);i++)
{
y[i]=0;
x[xn+i]=0;
h[hn+i]=0;
}
for(n=0;n<(xn+hn-1);n++)
{
for(k=0;k<=n;k++)
y[n] = (y[n]) + ((x[k])*(h[n-k]));
}
while(1);
}
Program
#include <math.h>
#define PI
3.14159
float x[8],t[8],s1[8],s2r[8],s2i[8],Xr[8],Xi[8],Yr[8],Yi[8];
const float W0r = 1,
W0i = 0,
W1r = 0.707,
W1i = -0.707,
W2r = 0,
W2i = -1,
W3r = -0.707,
W3i = -0.707;
void main()
{
int *Input,*Real_out,*Imag_out;
int i=0,j=0;
Input = (int *)0xC0001000;
Real_out = (int *)0xC0001030;
Imag_out = (int *)0xC0001050;
for(i=0;i<8;i++)
{
t[i] = 0;
t[i] = *(Input + i);
}
// Bit reversal process
x[0] = t[0];
x[1] = t[4];
x[2] = t[2];
x[3] = t[6];
x[4] = t[1];
x[5] = t[5];
x[6] = t[3];
x[7] = t[7];
// stage one process
Program
#include <math.h>
#define PI
3.14159
float
x[8],tr[8],ti[8],s1r[8],s1i[8],s2r[8],s2i[8],Xr[8],Xi[8],Yr[8],Yi[8]
;
const float W0r = 1,
W0i = 0,
W1r = 0.707,
W1i = -0.707,
W2r = 0,
W2i = -1,
W3r = -0.707,
W3i = -0.707;
void main()
{
int *Input,*Real_out,*Imag_out;
int i=0;
Input = (int *)0xC0001000;
Real_out = (int *)0xC0001030;
Imag_out = (int *)0xC0001050;
for(i=0;i<8;i++)
{
x[i] = 0;
x[i] = *(Input + i);
}
// stage one process
s1r[0] = (int)(x[0] + x[4]);
s1i[0] = 0;
s1r[1] = (int)(x[1] + x[5]);
s1i[1] = 0;
s1r[2] = (int)(x[2] + x[6]);
s1i[2] = 0;
s1r[3] = (int)(x[3] + x[7]);
s1i[3] = 0;
s1r[4] = (int)(x[0] - x[4]) * W0r;
s1i[4] = 0;
s1r[5] = (int)(x[1] - x[5]) * W1r;
s1i[5] = (int)(x[1] - x[5]) * W1i;
s1r[6] = 0;
s1i[6] = (int)(x[2] - x[6]) * W2i;
s1r[7] = (int)(x[3] - x[7]) * W3r;
s1i[7] = (int)(x[3] - x[7]) * W3i;
// stage two process
s2r[0] = (s1r[0] + s1r[2]);
s2i[0] = (s1i[0] + s1i[2]);
s2r[1] = (s1r[1] + s1r[3]);
s2i[1] = (s1i[1] + s1i[3]);
s2r[2] = (s1r[0] - s1r[2]) * W0r;
s2i[2] = 0; // (s1i[0] - s1i[2]) * W0i;
s2r[3] = 0; // (s1r[1] - s1r[3]) * W2r;
s2i[3] = (s1r[1] - s1r[3]) * W2i;
s2r[4] = (s1r[4] + s1r[6]);
tr[5] = Xr[5];
ti[5] = Xi[5];
tr[6] = Xr[3];
ti[6] = Xi[3];
tr[7] = Xr[7];
ti[7] = Xi[7];
// sending output array to memory location
for(i=0;i<8;i++)
{
*Real_out ++= tr[i];
*Imag_out ++= ti[i];
}
for(;;);
}
SINE WAVE GENERATION USING TMS320C6745 DSP
Program
#include<stdio.h>
#include<math.h>
#define PI 3.14
void main()
{
const float sampf = 1024000.0;// Sampling frquency is
fixed
const int inpf = 4000; // change the input frquency
from 1khz to
//8khz(1000 to 8000)
float sampt;
double teta;
short value,*sinout;
int i,count,nsamp,value1;
sinout = (short *)0xc0000000;
sampt = 1/sampf;
nsamp = sampf/inpf;
printf("\n
printf("\n
printf("\n
printf("\n
for(i=0;i<400;i++)
*(sinout+i)=0;
for(count=0;count<nsamp;count++)
{
teta = (2 * PI * inpf * sampt * count);
printf("\nteta = %lf",teta);
sin(t
value=sin(teta)*1024;//Set amplitude by
varying the value //0 to 1024
printf("\t sin %lf Value is : %d",teta,value);
value1 = value&0x0000FFFF;
*sinout++ = value1;
}}
SQUARE WAVE GENERATION USING TMS320C6745 DSP
Program
#include <stdio.h>
#include <math.h>
void main()
{
int *Square;
int i;
Square = (int *)0xC0000000;
while(1)
{
for(i=0;i<50;i++)
{
*Square++ = 0x0000FFFF;
}
for(i=0;i<50;i++)
{
*Square++ = 0x0;
}
}
}
Program
#include <stdio.h>
#include <math.h>
void main()
{
int *Triangle;
int i=0,j=0;
Triangle = (int *)0xC0000000;
while(1)
{
for(i=0;i<50;i++)
{
j=j+1;
*Triangle++ =
}
for(i=50;i>0;i--)
{
j=j-1;
*Triangle++ =
}
}
}
j;
Program
#include <stdio.h>
#include <math.h>
void main()
{
int *Sawtooth;
int i=0,j=0;
Sawtooth = (int *)0xC0000000;
while(1)
{
for(i=0;i<100;i++) //set the frequency value
{
j=j+1;
//set the amplitude value
*Sawtooth++ = j;
}
j=0;
i=0;
*Sawtooth++ = j;
}
}
Program
#include
#include
#include
#include
#include
<stdio.h>
<math.h>
"c6745.h"
"spiadc.h"
"spidac.h"
#define DAC_CS_LOW();
0x0;
//(CS=Low:Enable)
#define DAC_CS_HIGH();
0x1;
//(CS=High:Disable)
#define GAIN 0.03882011771
SPI0_SPIPC3 =
SPI0_SPIPC3 =
// setup
spiadc_cycle(spiadcbuf, 3);
// Execute
spiadc read cycle
adc_value = ((spiadcbuf[1]&0x0f) << 8)|
spiadcbuf[2];
vout = Chebyshev(adc_value);
SPI_Write(vout);
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive,j;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Clear any old data */
receive = SPI0_SPIBUF;
// Wait for transmit ready
while( SPI0_SPIBUF & 0x10000000 );
/* Write 1 byte */
SPI0_SPIDAT1 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(j=0;j<10;j++);
DAC_CS_HIGH();
}
int Chebyshev(int input)
{
int vout=0;
xv[0] = xv[1];
xv[1] = xv[2];
xv[2] = input;
yv[0] = yv[1];
yv[1] = yv[2];
yv[2] = (b0*xv[0] + b2*xv[2]) + b1 * xv[1] - (
a2 * yv[0]) - ( a1 * yv[1]);
vout = yv[2]*GAIN;
return vout;
}
Input:
Output:
Program:
#include <stdio.h>
#include <math.h>
#include "c6745.h"
#include "spiadc.h"
#include "spidac.h"
#define DAC_CS_LOW();
0x0;
//(CS=Low:Enable)
#define DAC_CS_HIGH();
0x1;
//(CS=High:Disable)
#define DCOFFSET 2711
SPI0_SPIPC3 =
SPI0_SPIPC3 =
//HP
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive,j;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Clear any old data */
receive = SPI0_SPIBUF;
// Wait for transmit ready
while( SPI0_SPIBUF & 0x10000000 );
/* Write 1 byte */
SPI0_SPIDAT1 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(j=0;j<10;j++);
DAC_CS_HIGH();
}
int Chebyshev(int input)
{
int vout=0;
xv[0] = xv[1];
xv[1] = xv[2];
xv[2] = input;
yv[0] = yv[1];
yv[1] = yv[2];
yv[2] = (b0*xv[0] + b2*xv[2]) + b1 *
xv[1] - ( a2 * yv[0]) - ( a1 * yv[1]);
vout = yv[2]*GAIN;
return vout;}
Input
output
Program
#include
#include
#include
#include
#include
#define
0x0;
#define
0x1;
<stdio.h>
<math.h>
"c6745.h"
"spiadc.h"
"spidac.h"
DAC_CS_LOW();
//(CS=Low:Enable)
DAC_CS_HIGH();
//(CS=High:Disable)
SPI0_SPIPC3 =
SPI0_SPIPC3 =
0.06107512116,
0.04746999219,
0.03375224397,
0.02072319016,
0.0090885479,
-0.000646590197,-0.008123514242,
-0.01320868172,
-0.01597031951,
-0.01663137041,
-0.01557052694,
-0.01322921738,
-0.01010407601,-0.006660183426,0.003321184311,
-0.0004065925605,
0.001853102469,
0.003353076056,
0.004079894163,
0.004117832519,
0.01060591545
};
void main( void )
{
Uint8 spiadcbuf[3];
int i,xval[120],k;
float temp,sum;
C6745_init();
spiadc_init();
spidac_init();
for(i=0;i<52;i++)
{
xval[i]=0;
}
while(1)
{
spiadcbuf[0] = 0x01;
command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
//
setup
sum = 0;
for(k=0;k<51;k++)
{
temp = (xval[k])*(h[k]);
sum = sum + temp;
}
SPI_Write(sum);
for(i=50;i>=0;i--)
{
xval[i+1] = xval[i];
}
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Clear any old data */
receive = SPI0_SPIBUF;
// Wait for transmit ready
while( SPI0_SPIBUF & 0x10000000 );
/* Write 1 byte */
SPI0_SPIDAT1 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(i=0;i<10;i++);
DAC_CS_HIGH();
}
Input:
output
Program
#include
#include
#include
#include
#include
#define
0x0;
#define
0x1;
<stdio.h>
<math.h>
"c6745.h"
"spiadc.h"
"spidac.h"
DAC_CS_LOW();
//(CS=Low:Enable)
DAC_CS_HIGH();
//(CS=High:Disable)
SPI0_SPIPC3 =
SPI0_SPIPC3 =
0.000646590197, 0.008123514242,
0.01320868172, 0.01597031951,
0.01663137041,
0.01557052694, 0.01322921738,
0.01010407601, 0.006660183426,
0.003321184311,
0.0004065925605,-0.001853102469,0.003353076056,-0.004079894163,0.004117832519,
-0.01060591545
};
void main( void )
{
Uint8 spiadcbuf[3];
int i,xval[120],k;
float temp,sum;
C6745_init();
spiadc_init();
spidac_init();
for(i=0;i<52;i++)
{
xval[i]=0;
}
while(1)
{
spiadcbuf[0] = 0x01;
command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
// setup
temp = (xval[k])*(h[k]);
sum = sum + temp;
}
SPI_Write(sum+1625);
for(i=50;i>=0;i--)
{
xval[i+1] = xval[i];
}
}
}
/****************************/
/* GLCD SPI Sent Data 8 bit */
/****************************/
void SPI_Write(unsigned short Data)
{
unsigned short receive;
DAC_CS_LOW();
Data = ( 0x3000 | Data );
/* Clear any old data */
receive = SPI0_SPIBUF;
// Wait for transmit ready
while( SPI0_SPIBUF & 0x10000000 );
/* Write 1 byte */
SPI0_SPIDAT0 = Data;
while((SPI0_SPIBUF & 0x20000000)==1);
/* Read 1 byte */
receive = SPI0_SPIBUF;
for(i=0;i<10;i++);
DAC_CS_HIGH();
}
Input
Output