Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HDL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
7ba59b0e
Commit
7ba59b0e
authored
Nov 8, 2016
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Automated search for half power bandwidth adjustment hp_factor.
parent
08759cbd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
applications/apertif/matlab/run_pfir_coeff.m
+42
-24
42 additions, 24 deletions
applications/apertif/matlab/run_pfir_coeff.m
with
42 additions
and
24 deletions
applications/apertif/matlab/run_pfir_coeff.m
+
42
−
24
View file @
7ba59b0e
...
@@ -41,8 +41,11 @@
...
@@ -41,8 +41,11 @@
% to choose fir1.
% to choose fir1.
% - The half power channel bandwidth is adjusted via hp_factor to have
% - The half power channel bandwidth is adjusted via hp_factor to have
% flat power gain between channels. The hp_factor depends on L and
% flat power gain between channels. The hp_factor depends on L and
% r_pass. The hp_factor was determined empirically by rerunning this
% r_pass. The hp_factor is determined automatically when hp_search =
% script for different values and .
% true. For floating point coeff_w=0 the hp_factor can achieve an
% arbitrary accurate solution. For fixed point coeff_w>0 the solution
% can only be as good as possible, so then decreasing hp_resolution
% does not change the coeff anymore.
% - For fircls1 the passband ripple and stopband ripple can be specified.
% - For fircls1 the passband ripple and stopband ripple can be specified.
% For fir1 the passband is flat and the stopband attenuation increases
% For fir1 the passband is flat and the stopband attenuation increases
% more and more for more distant frequencies. The fir1 can achieve
% more and more for more distant frequencies. The fir1 can achieve
...
@@ -66,7 +69,9 @@ application = 'apertif_subband'; % calculate Apertif subband filterbank coeff
...
@@ -66,7 +69,9 @@ application = 'apertif_subband'; % calculate Apertif subband filterbank coeff
%% - Application specific settings
%% - Application specific settings
% Default settings
% Default settings
hp_factor
=
1
;
% no channel half power bandwidth adjustment
hp_factor
=
1
;
hp_search
=
false
;
hp_search
=
true
;
% enable automatic channel half power bandwidth adjustment
if
strcmp
(
application
,
'test_bypass'
)
if
strcmp
(
application
,
'test_bypass'
)
N
=
64
;
N
=
64
;
L
=
8
;
L
=
8
;
...
@@ -105,38 +110,51 @@ else
...
@@ -105,38 +110,51 @@ else
if
strcmp
(
config
.
design
,
'fir1'
)
if
strcmp
(
config
.
design
,
'fir1'
)
r_pass
=
0
;
% not used for fir1
r_pass
=
0
;
% not used for fir1
r_stop
=
0
;
% not used for fir1
r_stop
=
0
;
% not used for fir1
% Set channel half power bandwidth adjustment hp_factor (determined empirically)
if
L
==
16
,
hp_factor
=
1.049922
;
end
if
L
==
8
,
hp_factor
=
1.10073
;
end
if
L
==
4
,
hp_factor
=
1.2
;
end
else
% fircls1
else
% fircls1
% Pass and stop band deviation for fircls1
% Pass and stop band deviation for fircls1
r_pass
=
1e-4
;
% choose 0.0001 to have more flat reponse between channels
r_pass
=
1e-4
;
% choose 0.0001 to have more flat reponse between channels
% for 0.001 it is better to choose fir1
% for 0.001 it is better to choose fir1
r_stop
=
1e-4
;
% choose 0.0001 to avoid artefact at ends of impulse response
r_stop
=
1e-4
;
% choose 0.0001 to avoid artefact at ends of impulse response
% that occur for 0.001
% that occur for 0.001
% Set channel half power bandwidth adjustment hp_factor (determined empirically)
if
r_pass
==
1e-3
% Config parameters that are specific for fircls1
if
L
==
16
,
hp_factor
=
1.054992
;
end
if
L
==
8
,
hp_factor
=
1.1138
;
end
if
L
==
4
,
hp_factor
=
1.24
;
end
elseif
r_pass
==
1e-4
if
L
==
16
,
hp_factor
=
1.055837
;
end
if
L
==
8
,
hp_factor
=
1.1154
;
end
if
L
==
4
,
hp_factor
=
1.205
;
end
end
% config parameters that are specific for fircls1
%config.design_flag = 'trace';
%config.design_flag = 'trace';
config
.
design_flag
=
''
;
config
.
design_flag
=
''
;
%config.interpolate = 'resample';
%config.interpolate = 'resample';
%config.interpolate = 'fourier';
%config.interpolate = 'fourier';
config
.
interpolate
=
'interpft'
;
config
.
interpolate
=
'interpft'
;
end
end
% Adjust channel half power bandwidth, so need db(sqrt(2)) = -3 dB gain instead of half gain
% Optional FIR filter bandwidth adjust
if
hp_search
==
false
% No channel half power bandwidth adjustment
BWchan
=
hp_factor
/
N
;
BWchan
=
hp_factor
/
N
;
% Calculate the FIR coefficients
% Calculate the FIR coefficients
coeff
=
pfir_coeff
(
N
,
L
,
BWchan
,
r_pass
,
r_stop
,
coeff_w
,
config
);
coeff
=
pfir_coeff
(
N
,
L
,
BWchan
,
r_pass
,
r_stop
,
coeff_w
,
config
);
else
% Automatically adjust channel half power bandwidth, so need db(sqrt(2)) = -3 dB gain instead of half gain
hp_radix
=
2
;
% choose 2 for binary search, or 10 for 'decimal' search
hp_step
=
1
/
hp_radix
;
hp_resolution
=
0.000001
;
while
true
BWchan
=
hp_factor
/
N
;
coeff
=
pfir_coeff
(
N
,
L
,
BWchan
,
r_pass
,
r_stop
,
coeff_w
,
config
);
hf_abs
=
abs
(
fftshift
(
fft
(
coeff
/
sum
(
coeff
),
N
*
L
)));
fi_0
=
N
*
L
/
2
+
1
;
% frequency index of center of channel, so 0 Hz
fi_p
=
fi_0
+
L
/
2
;
% frequency index of edge of channel at +f_chan/2
hf_abs_p
=
hf_abs
(
fi_p
);
% gain edge of channel at +f_chan/2
disp
(
sprintf
(
'hp_factor = %10.8f, hf_abs_p = %10.8f, hp_step = %10.8f\n'
,
hp_factor
,
hf_abs_p
,
hp_step
));
if
hf_abs_p
<
sqrt
(
0.5
)
hp_factor
=
hp_factor
+
hp_step
;
else
if
hp_step
<=
hp_resolution
,
break
;
end
hp_factor
=
hp_factor
-
hp_step
;
hp_step
=
hp_step
/
hp_radix
;
hp_factor
=
hp_factor
+
hp_step
;
end
end
end
end
end
NL
=
N
*
L
;
% Total number of FIR filter coefficients (taps)
NL
=
N
*
L
;
% Total number of FIR filter coefficients (taps)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment