1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
function tune
close all
sizew = 320;
sizeh = 430;
border = 20;
textw = 30;
texth = 16;
butth = 20;
buttw = 70;
textdx = 20;
edith = 16;
editw = 50;
manualw = 260;
manualh = 160;
%%global manualtxt;
manualtxt = {['Get KP as high as possible but maintain stability.'...
'Start with KI = 0 and KP = RKP and increase it 20% at a time.'...
' Each time you raise KP try to move the system and it has to stay stable.'...
' Use set position to move SMART and get position to check if position is right.'...
' When you are done click next. Use Update PID before testing.'];
['Now move KD up and down to find the quickest stability and quiet system. If KD is to high there'...
'will be a kind of grinding sound. When you are done with KD you can may be rise KP a little more again.'...
' Click next to go to KL. Use Update PID before testing.'];
['Start with KI = 0 and KL = 1000. Increase KI until the motor always reaches its target but'...
' keep KL at least ten times KI. Then add 30% to KI. Start bringing down KL until it hampers KI and'...
' then add 30% to KL. Use Update PID before testing.']};
%%global j;
j = 1;
%%manual = manualtxt{j};
fig = figure('Visible', 'off', 'Position', [0 0 sizew sizeh], 'Resize', 'off', 'Name', 'Tuning', 'UserData', 1);
%% Button : next
uicontrol('Style', 'pushbutton', 'Callback', @next, 'Tag', '#4', 'String', 'next', 'Position', ...
[sizew - 4 * border - buttw, sizeh - border - 6 * texth - 5 * 24.8, buttw, butth]);
%% Text : manual
%%global manual
manual = uicontrol('Style', 'text', 'HorizontalAlignment', 'left', 'FontSize', 10,'Position', ...
[sizew / 2 - manualw / 2, border, manualw, manualh],'String', manualtxt{j}, 'BackgroundColor', [0.8, 0.8, 0.8]);
handles.j = j;
handles.manualtxt = manualtxt;
handles.manual = manual;
guidata(fig, handles);
movegui(fig, 'center');
set(fig, 'Visible', 'on');
set(fig,'userdata',{j,manual,manualtxt});
function next(obj,event)
tout=get(gcf,'userdata');
j=tout{1};
manual=tout{2};
manualtxt=tout{3};
%%global j;
j = j + 1 ;
if (j == 4)
j = 3;
end
%%global manual;
%%global manualtxt;
set(manual, 'String', manualtxt{j})
tout{1}=j;
set(gcf,'userdata',tout); |
Partager