Sunteți pe pagina 1din 13

Scilab Manual for

Analog Communications Lab


by Prof Roopa Lakshmi G
Electronics Engineering
Mahaveer Institute Of Science And
Technology1

Solutions provided by
Ms Supriya Kadam
Others
Mumbai University/pvppcoe

December 13, 2017

1 Funded by a grant from the National Mission on Education through ICT,


http://spoken-tutorial.org/NMEICT-Intro. This Scilab Manual and Scilab codes
written in it can be downloaded from the Migrated Labs section at the website
http://scilab.in
1
Contents

List of Scilab Solutions 3

2 DSB-SC Modulator & Detector 4

6 Pre-emphasis & de-emphasis 5

7 Time Division Multiplexing & De multiplexing 6

9 Verification of Sampling Theorem 8

13 Frequency Synthesizer 9

15 PLL as FM Demodulator 11

2
List of Experiments

Solution 2.0Experiment Number 2 . . . . . . . . . . . . . . . . . . 4


Solution 6.0Experiment Number 6 . . . . . . . . . . . . . . . . . . 5
Solution 7.0Experiment Number 7 . . . . . . . . . . . . . . . . . . 6
Solution 9.0Experiment Number 9 . . . . . . . . . . . . . . . . . . 8
Solution 13.0
Experiment Number 13 . . . . . . . . . . . . . . . . . 9
Solution 15.0
Experiment Number 15 . . . . . . . . . . . . . . . . . 11

3
Experiment: 2

DSB-SC Modulator & Detector

Scilab code Solution 2.0 Experiment Number 2

1 //AIM : DSBSC M o d u l a t o r & D e t e c t o r


2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 7
4 clc ;
5 clear ;
6 t =0:0.001:1;
7 f1 = input ( e n t e r t h e b a s e b a n d s i g n a l f r e q u e n c y i n Hz
); // 10
8 f2 = input ( e n t e r t h e c a r r i e r s i g n a l f r e q u e n c y i n Hz )
; // 100
9 a =50* sin (2* %pi * f1 * t ) ;
10 b =2* sin (2* %pi * f2 * t ) ;
11 c = sin (2* %pi * f2 * t ) .* a ;
12 plot (t , c )

4
Experiment: 6

Pre-emphasis & de-emphasis

Scilab code Solution 6.0 Experiment Number 6

1 //AIM : Pree m p h a s i s & dee m p h a s i s


2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 7
4
5 clc ;
6 clear ;
7
8 r =250;
9 c =10*( -6) ;
10 f =0:100:30000000;
11 x = f *(( r ) *( -2* %pi * c ) ) ;
12
13 subplot (311)
14 plot (f , x ) ;
15
16 y = f *(( r *2* %pi ) \ c ) ;
17 subplot (312)
18 plot (f , y ) ;

5
Experiment: 7

Time Division Multiplexing &


De multiplexing

Scilab code Solution 7.0 Experiment Number 7

1 //AIM : Time D i v i s i o n M u l t i p l e x i n g & De m u l t i p l e x i n g


2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 7
4 clc ;
5 clear ;
6 N = input ( e n t e r t h e number o f s i g n a l s t o be
m u l t i p l e x e d ) ; // 2
7 f = zeros (1 , N ) ;
8 for i =1: N
9 f ( i ) = input ( e n t e r t h e f r e q u e n c y o f t h e s i g n a l ) ; // 25
p r e s s e n t e r t h e n 50
10 end
11 fs =2* max ( f ) ;
12 T = input ( e n t e r t h e d u r a t i o n o v e r which t h e s i g n a l i s
t o be p l o t t e d ) ; // 0 . 2
13 t =0: T / fs : T ;
14 Q = zeros (1 , N * length ( t ) ) ;
15 R=Q;
16 S=Q;

6
17 for i =1: N
18 Q (: ,(( i -1) * length ( t ) ) +1: i * length ( t ) ) = cos (2* %pi * f ( i )
*t);
19 end
20 j =1;
21 for i =0: N : length ( Q ) -N
22 for n =1: N
23 R ( i + n ) = Q ( j +( n -1) * length ( t ) ) ;
24 S ( j +( n -1) * length ( t ) ) = R ( i + n ) ;
25 end
26 j = j +1;
27 end
28 t1 =0: T / fs : N * T ;
29 for i = length ( t1 ) +1: length ( Q )
30 t1 ( i ) = t1 ( length ( t1 ) ) ;
31 end
32 subplot ( N +2 ,1 ,1)
33 plot ( t1 , Q )
34 title ( S i g n a l s t o be M u l t i p l e x e d )
35 subplot ( N +2 ,1 ,2)
36 plot ( t1 , R )
37 title ( M u l t i p l e x e d S i g n a l )
38 for i =1: N
39 subplot ( N +2 , 1 , i +2)
40 plot (t , S (: ,(( i -1) * length ( t ) ) +1: i * length ( t ) ) )
41 title ( Dem u l t i p l e x e d S i g n a l )
42 end

