From 4f2a024d79ad5a897ac710501fc0b13941ff35ed Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sat, 18 Aug 2018 13:43:12 +0300 Subject: [PATCH] Band pass output init, Minor fixes --- Band Pass Chebyshev/band_pass_design.m | 147 ++++++++++++++++--- High Pass Butterworth/high_pass_design.m | 2 +- Low Pass Inverse Chebyshev/low_pass_design.m | 14 +- 3 files changed, 134 insertions(+), 29 deletions(-) diff --git a/Band Pass Chebyshev/band_pass_design.m b/Band Pass Chebyshev/band_pass_design.m index e5b1782..901b6a5 100644 --- a/Band Pass Chebyshev/band_pass_design.m +++ b/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_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 -%{ -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 ========== %% ========== PROTOTYPE LOW PASS DESIGN SPECIFICATIONS START ========== @@ -80,6 +93,24 @@ design_geometric_central_radial_frequency = ... design_filter_bandwidth = specification_high_pass_radial_frequency- ... 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 START ========== @@ -89,10 +120,11 @@ design_filter_bandwidth = specification_high_pass_radial_frequency- ... % Designs the prototype normalized filter. % 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_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 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 % TODO: denormalize!! ====================%%%%%%%%%%%%%%%%%%%%%%%%============================ 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 @@ -166,9 +199,33 @@ else % Even number of poles 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 clearVars = {'prototype_normalized_stop_radial_frequency', ... - 'epsilon_parameter', 'alpha_parameter', 'theta'}; + 'epsilon_parameter', 'alpha_parameter', 'theta', 'temp_filter_order'}; clear(clearVars{:}) clear clearVars @@ -257,6 +314,26 @@ for i=1:prototype_number_of_poles 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 clearVars = {'prototype_number_of_poles', 'i', 'temp_index', ... '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 % parameter using the eq. 7-89 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 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); 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)* ... units_filter_central_frequency_gain(1,2)* ... @@ -391,7 +501,7 @@ total_transfer_function = series(series(series( ... %ltiview(total_transfer_function); -% +%{ plot_transfer_function(total_transfer_function, ... [specification_low_stop_frequency ... specification_low_pass_frequency ... @@ -399,14 +509,9 @@ plot_transfer_function(total_transfer_function, ... 941.83 ... specification_high_pass_frequency ... specification_high_stop_frequency]); -% +%} % 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$ -% ========== UNITS IMPLEMENTATION END ========== \ No newline at end of file +% ========== TRANSFER FUNCTIONS END ========== \ No newline at end of file diff --git a/High Pass Butterworth/high_pass_design.m b/High Pass Butterworth/high_pass_design.m index 9d4c892..94fd695 100644 --- a/High Pass Butterworth/high_pass_design.m +++ b/High Pass Butterworth/high_pass_design.m @@ -2,7 +2,7 @@ %% $DATE : 16-Aug-2018 19:23:40 $ %% $Revision : 1.00 $ %% DEVELOPED : 9.0.0.341360 (R2016a) -%% FILENAME : band_pass_design.m +%% FILENAME : high_pass_design.m %% AEM : 8261 %% %% ========== DESIGN SPECIFICATIONS START ========== diff --git a/Low Pass Inverse Chebyshev/low_pass_design.m b/Low Pass Inverse Chebyshev/low_pass_design.m index f24fbe4..04f4b5d 100644 --- a/Low Pass Inverse Chebyshev/low_pass_design.m +++ b/Low Pass Inverse Chebyshev/low_pass_design.m @@ -1,10 +1,10 @@ -% AUTHOR : Apostolos Fanakis -% $DATE : 02-May-2018 17:21:18 $ -% $Revision : 1.00 $ -% DEVELOPED : 9.0.0.341360 (R2016a) -% FILENAME : low_pass_design.m -% AEM : 8261 - +%% AUTHOR : Apostolos Fanakis +%% $DATE : 02-May-2018 17:21:18 $ +%% $Revision : 1.00 $ +%% DEVELOPED : 9.0.0.341360 (R2016a) +%% FILENAME : low_pass_design.m +%% AEM : 8261 +%% %% ========== DESIGN SPECIFICATIONS START ========== % Figures out design specifications according to my AEM number