Tuesday, 19 November 2013

DSP lab variations


DSP LAB QUESTIONS

1.        Write a MATLAB program so that output signal is sampled with a rate a) greater than twice the max frequency content in the input signal and b) for equal to maximum frequency content in the input signal. Given input signal is a cos function and the spacing between the samples is 50µs and total time duration is 0.05 seconds.
2.       Write a MATlAB program to find the system function of the causal LTI system with input x(z)= 1+2z-1+2z-2+z-3 and output y(z)= 1+z-1+2z-2+z-3 so plot input, output and impulse response.
3.       Write a MATLAB program to find convolution of unit imulse function with X(z)= 1+3z-1+4z-2 and convoluted output length is equal to sum of two input lengths-1.
4.       Write a MATLAB program to find the output of given system whose frequency response is Y(z)= X(z).H(z) and given x(n)= (1,2,3,4), h(n)= (1,2,3,4) and output length is equal to maximum length of x(n) and h(n).
5.        Write a MATLAB program to find convolution of two given sequences in time domain X1(z)= 1+2z-1+3z-2 & X2(z)= 2+z-1+4z-2 and convoluted output length is equal to sum of two input lengths minus one.
6.       Write a MATLAB program to find the similarities between the given sequence x(n)= Sin(2*pi*n/N) for N=4 and the time shifted version of same sequences in terms of convolution and write and verify a) Energy property b) periodicity property and draw the graph for the same.
7.        Write a program using MATLAB code for the received signal replected from the target is the delayed uerreon of the transmitted signal. Assume delay in two time units. Assume transmitted signal is {3, -1, 2, 1}.
8.       Write a MATLAB program to find the similarities between the two given sequence X1 (n)= [1 3 -2 1 2 -1 4 4 2] and X2(n)= [2 -1 4 1 -2 3] is its time shifted version which is shifted by two units, in terms of convolution and prove i) ϒxy[l]= ϒxy[-l] and 2) cross correlation of two sequences x(n) and y(n)= x(n-k) is having peak at the value of k.
9.       Write a MATLAB program to find the steady state response for the given difference equation y(n)-0.8y(n-1)=x(n) and x(n)= cos(0.05*pi*n); n=0 to N-1 where N=20 and plot the respective graph.
10.     Write a MATLAB program to find the first 8 samples of the complete response y(n) for the difference equation y[n]= 1/3 {x[n]+x[n-1]+x[n-2]}+0.95y[n-1]-0.9025y[n-2]; n>=0 where x(n)=cos(n*pi/3)u(n) and initial conditions are y[-1]=-2, y[-2]=-3, x[-1]=1, x[-2]=1.
11.      Write a MATLAB program to find the impulse response of a given difference equation y(n)+0.8y(n-2)+0.6y(n-3)=x(n)+0.7x(n-1)+0.5x(n-2). Plot the graph for N=20.
12.     Find steady state response using MATLAB for the difference equation y(n)-0.8y(n-1)= x(n) and x(n)= Cos(wn); n=0 to N-1 where N=20.
13.     Write a MATLAB program to find the multiplication of two frequencies domain aperiodic signals in the domain x1=[1 1 1 1] and x2=[1 2 3 4].
14.     Write a MATLAB program to find the multiplication of the two frequency domain periodic signals in time domain x1=[1 1 1 1] and x2=[1 2 3 4].
15.     Design an FIR filter for the given order of filter is 33 and cut-off frequency is 150Hz and sampling frequency is 1KHz and having stop band attenuation 21dB. Implement the same filter with assumed sinusoidal input.
16.     Write a MATLAB program to design an FIR filter is 2 and cut-off frequency is 150 and sampling frequency is 1KHz and having minimum stop band attenuation 44dB, Write a MATLAB program to implement the same filter with assumed sine input.
17.     Design an IIR filter for the pass band edge frequency w1=800 and stop band edge frequency w2=1200. sampling frequency ws=3600, passband ripple 1dB and stopband attenuation 40dB by using butterworth filter and maps it with bilinear transform. Find and plot the magnitude and frequency response. Implement with 3 various sinusoidal input signals of your own specification.

CCS PROGRAM:

18.     Linear convolution of a given sequence.
19.     Circular convolution of two sequences.
20.    Computation of N-point DFT for given value of N.
21.     Impulse response of given first order or second order filter.

Sunday, 20 October 2013

Digital Signal Processing lab interfacing programs

Digital Signal Processing lab interfacing programs...

To verify, Download C,C++ compiler from
https://www.facebook.com/groups/163904047131828/


alt+c   compile
alt+r   run
alt+f open file functions
alt+enter   exit full screen mode..

Note:1: Copy the programs and save as  filename.c  at  C:\TurboC++\Disk\TurboC3\BIN
          and directly run the programs from compiler.
         2:While running these progrms on CCStudio,Linux remove following commands from program.
                    a)#include<conio.h>
                    b)clrscr();
                    c)getch();

Expt no.1
Linear convolution


#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{

float x[15],y[15],h[15];
int i,j,m,n;
clrscr();

printf("\n Enter the value of m:");
scanf("%d",&m);
printf("\n Enter the first sequence:");
for(i=0;i<m;i++)
scanf("%f",&x[i]);

printf("\n Enter the value of n:");
scanf("%d",&n);
printf("\n Enter the second sequence:");
for(i=0;i<n;i++)
scanf("%f",&h[i]);

for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf("\n Linear convolution =%f\n",y[i]);
getch();

 }

Expt no.2
Circular convolution


