0% found this document useful (0 votes)
22 views23 pages

DC Software Manual

Uploaded by

D RAJESH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views23 pages

DC Software Manual

Uploaded by

D RAJESH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

PSCMR COLLEGE OF ENGINEERING AND TECHNOLOGY

Department of Electronics& Communication Engineering

DIGITAL COMMUNICATION SOFTWARE LAB MANUAL

Contents

List of Scilab Solutions 06

1 TIME DIVISION MULTIPLEXING AND DEMULTIPLEX-


ING
PAGE NUMBER 03-06

2 BINARY AMPLITUDE SHIFT KEYING GENERATION


AND DETECTION
PAGE NUMBER 07-09

3 BINARY PHASE SHIFT KEYING GENERATION AND


DETECTION

PAGE NUMBER 10-12

4 FREQUENCY SHIFT KEYING GENERATION AND DE-


TECTION
PAGE NUMBER 13-16

5 PULSE CODE MODULATION GENERATION AND DE-


TECTION

PAGE NUMBER 17-20

6 DELTA MODULATION GENERATION

PAGE NUMBER 21-23

1
List of Experiments

Solution 1.1 Exp01 .. . . . . . . . . . . . . . . . . . . . . . . 03


Solution 2.0 Exp02 .. . . . . . . . . . . . . . . . . . . . . . . 07
Solution 3.0 Exp03 .. . . . . . . . . . . . . . . . . . . . . . . 10
Solution 4.0 Exp04 .. . . . . . . . . . . . . . . . . . . . . . . 13
Solution 5.0 Exp05 .. . . . . . . . . . . . . . . . . . . . . . . 17
Solution 6.0 Exp06 .. . . . . . . . . . . . . . . . . . . . . . . 21

2
Experiment: 1

TIME DIVISION
MULTIPLEXING AND
DEMULTIPLEXING
14 clc;
15 close ;
16 cle ar
17 fs =100
18 t=0:1/ fs:1;
19
20 //GENERATION OF 3 MESSAGE SIGNALS FOR MULTIPLEXING
21
22 // Message S i g n a l 1
23 me ss age _ 1 = 2* sin (2* %pi *3* t ) ; // S i n e s i g n a l o f
f r e q u e n c y 3 hz
24 figure (1)
25 subplot (3 ,1 ,1)
26 plot2 d 3 (t , me ss age _ 1 )
27 xlabe l ( ’ TIME ’ ) ;
28 ylabe l ( ’AMPLITUDE ’ )
29 title ( ’MESSAGE SIGNAL 1 ( SINE WAVE) ’ );
30
31 // Message S i g n a l
32 me ss age _ 2 = 1* square wav e (2* %pi *3* t) ; // S q ua r e wa v e
s i g n a l o f f r e q u e n c y 3 hz
33 subplot (3 ,1 ,2)
34 plot2 d 3 (t , me ss age _ 2 )
35 xlabe l ( ’ TIME ’ ) ;
36 ylabe l ( ’AMPLITUDE ’ )
37 title ( ’MESSAGE SIGNAL 2 (SQUAREWAVE) ’ );
38
39 // Message S i g n a l 3
40 me ss age _ 3 = 3* cos (2* %pi *3* t) // C o s i n e s i gna l of
f r e q u e n c y 3 hz
41 subplot (3 ,1 ,3)
42 plot2 d 3 (t , me ss age _ 3 )
3
43 xlabe l ( ’ TIME ’ ) ;
44 ylabe l ( ’AMPLITUDE ’ )
45 title ( ’MESSAGE SIGNAL 3 ( COSINE WAVE) ’ );
46
47
48 // GENERATIONN OF TIME DIVISION MULTIPLEXED SIGNAL

49
50 tdm =0;
51 j =1
52
53 for i =1 :3 :3 * length ( t )
54
55 tdm ( i) = me ss age _ 1 ( j) ;
56 i= i + 1;
57 tdm ( i) = me ss age _ 2 ( j) ;
58 i= i + 1;
59 tdm ( i) = me ss age _ 3 ( j) ;
60 j= j +1
61
62 end
63
64 figure (2)
65 subplot (2 ,1 ,1)
66 plot2 d 3 ( tdm )
67 xlabe l ( ’ TIME ’ ) ;
68 ylabe l ( ’AMPLITUDE ’ )
69 title ( ’ TIME DIVISION MULTIPLEXED SIGNAL ’ );
70
71 // DEMULTIPLEXING OF TDM SIGNAL
72
73 n=1
74 for k =1:1: le ngth ( t )
75
76 m3 ( k ) = tdm ( n)
77 n=n +1;
78 m4 ( k ) = tdm ( n)
79 n=n +1;
80 m5 ( k ) = tdm ( n)
81 n=n +1;
82
83 end
4
84
85
86 figure (3)

