want2LearnVlsi
Newbie level 6
- Joined
- Jan 9, 2008
- Messages
- 13
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,382
Hi,
I am new to Digital Communications and MATLAB.
I am trying to implement the modulation scheme shown in the attached file <modulation_scheme.fig>.
My MATLAB code is here: <practice_comm.m> <low_pass.m>.
I could able to modulate, up-convert and down-convert the signal.
But I am facing problem in detecting 1 and 0 from y.
I am thinking of implementing an integrator to integrate the signal for every 1.5ms. If the integration value is more then it corresponds to 1. Else 0.
Whether this approach is recommended?
Please guide me what is the best way to decode the bits. Can I use any filters?
Thanks in advance.
V V
I am new to Digital Communications and MATLAB.
I am trying to implement the modulation scheme shown in the attached file <modulation_scheme.fig>.
My MATLAB code is here: <practice_comm.m> <low_pass.m>.
Code:
clc; clear all; close all;
% ----------------------------------------------------------------------
% ----------------------------- Modulator ----------------------------
databit = randint(20,1);
fc = 25000;
fs = fc * 4;
t = 0:1/fs:0.0015;
carrier = sin(2*pi*fc*t + pi);
% ----------------------------------------------------------------------
squ_msg = [];
carrier_m = [];
for i = 1 : length(databit)
if databit(i) == 0
squ = square(2*pi*(1000/1.5)*t, 66.7);
else
squ = square(2*pi*(1000/1.5)*t, 33.3);
end
squ_msg = [squ_msg squ];
carrier_m = [carrier_m carrier];
end
% To make the square wave amplitudes range from 0 to 1
for i = 1:length(squ_msg)
if squ_msg(i)~=1
squ_msg(i)=0;
end
end
% ----------------------------------------------------------------------
% up conversion
output = carrier_m .* squ_msg;
% ----------------------------------------------------------------------
% ----------------------------- Demodulator -------------------------
% down conversion
x = output .* carrier_m;
% Pass through a LPF
b = low_pass();
y = filter(b, x);
figure;
plot(y);
grid;
% Recover the bits 0 and 1 from y
Code:
function Hd = low_pass
%LOW_PASS Returns a discrete-time filter object.
%
% MATLAB Code
% Generated by MATLAB(R) 7.13 and the Signal Processing Toolbox 6.16.
%
% Generated on: 08-Mar-2013 18:41:03
%
% Equiripple Lowpass filter designed using the FIRPM function.
% All frequency values are in Hz.
Fs = 100000; % Sampling Frequency
Fpass = 2000; % Passband Frequency
Fstop = 6000; % 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});
Hd = dfilt.dffir(b);
% [EOF]
I could able to modulate, up-convert and down-convert the signal.
But I am facing problem in detecting 1 and 0 from y.
I am thinking of implementing an integrator to integrate the signal for every 1.5ms. If the integration value is more then it corresponds to 1. Else 0.
Whether this approach is recommended?
Please guide me what is the best way to decode the bits. Can I use any filters?
Thanks in advance.
V V