ultraviolet_ray
Newbie level 6
Hi everyone.
I am trying to implement an Amplitude shift Keying ASK modulation and (synchronous)demodulation in Matlab,I have to use a PLL at the receiver end for demodulation.The task is to read a hexadecimal file (attached) and convert it to a binary stream. the binary stream is the modulated with a carrier frequency of 30,000 Hz. The channel is bith AWGN amd rayleigh( for wireless modelling).
well,there are no problems in the transmitter so far ( the problems start when u start detection lol)
PROBLEM: I ham having problems in PLL .
Q-1 - How do I implement a 90 degree phase shift in my received signal (ev(t))
Q-2 - Am I implementing the PLL correctly ? If not can u please guide me about any changes that should be made?
heres the Code attached:
PS: i have used a lowpas filter with cutoff 10KHz.
I am trying to implement an Amplitude shift Keying ASK modulation and (synchronous)demodulation in Matlab,I have to use a PLL at the receiver end for demodulation.The task is to read a hexadecimal file (attached) and convert it to a binary stream. the binary stream is the modulated with a carrier frequency of 30,000 Hz. The channel is bith AWGN amd rayleigh( for wireless modelling).
well,there are no problems in the transmitter so far ( the problems start when u start detection lol)
PROBLEM: I ham having problems in PLL .
Q-1 - How do I implement a 90 degree phase shift in my received signal (ev(t))
Q-2 - Am I implementing the PLL correctly ? If not can u please guide me about any changes that should be made?
heres the Code attached:
Code:
%LPF1 Returns a discrete-time filter object.
%
% M-File generated by MATLAB(R) 7.5 and the Signal Processing Toolbox 6.8.
%
% Generated on: 18-Dec-2011 15:05:07
%
% Equiripple Lowpass filter designed using the FIRPM function.
% All frequency values are in Hz.
Fs = 30000; % Sampling Frequency
Fpass = 10000; % Passband Frequency
Fstop = 11000; % Stopband Frequency
Dpass = 0.057501127785; % Passband Ripple
Dstop = 0.0001; % Stopband Attenuation
dens = 20; % Density Factor
% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fpass, Fstop]/(Fs/2), [1 0], [Dpass, Dstop]);
% Calculate the coefficients using the FIRPM function.
b = firpm(N, Fo, Ao, W, {dens});
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid=fopen('hexadecimal.txt'); %reading data from hex file
A=fscanf(fid,'%x');
A=dec2bin(A);
A=A';
A=A(:);
A=str2num(A);
A=A'; % Data sequence
T=0.0001; % Bit duration
Eb=T/2;
fc=3/T;% fc = 30000
t=linspace(0,3200,3*3200); % discrete time sequence between 0 and 5*T (1000 samples)
N=length(t); % Number of samples
Nsb=N/length(A); % Number of samples per bit
d=repmat(A',1,Nsb);
dw=d'; % Transpose the rows and columns
dw=dw(:)';
w=sqrt(2*Eb/T)*sin(2*pi*fc*t);
ask=dw.*w;
%plot(t,ask); axis([0 60 -1.5 1.5])
r=raylrnd(1:3);
con=filter(r,1,ask);
ch_ask=awgn(ask,10,'measured');
figure;
plot(ch_ask); axis([0 50 -1.5 1.5])
% Reception :
%First implementing a product modulator and alowpass filter:
%initializing
% vco_out(1)= cos(2*pi*fc*t(1)); ==>vco_out(1) =1 % fc= 30,000 initial VCO output
ev(1)=0;
vco_out(1)=1; % have assumed cosine signal as above
for i=2:250 % it should be 9600 but for avoiding time i have just calculated the initial 25 values , just need to check at first.
%prod modulator:
prod_mod(i) =ch_ask(i)*vco_out(i-1);
%lpf_out = conv(ask(i),b);%lpf filter
lpf_out = filter(b,1,ch_ask(i-1));%lpf filter
phase_detector(i)=lpf_out;
gain_output(i)= 1000*phase_detector(i);
ev(i)=gain_output(i) % the VCO input
% the VCO
vco_out(i) =cos(2*pi*fc*t(i) +sum (ev(i-1)+ev(i)));
%end
%Here should be a 90 degree phase shift.
% The Voltage comparator to compare with 0 threshold
if (ev(i)>0)
out_comparator(i) = 1;
else
out_comparator(i) = 0;
end
end
figure
plot (ev)
figure
plot(out_comparator)
PS: i have used a lowpas filter with cutoff 10KHz.