Browse Source

Band pass output init, Minor fixes

master
Apostolos Fanakis 6 years ago
parent
commit
4f2a024d79
  1. 147
      Band Pass Chebyshev/band_pass_design.m
  2. 2
      High Pass Butterworth/high_pass_design.m
  3. 14
      Low Pass Inverse Chebyshev/low_pass_design.m

147
Band Pass Chebyshev/band_pass_design.m

@ -45,16 +45,29 @@ specification_high_stop_radial_frequency = 2*pi* ...
specification_min_stop_attenuation = 28+AEM(4)*5/9; % dB specification_min_stop_attenuation = 28+AEM(4)*5/9; % dB
specification_max_pass_attenuation = 0.5+AEM(3)/36; % dB specification_max_pass_attenuation = 0.5+AEM(3)/36; % dB
% Outputs results
fprintf(['\n' '===== DESIGN SPECIFICATIONS =====' '\n' ...
'Filter design specifications:\n' ...
'Central frequency = %.3fHz = %.3frad/s\n' ...
'Low pass frequency = %.3fHz = %.3frad/s\n' ...
'High pass frequency = %.3fHz = %.3frad/s\n' ...
'Low stop frequency = %.3fHz = %.3frad/s\n' ...
'High stop frequency = %.3fHz = %.3frad/s\n' ...
'Min stop attenuation = %.3fdB\n' ...
'Max pass attenuation = %.3fdB\n'], ...
specification_central_frequency, specification_central_radial_frequency, ...
specification_low_pass_frequency, ...
specification_low_pass_radial_frequency, ...
specification_high_pass_frequency, ...
specification_high_pass_radial_frequency, ...
specification_low_stop_frequency, ...
specification_low_stop_radial_frequency, ...
specification_high_stop_frequency, ...
specification_high_stop_radial_frequency, ...
specification_min_stop_attenuation, specification_max_pass_attenuation);
clear design_param_D clear design_param_D
%{
specification_low_pass_radial_frequency = 500; % rad/s
specification_high_pass_radial_frequency = 800; % rad/s
specification_low_stop_radial_frequency = 400; % rad/s
specification_high_stop_radial_frequency = 1000; % rad/s
specification_min_stop_attenuation = 18; % dB
specification_max_pass_attenuation = 0.5; % dB
%}
% ========== DESIGN SPECIFICATIONS END ========== % ========== DESIGN SPECIFICATIONS END ==========
%% ========== PROTOTYPE LOW PASS DESIGN SPECIFICATIONS START ========== %% ========== PROTOTYPE LOW PASS DESIGN SPECIFICATIONS START ==========
@ -80,6 +93,24 @@ design_geometric_central_radial_frequency = ...
design_filter_bandwidth = specification_high_pass_radial_frequency- ... design_filter_bandwidth = specification_high_pass_radial_frequency- ...
specification_low_pass_radial_frequency; % rad/s specification_low_pass_radial_frequency; % rad/s
% Outputs results
fprintf(['\n' '===== PROTOTYPE LOW PASS DESIGN SPECIFICATIONS =====' '\n' ...
'The prototype low pass filter will be designed with the\n' ...
'normalized stop radial frequency %.3frad/s, the normalized\n' ...
'pass radial frequency is equal to 1rad/s.\n' ...
'Min and max attenuation specifications remain the same.\n' ...
'\nThe filter bandwidth and geometric central frequency are also\n' ...
'calculated for later usage:\n' ...
'Filter bandwidth = %.3fHz = %.3frad/s\n' ...
'Geometric central frequency = %.3fHz = %.3frad/s\n' ...
'\nThe central frequency calculated is equal to the one given\n' ...
'in the specifications part, confirming the specifications\n' ...
'where calculated correctly.\n'], ...
prototype_normalized_stop_radial_frequency, ...
design_filter_bandwidth/(2*pi), design_filter_bandwidth, ...
design_geometric_central_radial_frequency/(2*pi), ...
design_geometric_central_radial_frequency);
% ========== PROTOTYPE LOW PASS DESIGN SPECIFICATIONS END ========== % ========== PROTOTYPE LOW PASS DESIGN SPECIFICATIONS END ==========
%% ========== PROTOTYPE LOW PASS DESIGN START ========== %% ========== PROTOTYPE LOW PASS DESIGN START ==========
@ -89,10 +120,11 @@ design_filter_bandwidth = specification_high_pass_radial_frequency- ...
% Designs the prototype normalized filter. % Designs the prototype normalized filter.
% Calculates the filter's order using the eq. 9-83 % Calculates the filter's order using the eq. 9-83
design_filter_order = ceil(acosh(((10^ ... temp_filter_order = acosh(((10^ ...
(specification_min_stop_attenuation/10)-1)/(10^ ... (specification_min_stop_attenuation/10)-1)/(10^ ...
(specification_max_pass_attenuation/10)-1))^(1/2))/ ... (specification_max_pass_attenuation/10)-1))^(1/2))/ ...
acosh(prototype_normalized_stop_radial_frequency)); acosh(prototype_normalized_stop_radial_frequency);
design_filter_order = ceil(temp_filter_order);
% Calculates epsilon parameter using the eq. 9-76 % Calculates epsilon parameter using the eq. 9-76
epsilon_parameter = sqrt(10^(specification_max_pass_attenuation/10)-1); epsilon_parameter = sqrt(10^(specification_max_pass_attenuation/10)-1);
@ -102,7 +134,8 @@ alpha_parameter = asinh(1/epsilon_parameter)/design_filter_order;
% Calculates the frequency at which half power occurs using the eq. 9-80 % Calculates the frequency at which half power occurs using the eq. 9-80
% TODO: denormalize!! ====================%%%%%%%%%%%%%%%%%%%%%%%%============================ % TODO: denormalize!! ====================%%%%%%%%%%%%%%%%%%%%%%%%============================
design_half_power_radial_frequency = cosh(acosh(( ... design_half_power_radial_frequency = cosh(acosh(( ...
10^(specification_max_pass_attenuation/10-1))^(-1/2))/design_filter_order); % rad/s 10^(specification_max_pass_attenuation/10-1))^(-1/2))/ ...
design_filter_order); % rad/s
% ----- % -----
% Calculates stable poles, zeros, angles and other characteristic sizes % Calculates stable poles, zeros, angles and other characteristic sizes
@ -166,9 +199,33 @@ else % Even number of poles
end end
end end
% Outputs results
fprintf(['\n' '===== PROTOTYPE LOW PASS DESIGN =====' '\n' ...
'A prototype low pass Chebyshev filter is designed with the\n' ...
'specifications previously calculated.\n\n' ...
'Filter order = %.3f\n' ...
'Filter order ceiling = %d\n' ...
'Epsilon parameter = %.3f\n' ...
'Alpha parameter = %.3f\n' ...
'Radial frequency at which half power occurs = %.3frad/s\n' ...
'Butterworth angles are ' char(177) '%.2f' char(176) ' and ' ...
char(177) '%.2f' char(176) '\n'], ...
temp_filter_order, design_filter_order, ...
epsilon_parameter, alpha_parameter, ...
design_half_power_radial_frequency, design_butterworth_angles(1,1), ...
design_butterworth_angles(1,2));
fprintf('\nLow pass Chebyshev poles found:\n');
for i=1:prototype_number_of_poles
fprintf(['Pole %d:\t' '%.3f' char(177) ...
'%.3fi\n'], ...
i, prototype_poles_real_parts(1,i), ...
prototype_poles_imaginary_parts(1,i));
end
% Clears unneeded variables from workspace % Clears unneeded variables from workspace
clearVars = {'prototype_normalized_stop_radial_frequency', ... clearVars = {'prototype_normalized_stop_radial_frequency', ...
'epsilon_parameter', 'alpha_parameter', 'theta'}; 'epsilon_parameter', 'alpha_parameter', 'theta', 'temp_filter_order'};
clear(clearVars{:}) clear(clearVars{:})
clear clearVars clear clearVars
@ -257,6 +314,26 @@ for i=1:prototype_number_of_poles
end end
end end
% Outputs results
fprintf(['\n' '===== HIGH PASS TO BAND PASS TRANSFORMATION =====' '\n' ...
'The low pass Chebyshev filter is transformed into a band pass\n' ...
'Chebyshev using the Geffe algorithm to transform the poles.\n']);
fprintf('\nBand pass Chebyshev poles found:\n');
for i=1:band_pass_number_of_poles
fprintf(['Pole %d:\t' 'radial frequency = %.3f, Q = %.3f, angle = ' ...
char(177) '%.2f' char(176) '\n'], ...
i, band_pass_poles_radial_frequencies(1,i), ...
band_pass_poles_Q(1,i), ...
band_pass_poles_angle(1,i));
end
fprintf('\nTransfer function zeros:\n');
for i=1:length(band_pass_transfer_function_zeros)
fprintf(['Zero %d:\t' '0%+.3fi\n'], ...
i, band_pass_transfer_function_zeros(1,i));
end
% Clears unneeded variables from workspace % Clears unneeded variables from workspace
clearVars = {'prototype_number_of_poles', 'i', 'temp_index', ... clearVars = {'prototype_number_of_poles', 'i', 'temp_index', ...
'prototype_poles_imaginary_parts', 'prototype_poles_real_parts'}; 'prototype_poles_imaginary_parts', 'prototype_poles_real_parts'};
@ -332,7 +409,7 @@ for i=1:band_pass_number_of_poles
% Calculates the gain at the central radial frequency and the alpha % Calculates the gain at the central radial frequency and the alpha
% parameter using the eq. 7-89 % parameter using the eq. 7-89
units_central_frequency_gain(1,i) = 2*band_pass_poles_Q(1,i)^2; units_central_frequency_gain(1,i) = 2*band_pass_poles_Q(1,i)^2;
%units_alpha(1,i) = 1/units_central_frequency_gain(1,i); units_alpha(1,i) = 1/units_central_frequency_gain(1,i);
% 11-58 % 11-58
units_filter_central_frequency_gain(1,i) = sqrt((2*band_pass_poles_Q(1,i)* ... units_filter_central_frequency_gain(1,i) = sqrt((2*band_pass_poles_Q(1,i)* ...
@ -372,6 +449,39 @@ for i=1:band_pass_number_of_poles
design_geometric_central_radial_frequency); design_geometric_central_radial_frequency);
end end
% Outputs results
fprintf(['\n' '===== UNITS IMPLEMENTATION =====' '\n' ...
'Units implementation details:\n']);
for i=1:band_pass_number_of_poles
fprintf(['Unit %d:\n' ...
'\tPole radial frequency = %.3f\n'...
'\tPole Q = %.3f\n' ...
'\tTransfer function zero = 0%+.3fi\n' ...
'\tUnit bandwidth = %.3fHz = %.3frad/s\n' ...
'\tCircuit elements:\n' ...
'\t\tZ2 = %.3fOhm\n' ...
'\t\tZ3 = %.3fOhm\n' ...
'\t\tR2 = %.3fOhm\n' ...
'\t\tC21 = %.7fF\n' ...
'\t\tC22 = %.7fF\n'], ...
i, band_pass_poles_radial_frequencies(1,i), ...
band_pass_poles_Q(1,i), ...
band_pass_transfer_function_zeros(1,i), ...
units_BW(1,i)/(2*pi), units_BW(1,i), units_Z2(1,i), ...
units_Z3(1,i), units_R2(1,i), units_C21(1,i), units_C22(1,i));
end
% Clears unneeded variables from workspace
clearVars = {'units_central_frequency_gain', 'i', 'units_alpha', ...
'unit_denominator', 'unit_numerator', 'unit_Z_parallel' ...
'units_amplitude_scale_factors', 'units_frequency_scale_factors'};
clear(clearVars{:})
clear clearVars
% ========== UNITS IMPLEMENTATION END ==========
%% ========== TRANSFER FUNCTIONS START ==========
%{ %{
total_gain = units_filter_central_frequency_gain(1,1)* ... total_gain = units_filter_central_frequency_gain(1,1)* ...
units_filter_central_frequency_gain(1,2)* ... units_filter_central_frequency_gain(1,2)* ...
@ -391,7 +501,7 @@ total_transfer_function = series(series(series( ...
%ltiview(total_transfer_function); %ltiview(total_transfer_function);
% %{
plot_transfer_function(total_transfer_function, ... plot_transfer_function(total_transfer_function, ...
[specification_low_stop_frequency ... [specification_low_stop_frequency ...
specification_low_pass_frequency ... specification_low_pass_frequency ...
@ -399,14 +509,9 @@ plot_transfer_function(total_transfer_function, ...
941.83 ... 941.83 ...
specification_high_pass_frequency ... specification_high_pass_frequency ...
specification_high_stop_frequency]); specification_high_stop_frequency]);
% %}
% Clears unneeded variables from workspace % Clears unneeded variables from workspace
clearVars = {'units_central_frequency_gain', 'i', 'units_alpha', ...
'unit_denominator', 'unit_numerator', 'unit_Z_parallel' ...
'units_amplitude_scale_factors', 'units_frequency_scale_factors'};
clear(clearVars{:})
clear clearVars
clear -regexp _transfer_function$ clear -regexp _transfer_function$
% ========== UNITS IMPLEMENTATION END ========== % ========== TRANSFER FUNCTIONS END ==========

2
High Pass Butterworth/high_pass_design.m

@ -2,7 +2,7 @@
%% $DATE : 16-Aug-2018 19:23:40 $ %% $DATE : 16-Aug-2018 19:23:40 $
%% $Revision : 1.00 $ %% $Revision : 1.00 $
%% DEVELOPED : 9.0.0.341360 (R2016a) %% DEVELOPED : 9.0.0.341360 (R2016a)
%% FILENAME : band_pass_design.m %% FILENAME : high_pass_design.m
%% AEM : 8261 %% AEM : 8261
%% %%
%% ========== DESIGN SPECIFICATIONS START ========== %% ========== DESIGN SPECIFICATIONS START ==========

14
Low Pass Inverse Chebyshev/low_pass_design.m

@ -1,10 +1,10 @@
% AUTHOR : Apostolos Fanakis %% AUTHOR : Apostolos Fanakis
% $DATE : 02-May-2018 17:21:18 $ %% $DATE : 02-May-2018 17:21:18 $
% $Revision : 1.00 $ %% $Revision : 1.00 $
% DEVELOPED : 9.0.0.341360 (R2016a) %% DEVELOPED : 9.0.0.341360 (R2016a)
% FILENAME : low_pass_design.m %% FILENAME : low_pass_design.m
% AEM : 8261 %% AEM : 8261
%%
%% ========== DESIGN SPECIFICATIONS START ========== %% ========== DESIGN SPECIFICATIONS START ==========
% Figures out design specifications according to my AEM number % Figures out design specifications according to my AEM number

Loading…
Cancel
Save