87
88 subplot (3 ,1 ,1)
89 plot2 d 3 ( m3 )
90 xlabe l ( ’ TIME ’ ) ;
91 ylabe l ( ’AMPLITUDE ’ )
92 title ( ’DEMUX MESSAGE SIGNAL 1 ( SINE WAVE) ’ ) ;
93
94 subplot (3 ,1 ,2)
95 plot2 d 3 ( m4 )
96 xlabe l ( ’ TIME ’ ) ;
97 ylabe l ( ’AMPLITUDE ’ )
98 title ( ’DEMUX MESSAGE SIGNAL 2 (SQUAREWAVE) ’ ) ;
99
100
101 subplot (3 ,1 ,3)
102 plot2 d 3 ( m5 )
103 xlabe l ( ’ TIME ’ ) ;
104 ylabe l ( ’AMPLITUDE ’ )
105 title ( ’DEMUX MESSAGE SIGNAL 3 ( COSINE WAVE) ’ ) ;

Figure 1.1: Exp01


5
Figure 1.2: Exp01

Figure 1.3: Exp01

6
Experiment: 2

BINARY AMPLITUDE SHIFTKEYING


GENERATION
AND DETECTION

14 clc
15 cle ar
16 close
17
18 n =[0 1 0 1 0 0]; // Random b in a r y Input
19
20 // Binary to p o l a r c o n v e r s i o n o f Bi t s
21
22 for m =1: length (n )
23 if n( m ) == 0
24 nn ( m ) = -1;
25 else
26 nn ( m ) =1;
27 end
28 end
29
30
31 // Ge n e ra t in g NRZ Waveform from b i t sequence of bit
duration 1 sec
32
33 i =1;
34 t =0 :0 .01 : leng th ( n) ;
35
36 for j =1: length (t )
37 if t( j ) <= i
38 data ( j ) = nn ( i );
39 else
40
41 i= i + 1;
42 data ( j ) = nn ( i );
43

7
44 end
45
46 end
47
48 figure (1)
49 subplot (3 ,1 ,1) ;
50 plot (t , data ’)

51 h= gca ();
52 h. d at a_ bound s =[0 , -1.5; le ngth ( n) ,1.5]
53 xlabe l ( ’ TIME ’ ) ;
54 ylabe l ( ’AMPLITUDE ’ )
55 title ( ’BINARY INPUT ’ ) ;
56
57 // C a r r i e r Ge n e ra t io n
58 carrier = sin (2.* %pi *4* t) ;
59 subplot (3 ,1 ,2) ;
60 plot (t , carrier ) ;
61 xlabe l ( ’ TIME ’ ) ;
62 ylabe l ( ’AMPLITUDE ’ )
63 title ( ’ CARRIER SIGNAL ’ );
64
65
66 //AMPLITUDE SHIFT KEYING SIGNAL GENERATION
67 for j =1: length (t )
68 if data ( j) ==1
69 ask ( j ) = carrier ( j );
70 else
71 ask( j) =0;
72 end
73
74 end
75
76
77 subplot (3 ,1 ,3) ;
78 plot (t , ask ’) ;
79 xlabe l ( ’ TIME ’ ) ;
80 ylabe l ( ’AMPLITUDE ’ )
81 title ( ’AMPLITUDE SHIFT KEYING SIGNAL ’ ) ;
82
83

8
84 // De m o d u al at i o n o f ASK S i g n a l
85 for j =1: length (t )
86 if ask ( j ) == carrier ( j )
87 demod ( j) =1
88 else

89 demod ( j) =-1
90 end
91
92 end
93
94 figure (2)
95 subplot (3 ,1 ,1)
96 plot (t , demod ’)
97 xlabe l ( ’ TIME ’ ) ;
98 ylabe l ( ’AMPLITUDE ’ )
99 title ( ’DEMODULATED MESSAGE SIGNAL ’ );
100 h= gca ();
101 h. d at a_ bound s =[0 , -1.5; le ngth ( n) ,1.5 ]

9
Experiment: 3

BINARY PHASE SHIFT KEYING GENERATION


AND DETECTION

