% FILENAME: TUNE.M % DONE BY : RENO CIPOLLA % DATE: January 1995 % VERSION: 2.0 % REVISED : January 1995 % COPYRIGHT 1995 by T. Marlin and R. Ciplloa % ********************************************************** while 1 clc disp('*************************************************************') disp('* MODIFY PID CONTROLLER TUNING CONSTANTS *') disp('* *') disp('*************************************************************') disp('') disp('SELECT THE APPROPRIATE MENU ITEM(s)') disp('') disp('MODIFY...') disp(' PRESENT VALUES') fprintf('1) Controller Gain, Kc %4.2f\n',kc) fprintf('2) Integral Time, TI %4.2f\n',ti) fprintf('3) Derivative Time, TD %4.2f\n',td) fprintf('4) Derivative Filter %4.3f\n',al_pha) disp('5) Return to main menu') disp('') TOON = input('Enter the desired selection: '); if isempty(TOON), break, end % go back to main menu if ENTER is pressed TOON = round(TOON); if (TOON<1) | (TOON>5) disp('') disp('Not a valid selection') disp('') disp('Press ENTER to continue') pause; end if TOON == 1 junk = input('Enter value for controller gain: ') ; if isempty(junk) junk=kc; end kc=junk; Y0i(1)=kc; elseif TOON == 2 junk = input('Enter value for integral time: ') ; if junk <= 0 junk=ti; disp('') disp(' Sorry, must enter a positive integral time ') disp('') disp(' Press Enter to continue ') pause % junk=ti; end if isempty(junk) junk=ti; end ti=junk; Y0i(2)=ti; elseif TOON == 3 junk = input('Enter value for derivative time: ') ; if isempty(junk) junk=td; end if junk < 0 junk=td; disp(' ') disp(' Sorry, must enter a nonnegative derivative time ') disp('') disp(' Press Enter to continue ') pause end td=junk; elseif TOON == 4 junk = input('Enter value for derivative filter (0 - 0.3): ') ; if isempty(junk) junk=al_pha; end if junk > 0.3 | junk < 0 disp('') disp(' Enter a nonnegative number less than or equal to 0.3 ') disp('') disp(' Press any key to continue') junk=al_pha; pause end al_pha=junk; else break end end