From 91a806445ab39ee98db1a2438a414dc9e403e8e0 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sat, 18 Aug 2018 15:38:02 +0300 Subject: [PATCH] High pass output init --- High Pass Butterworth/high_pass_design.m | 121 ++++++++++++++++++++--- 1 file changed, 105 insertions(+), 16 deletions(-) diff --git a/High Pass Butterworth/high_pass_design.m b/High Pass Butterworth/high_pass_design.m index 94fd695..913d40e 100644 --- a/High Pass Butterworth/high_pass_design.m +++ b/High Pass Butterworth/high_pass_design.m @@ -29,16 +29,19 @@ specification_stop_radial_frequency = ... specification_min_stop_attenuation = 24+AEM(4)*(6/9); % dB specification_max_pass_attenuation = 0.5+AEM(3)/36; % dB -clear design_param_m - +% Outputs results +fprintf(['\n' '===== DESIGN SPECIFICATIONS =====' '\n' ... + 'Filter design specifications:\n' ... + 'Pass frequency = %.3fHz = %.3frad/s\n' ... + 'Stop frequency = %.3fHz = %.3frad/s\n' ... + 'Min stop attenuation = %.3fdB\n' ... + 'Max pass attenuation = %.3fdB\n'], ... + specification_pass_frequency, specification_pass_radial_frequency, ... + specification_stop_frequency, specification_stop_radial_frequency, ... + specification_min_stop_attenuation, specification_max_pass_attenuation); -%{ -specification_pass_radial_frequency = 15707.96; % rad/s -specification_stop_radial_frequency = 6283.2; % rad/s +clear design_param_m -specification_min_stop_attenuation = 25; % dB -specification_max_pass_attenuation = 0.5; % dB -%} % ========== DESIGN SPECIFICATIONS END ========== %% ========== PROTOTYPE LOW PASS DESIGN SPECIFICATIONS START ========== @@ -53,16 +56,25 @@ prototype_normalized_stop_radial_frequency = ... % Min and max attenuations remain the same +% 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'], ... + prototype_normalized_stop_radial_frequency); + % ========== PROTOTYPE LOW PASS DESIGN SPECIFICATIONS END ========== %% ========== PROTOTYPE LOW PASS DESIGN START ========== % Designs the prototype normalized filter. % Calculates the filter's order using the eq. 9-52 -design_filter_order = ceil(log10(((10^ ... +temp_filter_order = log10(((10^ ... (specification_min_stop_attenuation/10)-1)/(10^ ... (specification_max_pass_attenuation/10)-1)))/ ... - (2*log10(prototype_normalized_stop_radial_frequency))); + (2*log10(prototype_normalized_stop_radial_frequency)); +design_filter_order = ceil(temp_filter_order); % Calculates the frequency at which half power of the low pass prototype % occurs using the eq. 9-48 @@ -162,13 +174,34 @@ else % Even number of poles end end +% Outputs results +fprintf(['\n' '===== PROTOTYPE LOW PASS DESIGN =====' '\n' ... + 'A prototype low pass Butterworth filter is designed with the\n' ... + 'specifications previously calculated.\n\n' ... + 'Filter order = %.3f\n' ... + 'Filter order ceiling = %d\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, ... + design_half_power_radial_frequency, design_butterworth_angles(1,1), ... + design_butterworth_angles(1,2)); + +fprintf('\nLow pass Butterworth poles found:\n'); +for i=1:low_pass_prototype_number_of_poles + fprintf(['Pole %d:\t' '%.3f' char(177) ... + '%.3fi, radial frequency = %.3f, Q = %.3f\n'], ... + i, low_pass_prototype_poles_real_parts(1,i), ... + low_pass_prototype_poles_imaginary_parts(1,i), ... + low_pass_prototype_poles_radial_frequencies(1,i), ... + low_pass_prototype_poles_Q(1,i)); +end + % Clears unneeded variables from workspace -% clearVars = {'i', 'prototype_normalized_stop_radial_frequency', ... 'low_pass_prototype_half_power_radial_frequency', 'theta'}; clear(clearVars{:}) clear clearVars -% % ========== PROTOTYPE LOW PASS DESIGN END ========== @@ -192,6 +225,27 @@ high_pass_poles_Q = low_pass_prototype_poles_Q; % filter order high_pass_transfer_function_zeros = zeros([1 design_filter_order]); +% Outputs results +fprintf(['\n' '===== LOW PASS TO HIGH PASS TRANSFORMATION =====' '\n' ... + 'The prototype low pass Butterworth filter is transformed into\n' ... + 'a high pass Butterworth using the transformation S = 1/s.\n']); + +fprintf('\nHigh pass Butterworth normalized poles found:\n'); +for i=1:high_pass_number_of_poles + fprintf(['Pole %d:\t' '%.3f' char(177) ... + '%.3fi, radial frequency = %.3f, Q = %.3f\n'], ... + i, high_pass_poles_real_parts(1,i), ... + high_pass_poles_imaginary_parts(1,i), ... + high_pass_poles_radial_frequencies(1,i), ... + high_pass_poles_Q(1,i)); +end + +fprintf('\nTransfer function zeros:\n'); +for i=1:length(high_pass_transfer_function_zeros) + fprintf(['Zero %d:\t' '0%+.3fi\n'], ... + i, high_pass_transfer_function_zeros(1,i)); +end + % Clears unneeded variables from workspace clear low_pass_prototype_number_of_poles clear -regexp ^low_pass_prototype_ @@ -213,6 +267,21 @@ for i=1:high_pass_number_of_poles design_half_power_radial_frequency; end +% Outputs results +fprintf(['\n' '===== POLES DE-NORMALIZATION =====' '\n' ... + 'The high pass filter designed is normalized.\n' ... + 'The poles are de-normalized.\n']); + +fprintf('\nHigh pass Butterworth poles found:\n'); +for i=1:high_pass_number_of_poles + fprintf(['Pole %d:\t' '%.3f' char(177) ... + '%.3fi, radial frequency = %.3f, Q = %.3f\n'], ... + i, high_pass_poles_real_parts(1,i), ... + high_pass_poles_imaginary_parts(1,i), ... + high_pass_poles_radial_frequencies(1,i), ... + high_pass_poles_Q(1,i)); +end + % Clears unneeded variables from workspace clear i clear -regexp ^geffe_ @@ -283,10 +352,30 @@ for i=1:high_pass_number_of_poles tf(unit_numerator, unit_denominator); end - +% Outputs results +fprintf(['\n' '===== UNITS IMPLEMENTATION =====' '\n' ... + 'Units implementation details:\n']); +for i=1:high_pass_number_of_poles + fprintf(['Unit %d:\n' ... + '\tPole radial frequency = %.3f\n'... + '\tPole Q = %.3f\n' ... + '\tTransfer function zero = 0%+.3fi (double)\n' ... + '\tCircuit elements:\n' ... + '\t\tR1 = %.3fOhm\n' ... + '\t\tR2 = %.3fOhm\n' ... + '\t\tr1 = %.3fOhm\n' ... + '\t\tr2 = %.3fOhm\n' ... + '\t\tC1 = %.7fF\n' ... + '\t\tC2 = %.7fF\n'], ... + i, high_pass_poles_radial_frequencies(1,i), ... + high_pass_poles_Q(1,i), ... + high_pass_transfer_function_zeros(1,i), ... + units_R(1,i), units_R(1,i), units_r1(1,i), units_r2(1,i), ... + units_C(1,i), units_C(1,i)); +end % Clears unneeded variables from workspace -clearVars = {''}; +clearVars = {'i'}; clear(clearVars{:}) clear clearVars clear -regexp _transfer_function$ @@ -320,13 +409,13 @@ ltiview(units_transfer_functions(1,1), ... %ltiview(total_transfer_function); -% +%{ plot_transfer_function(total_transfer_function, ... [design_half_power_radial_frequency/(2*pi) ... specification_stop_frequency ... specification_pass_frequency ... 15000]); -% +%} % Clears unneeded variable from workspace clearVars = {'total_transfer_function'};