function hydSysCompareGui
%hydSysCompareGui Plots ideal system efficiency for four types of
%hydraulic systems: a fixed displacement pump with relief valve, a pressure
%compensated pump, a single-pump pressure compensated load sensing system and a
%dual-pump load sense system.
%Copyright Travis Wiens travis.mlfx@nutaksas.com
%set up some GUI sizes, etc
% dimensions in pixels
leftMargin=25;%
topMargin=30;% (to bottom of first line)
bottomMargin=20;
buttonSpacing=2;
textLabelWidth=200;
valWidth=50;
linespace=30;%pixels
textHeight=25;%pixels
%set up some colors
figBackground=get(gcf,'Color');
colorL1=[1 0.5 0.5];%load 1
colorL2=[0 1 1];%load 2
colorMeter=[1 1 0];%metering losses
colorRV=[0.6 0.6 0];%relief valve losses
colorLS=[1 1 0.6];%load sense margin loss
figure(1)
clf
position=get(gcf,'position');%get position and dimensions
vpos=position(4)-topMargin;%initial vertical position
hpos=leftMargin;%horizontal position
h=uicontrol('Style','text','String','Ideal Hydraulic System Comparison',...
'Position',[hpos vpos 2*textLabelWidth textHeight],...
'backgroundcolor',figBackground,...
'fontweight','bold',...
'HorizontalAlignment','Left',...
'tooltip',sprintf('This GUI compares the efficiency of four types of hydraulic system.\nEach is an ideal system with minimal metering loss and no pressure\noverride on relief valves or pressure compensators.\nSystem 1 is a fixed displacement pump with a relief valve in parallel with the load (this assumes the open-centre bypass passage is closed.\nSystem 2 is a pressure compensated (variable displacement) pump with an ideal pressure compensator that destrokes the pump at the max pressure. \nSystem 3 is a pressure-compensated load-sensing system. This pump reduces its flow in order to maintain the desired flow,\nas measured by a load sensing orifice. Pressure compensators are required to reduce the pressure to the load with the lower pressure requirement.\nSystem 4 is a dual-pump load sensing system, where each load has a dedicated pump.\n\n The areas of graphs show the power lost or utilized for each function, since power=flow*pressure.\nThick black lines show the pump curve\n\nAuthor: Travis Wiens travis.mlfx@nutaksas.com') );
set(h,'fontsize',get(h,'fontsize')+2);
vpos=vpos-linespace;%move down one line
hpos=leftMargin;%return to left margin
uicontrol('Style','text','String','Pump Max Flow (L/min):',...
'Position',[hpos vpos textLabelWidth textHeight],...
'backgroundcolor',figBackground,...
'HorizontalAlignment','right',...
'tooltip','Enter pump maximum flow here. (Total pump flow for dual-pump system.)');
hpos=hpos+textLabelWidth+buttonSpacing;
h_maxQs=uicontrol('Style','edit','String','100',...
'position', [hpos vpos valWidth textHeight],...
'callback',@callbackUpdate,...
'tooltip','Enter pump maximum flow here. (Total pump flow for dual-pump system.)');
hpos=hpos+valWidth+buttonSpacing;
uicontrol('Style','text','String','Relief/Deadhead Pressure (MPa):',...
'Position',[hpos vpos textLabelWidth textHeight],...
'backgroundcolor',figBackground,...
'HorizontalAlignment','right',...
'tooltip','Enter pump maximum pressure here. This is the relief valve setpoint or pump deadhead pressure.');
hpos=hpos+textLabelWidth+buttonSpacing;
h_maxPs=uicontrol('Style','edit','String','32',...
'position', [hpos vpos valWidth textHeight],...
'callback',@callbackUpdate,...
'tooltip','Enter pump maximum pressure here. This is the relief valve setpoint or pump deadhead pressure.');
hpos=hpos+valWidth+buttonSpacing;
vpos=vpos-linespace;
hpos=leftMargin;
uicontrol('Style','text','String','Load 1 Flow (L/min):',...
'Position',[hpos vpos textLabelWidth textHeight],...
'backgroundcolor',figBackground,...
'HorizontalAlignment','right',...
'tooltip','Enter load #1 flow here. Do not try to request more total load flow than the max pump flow.');
hpos=hpos+textLabelWidth+buttonSpacing;
h_QL1=uicontrol('Style','edit','String','50',...
'position', [hpos vpos valWidth textHeight],...
'backgroundcolor',colorL1,...
'callback',@callbackUpdate,...
'tooltip','Enter load #1 flow here. Do not try to request more total load flow than the max pump flow.');
hpos=hpos+valWidth+buttonSpacing;
uicontrol('Style','text','String','Load 1 Pressure (MPa):',...
'Position',[hpos vpos textLabelWidth textHeight],...
'backgroundcolor',figBackground,...
'HorizontalAlignment','right',...
'tooltip','Enter load #1 pressure here. Do not try to request more pressure than the max pump pressure.');
hpos=hpos+textLabelWidth+buttonSpacing;
h_PL1=uicontrol('Style','edit','String','15',...
'position', [hpos vpos valWidth textHeight],...
'backgroundcolor',colorL1,...
'callback',@callbackUpdate,...
'tooltip','Enter load #1 pressure here. Do not try to request more pressure than the max pump pressure.');
hpos=hpos+valWidth+buttonSpacing;
vpos=vpos-linespace;
hpos=leftMargin;
uicontrol('Style','text','String','Load 2 Flow (L/min):',...
'Position',[hpos vpos textLabelWidth textHeight],...
'backgroundcolor',figBackground,...
'HorizontalAlignment','right',...
'tooltip','Enter load #2 flow here. Do not try to request more total load flow than the max pump flow.');
hpos=hpos+textLabelWidth+buttonSpacing;
h_QL2=uicontrol('Style','edit','String','10',...
'position', [hpos vpos valWidth textHeight],...
'backgroundcolor',colorL2,...
'callback',@callbackUpdate,...
'tooltip','Enter load #2 flow here. Do not try to request more total load flow than the max pump flow.');
hpos=hpos+valWidth+buttonSpacing;
uicontrol('Style','text','String','Load 2 Pressure (MPa):',...
'Position',[hpos vpos textLabelWidth textHeight],...
'backgroundcolor',figBackground,...
'HorizontalAlignment','right',...
'tooltip','Enter load #2 pressure here. Do not try to request more pressure than the max pump pressure.');
hpos=hpos+textLabelWidth+buttonSpacing;
h_PL2=uicontrol('Style','edit','String','10',...
'position', [hpos vpos valWidth textHeight],...
'backgroundcolor',colorL2,...
'callback',@callbackUpdate,...
'tooltip','Enter load #1 pressure here. Do not try to request more pressure than the max pump pressure.');
hpos=hpos+valWidth+buttonSpacing;
vpos=vpos-linespace;
hpos=leftMargin;
uicontrol('Style','text','String','Load Sense Margin (MPa):',...
'Position',[hpos vpos textLabelWidth textHeight],...
'backgroundcolor',figBackground,...
'HorizontalAlignment','right',...
'tooltip','Enter load sense margin here. This is the target pressure drop across the load-sense orifice.');
hpos=hpos+textLabelWidth+buttonSpacing;
h_PLS=uicontrol('Style','edit','String','1.5',...
'position', [hpos vpos valWidth textHeight],...
'backgroundcolor',colorLS,...
'callback',@callbackUpdate,...
'tooltip','Enter load sense margin here. This is the target pressure drop across the load-sense orifice.');
hpos=hpos+valWidth+buttonSpacing;
hpos=hpos+valWidth;
uicontrol('Style','text','String','Relief',...
'Position',[hpos vpos textLabelWidth/2 textHeight],...
'backgroundcolor',colorRV,...
'HorizontalAlignment','center',...
'tooltip','This color denotes power lost over relief valve.');
hpos=hpos+textLabelWidth/2+buttonSpacing;
uicontrol('Style','text','String','Metering',...
'Position',[hpos vpos textLabelWidth/2 textHeight],...
'backgroundcolor',colorMeter,...
'HorizontalAlignment','center',...
'tooltip','This color denotes power lost over metering orifices. This is the absolute minimum, most systems will exhibit more.');
hpos=hpos+textLabelWidth/2+buttonSpacing;
vpos_ax=vpos-10;%vertical position of top of graphs
%set up four axes
ax=nan(1,4);
axMargin=0.18;
ax(1)=axes('position',[0+axMargin/2 vpos_ax/position(4)/2+axMargin/2 0.5-axMargin vpos_ax/position(4)/2-axMargin]);
ax(2)=axes('position',[0.5+axMargin/2 vpos_ax/position(4)/2+axMargin/2 0.5-axMargin vpos_ax/position(4)/2-axMargin]);
ax(3)=axes('position',[0+axMargin/2 0+axMargin/2 0.5-axMargin vpos_ax/position(4)/2-axMargin]);
ax(4)=axes('position',[0.5+axMargin/2 0+axMargin/2 0.5-axMargin vpos_ax/position(4)/2-axMargin]);
callbackUpdate;
function callbackUpdate(varargin)
%this functions updates plots
%get values from text boxes
maxQs=str2num(get(h_maxQs,'string'));
maxPs=str2num(get(h_maxPs,'string'));
PL1=str2num(get(h_PL1,'string'));
PL1(PL1==0)=1e-10;
PL2=str2num(get(h_PL2,'string'));
PL2(PL2==0)=1e-10;
QL1=str2num(get(h_QL1,'string'));
QL1(QL1==0)=1e-10;
QL2=str2num(get(h_QL2,'string'));
QL2(QL2==0)=1e-10;
PLS=str2num(get(h_PLS,'string'));
PLS(PLS==0)=1e-10;
axes(ax(1));%open center, relief valve
Qs=maxQs;
Ps=max([PL1 PL2]);
QL1act=QL1;
QL2act=QL2;
if QL1act+QL2act>maxQs
error('QL1+QL2 out of range')
end
Qrv=Qs-(QL1act+QL2act);
Qrv(Qrv==0)=1e-10;
eff=(QL1act*PL1+QL2act*PL2)/(Qs*Ps);
cla
hold on
plot([0 maxPs maxPs],[maxQs maxQs 0],'k','linewidth',3)
rectangle('Position',[0 0 Ps Qs],'FaceColor',colorMeter);
rectangle('Position',[0 0 PL1 QL1act],'FaceColor',colorL1);
rectangle('Position',[0 QL1act PL2 QL2act],'FaceColor',colorL2);
rectangle('Position',[0 QL1act+QL2act Ps Qrv],'FaceColor',colorRV);
title(sprintf('Open Center \\eta=%0.1f%%',eff*100))
axis([0 maxPs*1.05 0 maxQs*1.05])
axes(ax(2));%closed center, pressure compensated
Ps=maxPs;
QL1act=QL1;
QL2act=QL2;
if QL1act+QL2act>maxQs
error('QL1+QL2 out of range')
end
Qs=QL1act+QL2act;
eff=(QL1act*PL1+QL2act*PL2)/(Qs*Ps);
cla
hold on
plot([0 maxPs maxPs],[maxQs maxQs 0],'k','linewidth',3)
rectangle('Position',[0 0 Ps Qs],'FaceColor',colorMeter);
rectangle('Position',[0 0 PL1 QL1act],'FaceColor',colorL1);
rectangle('Position',[0 QL1act PL2 QL2act],'FaceColor',colorL2);
title(sprintf('Press Compensated, Closed Center \\eta=%0.1f%%',eff*100))
axis([0 maxPs*1.05 0 maxQs*1.05])
axes(ax(3));%pressure compensated, load sensing
Ps=max([PL1 PL2])+PLS;
QL1act=QL1;
QL2act=QL2;
if QL1act+QL2act>maxQs
error('QL1+QL2 out of range')
end
Qs=QL1act+QL2act;
eff=(QL1act*PL1+QL2act*PL2)/(Qs*Ps);
cla
hold on
plot([0 maxPs maxPs],[maxQs maxQs 0],'k','linewidth',3)
rectangle('Position',[0 0 Ps Qs],'FaceColor',colorMeter);
rectangle('Position',[0 0 PL1 QL1act],'FaceColor',colorL1);
rectangle('Position',[0 QL1act PL2 QL2act],'FaceColor',colorL2);
rectangle('Position',[max([PL1 PL2]) 0 PLS Qs],'FaceColor',colorLS);
xlabel('Pressure (MPa)')
ylabel('Flow (L/min)')
title(sprintf('PCLS \\eta=%0.1f%%',eff*100))
axis([0 maxPs*1.05 0 maxQs*1.05])
axes(ax(4));%load sensing, dual pumps
Ps=[PL1 PL2]+PLS;
QL1act=QL1;
QL2act=QL2;
if QL1act+QL2act>maxQs
error('QL1+QL2 out of range')
end
Qs=[QL1act QL2act];
eff=(QL1act*PL1+QL2act*PL2)/(Qs(1)*Ps(1)+Qs(2)*Ps(2));
cla
hold on
plot([0 maxPs maxPs],[maxQs maxQs 0],'k','linewidth',3)
rectangle('Position',[0 0 PL1 QL1act],'FaceColor',colorL1);
rectangle('Position',[0 QL1act PL2 QL2act],'FaceColor',colorL2);
rectangle('Position',[PL1 0 PLS Qs(1)],'FaceColor',colorLS);
rectangle('Position',[PL2 Qs(1) PLS Qs(2)],'FaceColor',colorLS);
title(sprintf('Two LS Pumps \\eta=%0.1f%%',eff*100))
axis([0 maxPs*1.05 0 maxQs*1.05])
end
end