14 cle ar
15 clc
16 close
17
18 n =[1 0 1 0 1 1]; //INPUT RANDOM BINARY SEQUENCE
19
20 // BINARY TO POLAR CONVERSION
21 for m =1: le ngth ( n)
22 if n( m ) == 0
23 nn ( m ) = -1;
24 else
25 nn ( m ) =1;
26 end
27 end
28
29 // Ge n e ra t in g NRZ Waveform from b i t sequence of
bit duration 1 sec
30
31 i =1;
32 t =0 :0 .01 : leng th ( n) ;
33
34 for j =1: length (t )
35 if t( j ) <= i
36 data ( j ) = nn ( i );
37 else
38
39 i= i + 1;
40 data ( j ) = nn ( i );
41
42 end
43 end
44
45 // P l o t t i n g o f NRZ Data Waveform
46 figure (1)
47 subplot (3 ,1 ,1) ;
48 plot (t , data ’) ;
49 h= gca ();
10
50 h. d at a_ bound s =[0 , -1.5; le ngth ( n) ,1.5]

51 xlabe l ( ’ TIME ’ ) ;
52 ylabe l ( ’AMPLITUDE ’ )
53 title ( ’BINARY INPUT ’ ) ;
54
55 // C a r r i e r Ge n e ra t io n
56
57 carrier = sin (2.* %pi *2* t) ;
58 subplot (3 ,1 ,2) ;
59 plot (t , carrier ) ;
60 xlabe l ( ’ TIME ’ ) ;
61 ylabe l ( ’AMPLITUDE ’ )
62 title ( ’ CARRIER SIGNAL ’ );
63
64
65 // Ge n e ra t io n o f BPSK S i g n a l
66 z = carrier ’;
67 bpsk= data .* z;
68 subplot (3 ,1 ,3) ;
69 plot (t , bpsk ’) ;
70 xlabe l ( ’ TIME ’ ) ;
71 ylabe l ( ’AMPLITUDE ’ )
72 title ( ’BINARY PHASE SHIFT KEYING SIGNAL ’ ) ;
73
74
75 // De m od ul at ion o f BPSK S i g n a l
76 for j =1: length (t )
77 if carrier ( j) == bpsk ( j )
78 demod ( j) =1;
79 else
80 demod ( j) = -1;
81 end
82
83 end
84
85 figure (2)
86 subplot (3 ,1 ,1) ;
87 plot (t , demod ’) ;
88 xlabe l ( ’ TIME ’ ) ;

89 ylabe l ( ’AMPLITUDE ’ )

11
90 title ( ’RECOVERED BINARY DATA ’ );
91 h= gca ();
92 h. d at a_ bound s =[0 , -1.5;6 ,1.5]

Figure 3.1: Exp03

Figure 3.2: Exp03

12
Experiment: 4

FREQUENCY SHIFT
KEYING GENERATION
14 clc
15 cle ar
16 close
17
18 n =[1 0 1 0 0 1]; // Random b in a r y Input
19
20 // Binary to p o l a r c o n v e r s i o n o f Bi t s
21
22 for m =1: length (n )
23 if n( m ) == 0
24 nn ( m ) = -1;
25 else
26 nn ( m ) =1;
27 end
28 end
29
30
31 // Ge n e ra t in g NRZ Waveform from b i t sequence of bit
duration 1 sec
32
33 i =1;
34 t =0 :0 .01 : leng th ( n) ;
35
36 for j =1: length (t )
37 if t( j ) <= i
38 data ( j ) = nn ( i );
39 else
40
41 i= i + 1;
42 data ( j ) = nn ( i );
43
44 end
45
46 end
13
47
48 // P l o t t i n g o f NRZ Data
49