#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int m,n,i,j,k;
float x[30],h[30],y[30],x2[30],a[30];
clrscr();
printf("Enter the length of the first sequence:\n");
scanf("%d",&m);
printf("Enter the first sequence:\n");
for(i=0;i<m;i++)
scanf("%f",&x[i]);
printf("Enter the length of the second sequence:\n");
scanf("%d",&n);
printf("Enter the second sequence:\n");
for(j=0;j<n;j++)
scanf("%f",&h[j]);
/*If length of both sequences are not equal*/
if(m-n!=0)
{
if(m>n) /* Pad the smaller sequence with zero*/
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++) /*folding h(n) to h(-n)*/
a[j]=h[n-j];
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" the circular convolution is\n");
for(i=0;i<n;i++)
printf("%f ",y[i]);
getch();
}


Expt no.3
N point DFT

#include <stdio.h>
#include <math.h>
#include<conio.h>

void dft(int *x, short k, float *real, float *imaginary);
float pi = 3.141592654;
float real[10],imaginary[10]; //Output results
int index=0;
int N,x[10]={0};

void main()
{
 short i,j;
 clrscr();
 printf("\nEnter the length of the input sequence:");
 scanf("%d",&N);
 printf("\nEnter the input sequence:");
 for(i=0;i<N;i++)
 scanf("%d",&x[i]);
  printf("\n The %d point DFT of sequence is \n",N);
 for (j = 0; j < N; j++)
    {
     dft(x,j,real,imaginary);                 //call DFT function
    }
}

void dft(int *x, short k, float *real, float *imaginary)  //DFT function
{
 float sumRe = 0;                        //initialize real component
 float sumIm = 0;                        //initialize imaginary component
 int i = 0;
 float cs = 0;                         //initialize cosine component
 float sn = 0;                          //initialize sine component

 for (i = 0; i < N; i++)                 //for N-point DFT
    {
      cs = cos(2*pi*(k)*i/N);           //real component
      sn = sin(2*pi*(k)*i/N);           //imaginary component
      sumRe = sumRe + x[i]*cs;        //sum of real components
      sumIm = sumIm - x[i]*sn;        //sum of imaginary components
    }
    real[index]=sumRe;
    imaginary[index]=sumIm;
 index++;

 printf("\n%f+j*%f\n",sumRe,sumIm);
 getch();
}


Expt no.4
Impulse response

#include<stdio.h>
#include<conio.h>
#define Order 2
#define Len 5

float h[Len] = {0.0,0.0,0.0,0.0,0.0},sum;

void main()
{
int j,k;
float a[Order+1] = {0.5311, 0.8622, 1.1311};
float b[Order+1] = {.2009, -0.7478, 0.5722};
clrscr();
printf("Impulse response of the given system:\n");
for(j=0;j<Len;j++)
{
sum = 0.0;
for(k=1;k<=Order;k++)
{
if((j-k)>=0)
sum = sum+(b[k]*h[j-k]);
}
if(j<=Order)
{
h[j] = a[j]-sum;
}
else
{
h[j] = -sum;
  }
printf("%f ",h[j]);
}
getch();

}




Thursday, 3 October 2013

Sunday, 29 September 2013

Smith chart


Smith chart

Smith chart is a graphical aid for solving transmission line problems very easily which would be tedious to solve by using analytical methods.




1.        Smith chart consist of resistance and reactance circles.

  r=Rl\Zo
  x=Xl\Zo
  where Zl=Rl+jXl
hence in smith chart. This process is called “normalization”.
and the ratio (Zl\Zo) is called “per unit load impedence” or “normalized impedence”.


2.       Plotting of impedence: Any complex impedence can be shown by a single point on the
               Smith chart . this point is intersection of “r=Rl\Zo” and “x=jXl\Zo”.







EXAMPLE : Let Zl = 120+j160 Ω  and Z0=400 Ω
       Normalising we get,
r=0.3
x=0.4
zl=0.3+j0.4Ω  shown on Smith chart.

                                                
                                                                  BLACK MAGIC DESIGN






3.       VSWR Determination:
With “O” as centre and OA as radius a  circle is drawn  which cuts right side of the horizontal axis at “r” value of 3.9 (shown as point B)
This gives value of VSWR = ρ = 3.9

4.       Determination of Γ in magnitude and direction:
The line oa in figure is produced to meet the outer circle at point C
The angle at point C= Ɵ=133.2° is the phase angle of reflection coefficient.
To find magnitude of  Γ , the linear scale at bottom of chart is refered  which is marked
“voltage reflection coefficient”. With O as centre and radius exactly wqual to “OA”,
An arc is cut on left side.
The value of | Γ | is read as 0.6
Therefore Γ=0.6∟133.2°

5.       Location of  Vmax  and  Vmin  : The constant ρ circle intersects the central horizontal axis at
Points D and B.
Vmax = Rmax\Zo  =rmax = 3.91
Vmin = Rmin\Zo  = rmin = 0.26

6.       Open and short circuit line:
At point F on the horizontal axis r= , x= this represents open circuit termination of line.
At point E in the horizontal axis r=0 , x=0  this represents short circuit termination of line.

7.        Movement along periphery :
Movement in clockwise direction from point E results in no of wavelengths towards generator
Movement in anti-clockwise direction from point E results in no of wavelengths towards load.
One full rotation on pheriphery corresponds to λ\2.

8.       Conversion of impedence to admittance:
To find admittance of an impedence at point a, the point a is rotated through constant S-circle
By an amount λ\4  which is equivalent to 180°.
The point yl is diametrically opposite to “A” or (zl) has a value,
yl = 1.2-j1.6.