7
Experiment: 9

Verification of Sampling
Theorem

Scilab code Solution 9.0 Experiment Number 9

1 //AIM : V e r i f i c a t i o n o f S a m p l i n g Theorem
2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 7
4 clc ;
5 clear ;
6 t =0:0.001:1;
7 f = input ( e n t e r t h e b a s e b a n d s i g n a l f r e q u e n c y ) ; // 0
t o 50
8 x = sin (2* %pi * f * t ) ;
9 subplot (2 ,1 ,1)
10 plot (t , x )
11 n = input ( e n t e r t h e s a m p l i n g t i m e ) ; // l e s s t h a n
0.5
12 i =0: n :1;
13 y = sin (2* %pi * f * i )
14 subplot (2 ,1 ,2)
15 plot2d3 (i , y )

8
Experiment: 13

Frequency Synthesizer

Scilab code Solution 13.0 Experiment Number 13

1 //AIM : F r e q u e n c y s y n t h e s i z e r
2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 7
4 clc ;
5 clear ;
6 fs = 10000;
7 t = 0:1/ fs :1.5;
8 f =50;
9 x1 = squarewave (2* %pi * f * t ) ;
10 subplot (3 ,1 ,1)
11 plot (t , x1 ) ;
12 xlabel ( Time ( s e c ) ) ;
13 ylabel ( A m p l i t u d e ) ;
14 title ( S q u a r e wave i n p u t w i t h f r e q =50HZ ) ;
15 t = 0:1/ fs :1.5;
16 x2 = squarewave (2* %pi *2* f * t ) ;
17 subplot (3 ,1 ,2)
18 plot (t , x2 ) ;
19 xlabel ( Time ( s e c ) ) ;
20 ylabel ( A m p l i t u d e ) ;
21 title ( f r e q u e n c y m u l t i p l i c a t i o n by a f a c t o r o f 2 ) ;

9
22 x3 = squarewave (2* %pi * f /2* t ) ;
23 subplot (3 ,1 ,3)
24 plot (t , x3 ) ;
25 xlabel ( Time ( s e c ) ) ;
26 ylabel ( A m p l i t u d e ) ;
27 title ( f r e q u e n c y d i v i s i o n by a f a c t o r o f 2 );

10
Experiment: 15

PLL as FM Demodulator

Scilab code Solution 15.0 Experiment Number 15

1 //AIM : PLL a s FM De modu lato r .


2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 7
4 clc ;
5 clear ;
6 reg1 =0;
7 reg2 =0;
8 reg3 = 0;
9 eta = sqrt (2) /2;
10 theta =2* %pi *(1/100) ;
11 Kp = [(4* eta * theta ) /(1+2* eta * theta + theta ^2) ];
12 Ki = [(4* theta ^2) /(1+2* eta * theta + theta ^2) ];
13 d_phi_1 = 1/20;
14 n_data = 100;
15 for nn =1: n_data
16 phi1 = reg1 + d_phi_1 ;
17 phi1_reg ( nn ) = phi1 ;
18 s1 = exp ( %i *2* %pi * reg1 ) ;
19 s2 = exp ( %i *2* %pi * reg2 ) ;
20 s1_reg ( nn ) = s1 ;
21 s2_reg ( nn ) = s2 ;

11
22 t = s1 * conj ( s2 ) ;
23 phi_error = atan ( imag ( t ) / real ( t ) ) /(2* %pi ) ;
24 phi_error_reg ( nn ) = phi_error ;
25 sum1 = Kp * phi_error + phi_error * Ki + reg3 ;
26 reg1_reg ( nn ) = reg1 ;
27 reg2_reg ( nn ) = reg2 ;
28 reg1 = phi1 ;
29 reg2 = reg2 + sum1 ;
30 reg3 = reg3 + phi_error * Ki ;
31 phi2_reg ( nn ) = reg2 ;
32 end
33 subplot (321) ;
34 plot ( phi1_reg ) ;
35 subplot (322) ;
36 plot ( phi2_reg , r ) ;
37 title ( p h a s e p l o t ) ;
38 xlabel ( S a m p l e s ) ;
39 ylabel ( Phase ) ;
40 subplot (323) ;
41 plot ( phi_error_reg ) ;
42 title ( p h a s e E r r o r o f p h a s e d e t e c t o r ) ;
43 xlabel ( s a m p l e s ( n ) ) ;
44 ylabel ( Phase e r r o r ( d e g r e e s ) ) ;
45 subplot (324) ;
46 plot ( real ( s1_reg ) ) ;
47 subplot (315) ;
48 plot ( real ( s2_reg ) , r ) ;
49 title ( I n p u t s i g n a l & Output s i g n a l o f VCO ) ;
50 xlabel ( S a m p l e s ) ;
51 ylabel ( A m p l i t u d e ) ;

12

S-ar putea să vă placă și