%  MODIFY FEEDBACK PROCESS PARAMETERS
%  FILENAME: FBPAR.M
%  DATE: October 1994
%  VERSION: 02
%  COPYRIGHT 1993, 1994 M.Gretzinger & T.Marlin
%            McMaster University   
% This m-file is called from STABLE.M. It sets up menu to allow user to
%       modify the feedback process parameters.

while 1
  clc
  disp('*************************************************************')
  disp('*           MODIFY FEEDBACK PROCESS PARAMETERS              *')
  disp('*                                                           *')
  disp('*************************************************************')
  disp('')
  disp('SELECT THE APPROPRIATE MENU ITEM')
  disp('')
  disp('MODIFY...')
  disp('                                       PRESENT VALUES')
  fprintf('1) Process Gain, Kp                    %4.4f\n',kp)
  fprintf('2) Dead time, theta                    %4.2f\n',theta)
  fprintf('3) Time Constant, taulead (numerator)  %4.2f\n',taulead)
  fprintf('4) Time Constant, tau1  (lag)          %4.2f\n',tau1)
  fprintf('5) Time Constant, tau2                 %4.2f\n',tau2)
  fprintf('6) Time Constant, tau3                 %4.2f\n',tau3)
  fprintf('7) Damping Coef., xi                   %4.2f\n',xi)
  disp('8) Return to main menu')
  disp('')
        
  m1 = input('Enter the desired selection:   ');
  
  if isempty(m1), break, end
      
  m1 = round(m1);
  if (m1<1) | (m1>8)
      disp('')
      disp('Not a valid selection')
      disp('')
      disp('Press ENTER to continue')
      pause;
  end    
  if m1 == 1
      junkkp = input('Enter value for process gain, Kp:  ') ;
      if isempty(junkkp)
          junkkp = kp ;
      end
      kp = junkkp;

  elseif m1 == 2
      junktheta = input('Enter value for dead time, theta:  ') ;
      if isempty(junktheta)
          junktheta = theta;
      end
      
      if junktheta < 0
          junktheta = theta;
          disp('Illegal entry, theta must be >= 0')
          disp('')
          disp('Press ENTER to continue')
          pause
      end
      theta = junktheta;

  elseif m1 == 3
      junktaulead = input('Enter value for time constant in numerator, taulead:  ') ;
      if isempty(junktaulead)
          junktaulead = taulead  ;
      end
      taulead = junktaulead;

  elseif m1 == 4
      junktau1 = input('Enter value for time constant, tau1:  ') ;
      if isempty(junktau1)
         junktau1 = tau1 ;
      end
      tau1 = junktau1;

  elseif m1 == 5
      junktau2 = input('Enter value for time constant, tau2:  ') ;
      if isempty(junktau2)
          junktau2 = tau2  ;
      end
      tau2 = junktau2;

  elseif m1 == 6
      junktau3 = input('Enter value for time constant, tau3:  ') ;
      if isempty(junktau3)
          junktau3 = tau3 ;
      end
      tau3 = junktau3;

  elseif m1 == 7
      junkxi = input('Enter value for damping factor, xi:  ') ;
      if isempty(junkxi)
          junkxi = xi ;
      end
      if junkxi <= 0
          disp(' damping coef. must be positive, entry not accepted')
          disp(' press enter to continue')
          junkxi=xi;
          pause
      end
      xi = junkxi;

  else
      break
  end        % if m1


end    % while 1 (line 10)

