Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help on demodulating a signal in matlab

Status
Not open for further replies.

nearxos

Junior Member level 1
Joined
Oct 15, 2010
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,377
hello. i am having some problem on demodulating my signal maybe some one can help me
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
 

Attachments

  • demodulated.jpg
    demodulated.jpg
    34.4 KB · Views: 60
  • modulated.jpg
    modulated.jpg
    32.4 KB · Views: 59
  • unmodulated.jpg
    unmodulated.jpg
    19 KB · Views: 58

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top