nearxos
Junior Member level 1
hello. i am having some problem on demodulating my signal maybe some one can help me
below is my code
when i demodulate the signal its not the same as the original signal i created. is this normal. or am i doing something wrong
i have also attached plots for the unmodulated signal modulated and demodulated
below is my code
Code:
%% create DATA
fc=13.56E6; % carrier frequency
fm=fc/32; % modulation frequency
fs=fc*4; %sampling frequency
tb=512/fc; %time length of 1 bit
To=8*tb; %length of 8 bit
hex_string='AF'; % string in hexadecimal format
dec_string= hex2dec(hex_string); % convert hexadecimal string to decimal
input=dec2bin(double(dec_string),8); % convert decimal string to binary
dataCh=0;
for j=1:length (dec_string)
dataCh=[dataCh input(j,1:8)];
end;
dataCh=dataCh(2:length(dataCh));
input=double(dataCh)-48;
Ns=tb*fs; %The required number of sample to 1 bit
%% MANCHESTER CODING
i=1;
while i<=length(input)
switch input(i)
case 0
for j=1:2:15
output((i-1)*Ns+1+(j-1)*Ns/32:(i-1)*Ns+j*Ns/32)=4;
end
for j=2:2:16
output((i-1)*Ns+1+(j-1)*Ns/32:(i-1)*Ns+j*Ns/32)=0;
end
for j=16:32
output((i-1)*Ns+1+(j-1)*Ns/32:(i-1)*Ns+j*Ns/32)=0;
end
case 1
for j=1:16
output((i-1)*Ns+1+(j-1)*Ns/32:(i-1)*Ns+j*Ns/32)=0;
end
for j=17:2:31
output((i-1)*Ns+1+(j-1)*Ns/32:(i-1)*Ns+j*Ns/32)=4;
end
for j=18:2:32
output((i-1)*Ns+1+(j-1)*Ns/32:(i-1)*Ns+j*Ns/32)=0;
end
end
i=(i+1);
end
figure
plot(output);
axis([0 1.65E4*length(dec_string) -25 25]);
title('Unmodulated signal');
ylabel ('U [V]');
m=1; %modulation index 100%
a=4/2;
opt=a*(1-m)/(1+m);
signal = modulate(sign,fc,fs,'amdsb-tc',opt);
figure
plot(signal)
z=demod(signal,fc,fs,'amdsb-sc',opt);
figure
plot(z);
when i demodulate the signal its not the same as the original signal i created. is this normal. or am i doing something wrong
i have also attached plots for the unmodulated signal modulated and demodulated