-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDSP_SC.m
90 lines (71 loc) · 2.56 KB
/
DSP_SC.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function DSP_SC(msg,fs)
%------------------------- TX --------------------------%
fc = 100000;
new_fs = 5*fc;
% resampling
msg_resampled = resample(msg,new_fs,fs);
t_end = length(msg_resampled)./new_fs;
t = linspace(0,t_end, length(msg_resampled));
% modulating
carrier = cos(2*pi*fc*t);
carrier = carrier';
tx_msg = msg_resampled.*carrier;
% freq domain
TX_msg = fftshift(fft(tx_msg));
TXmsg_mg = abs(TX_msg);
N = length(tx_msg);
fvec = linspace(-new_fs/2,new_fs/2,N);
figure(3)
subplot(2,1,1)
plot(fvec,TXmsg_mg)
title('DSB-SC TX modulated msg in freq domain')
%------------------------------ RX ------------------------------%
%------------- Envelop--------------%
envelop = abs(hilbert(tx_msg));
figure(4)
subplot(2,1,1)
plot(t,envelop)
title('DSB-SC RX-Envelop msg in time domain')
% Resample
original_msg = resample(envelop,fs,new_fs);
%sound(original_msg,fs);
%observation can you make of this or which type of modulation the envelope detector can be
%used with?
%-> DSP-SC sound is distorteded
%-> envelop detector can only be used in DSB-TC, as m>1
%------------- Envelop--------------%
%--------- Coherent detection-------%
%8) changing SNR
%fc=100k
fignam = 5;
phase_error = 0;
carrier = cos(2*pi*fc*t);
carrier = carrier';
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,0,fignam,1,"DSB_SC")
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,10,fignam,2,"DSB_SC")
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,30,fignam,3,"DSB_SC")
%-> Find the error. Do you have a name for this phenomenon?
% error = 100k - 100k = 0k = 0hz
%9) changing SNR and fc
%fc=100.1k
fignam=6;
fc = 100100;
phase_error = 0;
carrier = cos(2*pi*fc*t);
carrier = carrier';
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,0,fignam,1,"DSB_SC")
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,10,fignam,2,"DSB_SC")
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,30,fignam,3,"DSB_SC")
%-> Find the error. Do you have a name for this phenomenon?
% error = 100.1k - 100k = .1k = 100hz
% distortions happens (beat effect)
%10) changing SNR and phase error
fignam = 7;
fc = 100000;
phase_error = 20;
carrier = cos(2*pi*fc*t+phase_error);
carrier = carrier';
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,0,fignam,1,"DSB_SC")
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,10,fignam,2,"DSB_SC")
DSB_SC_SSP_Coherent_Detection(tx_msg,carrier,fc,fs,new_fs,phase_error,30,fignam,3,"DSB_SC")
%---------------- Coherent detection-----------%