51 subplot (3 ,1 ,1) ;
52 plot (t , data ’) ;
53 h= gca ();
54 h. d at a_ bound s =[0 , -1.5; le ngth ( n) ,1.5]
55 xlabe l ( ’ TIME ’ ) ;
56 ylabe l ( ’AMPLITUDE ’ )
57 title ( ’BINARY INPUT ’ ) ;
58
59 // C a r r i e r Ge n e ra t io n
60 carrie r _ 1 = sin (2.* %pi *8* t ) ; // H i g h e r F r eq u e n c y
Carrier
61 subplot (3 ,1 ,2) ;
62 plot (t , car rie r_ 1 );
63 xlabe l ( ’ TIME ’ ) ;
64 ylabe l ( ’AMPLITUDE ’ )
65 title ( ’ CARRIER SIGNAL 1 ’ );
66
67 carrie r _ 2 = sin (2.* %pi *3* t ) ; // Lower F r e q u e n c y
Carrier
68 subplot (3 ,1 ,3) ;
69 plot (t , car rie r_ 2 );
70 xlabe l ( ’ TIME ’ ) ;
71 ylabe l ( ’AMPLITUDE ’ )
72 title ( ’ CARRIER SIGNAL 2 ’ );
73
74 //FSK SIGNAL GENERATION
75 for j =1: length (t )
76 if data ( j) ==1
77 fsk ( j ) = carr ie r_ 1 ( j );
78 else
79 fsk ( j ) = carr ie r_ 2 ( j );
80 end
81
82 end
83
84 figure (2)
85 subplot (3 ,1 ,1) ;
86 plot (t , fsk ’) ;
14
87 xlabe l ( ’ TIME ’ ) ;
88 ylabe l ( ’AMPLITUDE ’ )
89 title ( ’FREQUENCY SHIFT KEYING SIGNAL ’ ) ;
90
91
92 // De m o d u al at i o n o f FSK S i g n a l
93 for j =1: length (t )
94 if fsk ( j ) == carr ie r_ 1 ( j )
95 demod ( j) =1
96 else
97 demod ( j) =-1
98 end
99
100 end
101
102 figure (2)
103 subplot (3 ,1 ,2)
104 plot (t , demod ’)
105 xlabe l ( ’ TIME ’ ) ;
106 ylabe l ( ’AMPLITUDE ’ )
107 title ( ’RECOVERED BINARY DATA ’ );
108 h= gca ();
109 h. d at a_ bound s =[0 , -1.5; le ngth ( n) ,1.5]

Figure 4.1: Exp4

15
Figure 4.1: Exp4

16
Experiment: 5

PULSE CODE MODULATION


GENERATION AND
DECTION
14 clc;
15 close ;
16 cle ar ;
17 f=2;
18 fs =20* f;// Sampling Frequ enc y
19 t=0:1/ fs:2;
20 a=2;
21
22 msg = a * sin (2.* %pi * f* t) ;
23 subplot (3 ,1 ,1) ;
24 plot (t , msg )
25 xlabe l ( ’ TIME ’ ) ;
26 ylabe l ( ’AMPLITUDE ’ )
27 title ( ’ M es s a g e S i g n a l ’ );
28
29
30 x1 = msg + a ; // L e v e l S h i f t i n g t o o n e s i d e d s i g n a l
31 disp ( x1 , ’ D i s c r e t e Sam pl ed V a l u e s o f M es s a g e S i g n a l ’ )
// Di s p l a y s sampled v a l u e s
32
33 quant= round ( x1 ) ;// Qu a n t i z a t i o n
34 disp ( quant , ’ Q u a n t i z e d Sam pled V a l u e s ’ ); // D i s p l a y s
quantized values
35 enco = de c2 bin ( quant ) ; // E n c o d i n g i n t o b i nar y data
36
37
38
39 deco = bin 2 de c ( enco ) ; // R e c o v e r i n g Ana l o g Mes sa g e
signal
40 recover=deco - a;
41 subplot (3 ,1 ,2) ;
17
42 plot (t , re cover )
43 xlabe l ( ’ TIME ’ ) ;
44 ylabe l ( ’AMPLITUDE ’ )
45 title ( ’ R e c o v e r e d S i g n a l ’ );
46 h= gca ();
47 h. d at a_ bound s =[0 , -3;2 ,3]
49
50 subplot (3 ,1 ,3) ;
51 plot (t , msg ,t , re cove r , ’ r ’ );
52 xlabe l ( ’ TIME ’ ) ;
53 ylabe l ( ’AMPLITUDE ’ )
54 title ( ’ R e c o v e r e d VS O r i g i n a l S i g n a l ’ );
55 h= gca ();
56 h. d at a_ bound s =[0 , -3;2 ,3]
57
58
59 // D i s c r e t e Sampled V al ue s o f Me ssage S i g n a l
60
61
62 // column 1 to 12
63
64 // 2. 2.618034 3.1755705 3.618034 3.902113
4. 3.902113 3.618034 3.1755705
2.618034 2. 1.381966
65
66 // column 13 to 23
67
68 // 0.8244295 0.381966 0.097887 0. 0.097887
0.381966 0.8244295 1.381966 2.
2.618034 3.1755705
69
70 // column 24 to 34
71
72 // 3 . 6 1 8 0 3 4 3.902113 4. 3.902113 3.618034
3.1755705 2.618034 2. 1.381966
0.8244295 0.381966
73
74 // colu mn 35 to 46
75
76 // 0 . 0 9 7 8 8 7 0. 0.097887 0.381966 0.8244295
1.381966 2. 2.618034 3.1755705
3.618034 3.902113 4.
18
77

