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.

designing 2 bandpass filters in matlab to be used in fpga

Status
Not open for further replies.

fena

Newbie level 3
Joined
Nov 24, 2009
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
turkey
Activity points
1,349
hi to all. i have a project in which I have to demodulate a fsk-modulated signal that comes from a adc which samples at 5mHzin fpga. to do that, I have to design two bandpass filters at 690 kHz and 710 kHz. Now I am trying to simulate it in matlab to make sure it works. this is my code:
close all;
%clear;
% find the period of the transmitted sine waves in ns
period_of_710 = ceil(1000000000/710000);% ns
period_of_690 = ceil(1000000000/690000);% ns

% create a 1 period signal of each waveform perhaps for some filtering
%operations
s690KHZ = sin([2*pi/period_of_690:2*pi/period_of_690:2*pi]);
s710KHZ = sin([2*pi/period_of_710:2*pi/period_of_710:2*pi]);

figure, plot(s690KHZ);
figure, plot(s710KHZ);


% create a band filter for each waveform
bp_690 = ones(1,length(s690KHZ));
bp_710 = ones(1,length(s710KHZ));
lp_dum = ones(1,100);
figure, plot(bp_690);


% the duration of each symbol at the time of transmission in ns
sym_period = 10000;


% create a pattern to be transmitted that is made of 1's and 0's
input = [1 0 0 1 1 0 1];

% now create the symbols for transmitting 1 and 0. e.g. if you want to
% transmit a 1 then you have to transmit a 690 KHz sine wave in sym_period
% of time length
tx_1 = sin([2*pi/period_of_690:2*pi/period_of_690:2*pi*sym_period/period_of_690]+0.75*pi);
tx_0 = sin([2*pi/period_of_710:2*pi/period_of_710:2*pi*sym_period/period_of_710]+0.75*pi);
%tx_1 = sin([2*pi*(710/2500)/period_of_690:2*pi*(710/2500)/period_of_690:2*pi*(710/2500)*sym_period/period_of_690]+0.75*pi);
%tx_0 = sin([2*pi/period_of_710*(690/2500):2*pi/period_of_710*(690/2500):2*pi*(690/2500)*sym_period/period_of_710]+0.75*pi)

figure, plot(tx_1);
figure, plot(tx_0);

% create the final transmitted wave by looking at the "input" register
for ii = 1:length(input)
if input(ii) == 1
tx((ii-1)*sym_period+1 : ii*sym_period) = tx_1;
else
tx((ii-1)*sym_period+1 : ii*sym_period) = tx_0;
end
end

figure,plot(tx);

%create a noise pattern.
noise = sqrt(0)*randn(1,length(tx));


% written for matched filtered
% filter_690 = imfilter(tx,s690KHZ);
% filter_710 = imfilter(tx,s710KHZ);

% obtain the received signal by adding the noise to the transmitted signal
rx = tx+noise;

% band-pass filter the incoming signal
%filter_690 = imfilter(rx,bp_690);
%filter_710 = imfilter(rx,bp_710);
filter_690 = filter(Hd0,rx);
filter_710 = filter(Hd1,rx);
figure,plot(filter_690);
title('filter_ 690');
figure,plot(filter_710);
title('filter_ 710');

% apply matched filter to the band-passed signal.
%matched_690 = imfilter(filter_690,s690KHZ);
%matched_710 = imfilter(filter_710,s710KHZ);


% written for the power matched filtered wave
% filter_690_kare = filter_690.*filter_690;
% filter_710_kare = filter_710.*filter_710;

%observe the power of the filtered waveform
%filter_690_kare = matched_690.*matched_690;
%filter_710_kare = matched_710.*matched_710;
filter_690_kare = filter_690.*filter_690;
filter_710_kare = filter_710.*filter_710;
figure,plot(filter_690_kare);

when I use "imfilter" function It works properly (the signal is processed well) but when I try to use a filters designed in fdatool (Hd0 and Hd1 in this case), it doesnt work. I dont understand why. I am sure it is not about the order of the filters. I have to see it working with filters because I will have to use these filters' coefficents in fpga.
these are the properties of the filters that I designed in fdatool:
order:128,
fir least-squares
PersistentMemory: 0
NumSamplesProcessed: 0
FilterStructure: 'Direct-Form FIR'
States: [128x1 embedded.fi]
Numerator: [1x129 double]
Arithmetic: 'fixed'
CoeffWordLength: 8
CoeffAutoScale: 1
Signed: 1
RoundMode: 'convergent'
OverflowMode: 'wrap'
InputWordLength: 8
InputFracLength: 15
NumFracLength: 14
FilterInternals: 'FullPrecision'
OutputWordLength: 21
OutputFracLength: 29
ProductWordLength: 15
ProductFracLength: 29
AccumWordLength: 21
AccumFracLength: 29
sampling freq: 5MHz
for 710 KHz:
fstop1: 700kHz
fpass1: 706kHz
fpass2:715kHz
fstop2:720kHz

for 690 KHz :
fstop1: 680kHz
fpass1: 685kHz
fpass2:695kHz
fstop2:700kHz

any help will be very appreciated.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top