You are on page 1of 3

Design and Simulation Lab1 M.Vinod Kumar 11EC64Q01 1.

Problem statement:
To simulate frequency modulation and demodulation and to plot the message signal, modulated signal and demodulated signal.

Program: 4 28/10/11

2. Methodology: Design:
Modulation: It is the process of changing the frequency of the carrier wave in accordance with amplitude of the message signal. The representation of the message signal is given by x(t) =Am *cos(2**fm*t). The representation of the carrier signal is given by c(t) =Ac* cos(2**fc*t). The representation of the modulated signal is given by xFM(t) =Ac*cos[2**fc*t +2**kfx(t)dt]. There are two ways by which we can generate frequency modulation 1. Direct method: In these FM is generated by applying message as input to VCO. 2. In direct method: In these we will generate phase modulated signal and then we will generate FM signal from these. Demodulator: The various ways in which we can implement fm demodulation. They are listed below. 1. Foster seeley discriminator. 2. Slope detector. 3. Ratio detector

IMPLEMENTATION:
While implementing we have to convert the continuous time equations into discrete time domain by sampling at the time instants NTs. The sampled versions of signals can be written as m[i] and c[i].

As we consider co-sinusoidal signal as modulating signal the frequency modulation equation becomes after simplification as follows

XFM (t) =Ac*cos[2**fc*t+(*2 *fm*t)] After sampling the equation becomes C[i]= Ac*cos[4**fc*t[i]+(*4* *fm*t[i])];
Slope detector is used here for demodulating FM. Slope detection demodulates FM signal by first converting the frequency variations into amplitude variations and then extracts the original signal by using envelope detector.

3. Code:
#include<stdio.h> #include<stdlib.h> #include<math.h> #define PI 3.143 #define size 1000 int main() { int Am,Ac,Fc,Fm,i,MI,f; float t[size],m[size],c[size],fm[size],y[size],d[size],x[size],z[size]; FILE *fp,*fp1,*fp2; fp=fopen("cosinewaveform.txt","w"); fp1=fopen("cosinewaveform1.txt","w"); fp2=fopen("cosinewaveform2.txt","w"); printf("\n enter the amplitude of message signal "); scanf("%d" ,&Am); printf("\n enter the amplitude of carrier signal "); scanf("%d" ,&Ac); printf("\n enter the frequency of message signal "); scanf("%d" ,&Fm); printf("\n enter the frequency of carrier signal "); scanf("%d" ,&Fc); printf("\n enter the value of modulation index "); scanf("%d",&MI); t[0]=0.0; for(i=1.0;i<size;i++) { t[i]=t[i-1]+0.000001; m[i]=Am*cos(4*PI*Fm*t[i]); fprintf(fp1,"%d %f \n",i,m[i]); c[i]= Ac* cos((4*PI*Fc*t[i])+(MI*sin(4*PI*Fm*t[i]))); y[i]= (c[i]-c[i-1])/(t[i]-t[i-1]);

d[i]= Ac* sin((4*PI*Fc*t[i])+(MI*sin(4*PI*Fm*t[i]))); x[i]= (d[i]-d[i-1])/(t[i]-t[i-1]); z[i]= .00001*sqrt((y[i]*y[i])+(x[i]*x[i])); fprintf(fp,"%d %f \n",i,c[i]); if(y[i]>0) fprintf(fp2,"%d %f \n",i,z[i]); } fclose(fp); fclose(fp1); fclose(fp2); return 0; } 4. 5.

Conclusion: Frequency modulation and demodulation are implemented. Results: The modulating signal modulated signal and demodulated signal waveforms
are shown below.

6.

You might also like