79
80 // 3.902113 3.618034 3.1755705 2.618034 2.
1.381966 0.8244295 0.381966 0.097887
0. 0.097887
81
82 // column 58 to 68
83
84 // 0.381966 0.8244295 1.381966 2. 2.618034
3.1755705 3.618034 3.902113 4.
3.902113 3.618034
85
86 // column 69 to 79
87
88 // 3 . 1 7 5 5 7 0 5 2.618034 2. 1.38196 6
0.8244295 0.381966 0.097887 0.
0.097887 0.381966 0.8244295
89
90 // column 80 to 81
91
92 // 1.381966 2.
93
94 // Q u a n t i z e d Sampled V al ue s
95
96
97 // column 1 to 24
98
99 // 2 . 3. 3. 4. 4. 4. 4. 4. 3. 3.
2. 1. 1. 0. 0. 0. 0. 0. 1.
1. 2. 3. 3. 4.
100
101 // column 25 to 48
102
103 // 4 . 4. 4. 4. 3. 3. 2. 1. 1. 0.
0. 0. 0. 0. 1. 1. 2. 3. 3.
4. 4. 4. 4. 4.
104
105 // column 49 to 72
106

// 3 . 3. 2. 1. 1. 0. 0. 0. 0. 0.
1. 1. 2. 3. 3. 4. 4. 4. 4.
19
4. 3. 3. 2. 1.

// column 73 to 81

// 1. 0. 0. 0. 0. 0. 1. 1. 2.

Figure 5.1: Exp5

20
Experiment: 6

DELTA MODULATION
GENERATION

14 clc
15 clear
14 close
17
18 am = input ( ’ E n t e r t h e m e s s a g e s i g n a l a m p l i t u d e = ’ );
19 fm = input ( ’ E n t e r t h e m e s s a g e s i g n a l f r e q u e n c y = ’ );
20 // Hig h e r Sa m plig Fre q ue nc y gives better recovery of
me ss age S i g n a l
21 fs = input ( ’ E n t e r t h e s a m p l i n g f r e q u e n c y ( 5 0 − 3 0 0 ) = ’ );
22 t=0:1/ fs:1;
23
24 msg = am * sin (2.* %pi * fm * t );
25 p= le ngth ( msg ) ;
26
27 subplot (3 ,1 ,1)
28 plot (t , msg ) ;
29 title ( ’ M es s a g e S i g n a l ’ );
30 xlabe l ( ’ TIME ’ ) ;
31 ylabe l ( ’ A m pli t u d e ’ ) ;
32
33 de lta = (2.* %pi * am * fm ) / fs ; //To p r e v e n t slope overload
d i s t o r t i o n and Gran ual ar No i s e
34 disp ( delta , ’ The S t e p S i z e i s ’ )
35
36
37 // Ge n e ra t io n o f De l ta M o d u l at i o n
38 de lta_ mo d =0
39 for i =1: p
40 if msg ( i ) > de lt a_ mo d ( i)
41 d( i) =1;
42 de lta_ mo d ( i + 1) = de lt a_ mo d ( i) + de lta ;
21
43 else
44 d( i) =0;
45 de lta_ mo d ( i + 1) = de lt a_ mo d ( i) - de lta ;
46 end
47 end
48
49
50 subplot (3 ,1 ,2)

51 title ( ’ D e l t a M o d ula t e d Output ’ ) ;


52 xlabe l ( ’ TIME ’ ) ;
53 ylabe l ( ’AMPLITUDE ’ ) ;
55
56
57 // Rec ov ery o f Me ssage s i g n a l ( De m o dul at io n )
58 demod =0
59 for i =1: p
60 if d( i) = =1;
61
62 de mod ( i +1) = de lta_ m od ( i )+ de lta ;
63 else
64
65 de mod ( i +1) = de lta_ m od ( i ) - de lta ;
66 end
67 end
68
69 subplot (3 ,1 ,3)
70 plot ( de mod );
71 title ( ’RECOVERED MESSAGE SIGNAL ’ );
72 xlabe l ( ’ TIME ’ ) ;
73 ylabe l ( ’AMPLITUDE ’ ) ;
74
75 // Sample In p u t s f o r program
76 // Enter the me ss age s i g n a l a m p l i t u d e =2
77
78 // Ente r the me ss age s i g n a l f r e q u e n c y =4
79
80 // Ent e r the s a mp l i n g f r e q u e n c y (50 − 300 ) =150
81
82
83 // The Ste p Size is

22
84
85 // 0 . 3 3 5 1 0 3 2

Figure 6.1: Exp6

23

You might also like