📄 sltank.mdl
字号:
}
}
}
Block {
BlockType Sum
Name "Sum1"
Ports [2, 1]
Position [100, 110, 120, 150]
IconShape "rectangular"
Inputs "+-"
SaturateOnIntegerOverflow on
}
Block {
BlockType Switch
Name "Switch"
Position [360, 72, 380, 128]
Threshold "0"
}
Block {
BlockType Saturate
Name "change"
Position [255, 269, 290, 301]
Orientation "left"
UpperLimit "0.1"
LowerLimit "-0.1"
LinearizeAsGain on
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
}
Block {
BlockType Scope
Name "change\nscope"
Ports [1]
Position [260, 210, 290, 240]
Floating off
Location [715, 630, 977, 764]
Open off
NumInputPorts "1"
TickLabels "on"
ZoomMode "on"
List {
ListType AxesTitles
axes1 "%<SignalLabel>"
}
Grid "on"
TimeRange "20.000000"
YMin "-0.100000"
YMax "0.100000"
SaveToWorkspace off
SaveName "ScopeData"
DataFormat "Array"
LimitDataPoints on
MaxDataPoints "5000"
Decimation "1"
SampleInput off
SampleTime "0"
}
Block {
BlockType Constant
Name "const"
Position [310, 86, 335, 114]
Value "-1"
VectorParams1D on
}
Block {
BlockType Sum
Name "error"
Ports [2, 1]
Position [155, 125, 175, 145]
IconShape "rectangular"
Inputs "+-"
SaturateOnIntegerOverflow on
}
Block {
BlockType SubSystem
Name "tank 2"
Ports [1, 3]
Position [470, 81, 530, 139]
ShowPortLabels off
TreatAsAtomicUnit off
RTWSystemCode "Auto"
RTWFcnNameOpts "Auto"
RTWFileNameOpts "Auto"
MaskType "Water tank"
MaskDescription "Cylindrical water tank with overflow signal"
MaskPromptString "Height of tank (m):|Bottom area (m^2):|Out pipe"
" crossection (m^2):|Overflow sensor distance from top (m):|Initial level heig"
"ht (m):"
MaskStyleString "edit,edit,edit,edit,edit"
MaskTunableValueString "on,on,on,on,on"
MaskCallbackString "||||"
MaskEnableString "on,on,on,on,on"
MaskVisibilityString "on,on,on,on,on"
MaskToolTipString "on,on,on,on,on"
MaskInitialization "ht=@1;area=@2;outletArea=@3;overflowLimit=@4;in"
"itialHt=@5;"
MaskDisplay "disp('WATER\\nTANK')"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
MaskValueString "2|1|0.05|0|0.5"
System {
Name "tank 2"
Location [416, 401, 962, 709]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
ZoomFactor "100"
AutoZoom on
Block {
BlockType Inport
Name "flow\nin"
Position [25, 175, 45, 195]
Port "1"
Interpolate on
}
Block {
BlockType Gain
Name "1/area"
Position [220, 167, 270, 223]
Gain "1/area"
Multiplication "Element-wise(K.*u)"
SaturateOnIntegerOverflow on
}
Block {
BlockType Relay
Name "Overflow sensor"
Position [385, 18, 425, 62]
OnSwitchValue "ht - overflowLimit"
OffSwitchValue "ht - overflowLimit"
OnOutputValue "1"
OffOutputValue "0"
}
Block {
BlockType Gain
Name "outletArea"
Position [410, 167, 460, 223]
Gain "outletArea"
Multiplication "Element-wise(K.*u)"
SaturateOnIntegerOverflow on
}
Block {
BlockType Fcn
Name "sqrt(2gh)"
Position [300, 171, 390, 219]
Expr "sqrt(2*9.8*u)"
}
Block {
BlockType Sum
Name "sum"
Ports [2, 1]
Position [105, 175, 125, 210]
IconShape "rectangular"
Inputs "+-"
SaturateOnIntegerOverflow on
}
Block {
BlockType SubSystem
Name "tank\nvolume"
Ports [1, 1]
Position [150, 174, 200, 216]
ShowPortLabels off
TreatAsAtomicUnit off
RTWSystemCode "Auto"
RTWFcnNameOpts "Auto"
RTWFileNameOpts "Auto"
MaskType "Limited integrator."
MaskDescription "Limited integrator"
MaskHelp "Implements a limited integrator with \\nan "
"expression of the form:\\n\\nif(x<=lb and u<0) or (x>=ub and u>0)\\n\\txdot=0"
"\\nelse\\n\\txdot=u."
MaskPromptString "Lower bound:|Upper bound:|Initial condition"
MaskStyleString "edit,edit,edit"
MaskTunableValueString "on,on,on"
MaskCallbackString "||"
MaskEnableString "on,on,on"
MaskVisibilityString "on,on,on"
MaskToolTipString "on,on,on"
MaskInitialization "lb = @1; ub = @2; xi = @3;"
MaskDisplay "plot(-1,-0.2,3.5,1.2,[0.05,1,2,2.9],[0,0,1,"
"1]);disp(' 1/s ')"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
MaskValueString "0|ht * area|initialHt * area"
System {
Name "tank\nvolume"
Location [0, 0, 791, 233]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
ZoomFactor "100"
AutoZoom on
Block {
BlockType Inport
Name "In_1"
Position [20, 130, 40, 150]
Port "1"
Interpolate on
}
Block {
BlockType Fcn
Name "Fcn"
Position [150, 116, 520, 154]
Expr "u[2]*((((u[1]>lb)+(u[2]>=0))>0) * (((u["
"1]<ub)+(u[2]<=0))>0))"
}
Block {
BlockType Integrator
Name "Integrator"
Ports [1, 1]
Position [540, 126, 585, 144]
ExternalReset "none"
InitialConditionSource "internal"
InitialCondition "xi"
LimitOutput off
UpperSaturationLimit "inf"
LowerSaturationLimit "-inf"
ShowSaturationPort off
ShowStatePort off
AbsoluteTolerance "auto"
}
Block {
BlockType Mux
Name "Mux"
Ports [2, 1]
Position [85, 116, 115, 149]
Inputs "2"
DisplayOption "none"
}
Block {
BlockType Saturate
Name "Saturation"
Position [630, 121, 675, 149]
UpperLimit "ub"
LowerLimit "lb"
LinearizeAsGain on
}
Block {
BlockType Outport
Name "Out_1"
Position [720, 125, 740, 145]
Port "1"
OutputWhenDisabled "held"
InitialOutput "0"
}
Line {
SrcBlock "Integrator"
SrcPort 1
Points [10, 0]
Branch {
DstBlock "Saturation"
DstPort 1
}
Branch {
Points [0, -100; -545, 0; 0, 90]
DstBlock "Mux"
DstPort 1
}
}
Line {
SrcBlock "Fcn"
SrcPort 1
DstBlock "Integrator"
DstPort 1
}
Line {
SrcBlock "Mux"
SrcPort 1
DstBlock "Fcn"
DstPort 1
}
Line {
SrcBlock "In_1"
SrcPort 1
DstBlock "Mux"
DstPort 2
}
Line {
SrcBlock "Saturation"
SrcPort 1
DstBlock "Out_1"
DstPort 1
}
}
}
Block {
BlockType Outport
Name "water\nlevel"
Position [495, 100, 515, 120]
Port "1"
OutputWhenDisabled "held"
InitialOutput "0"
}
Block {
BlockType Outport
Name "flow\nout"
Position [495, 185, 515, 205]
Port "2"
OutputWhenDisabled "held"
InitialOutput "0"
}
Block {
BlockType Outport
Name "overflow\nflag"
Position [495, 30, 515, 50]
Port "3"
OutputWhenDisabled "held"
InitialOutput "0"
}
Line {
SrcBlock "outletArea"
SrcPort 1
Points [10, 0]
Branch {
DstBlock "flow\nout"
DstPort 1
}
Branch {
Points [0, 65; -390, 0; 0, -60]
DstBlock "sum"
DstPort 2
}
}
Line {
SrcBlock "sqrt(2gh)"
SrcPort 1
DstBlock "outletArea"
DstPort 1
}
Line {
SrcBlock "1/area"
SrcPort 1
Points [0, 0]
Branch {
Points [10, 0; 0, -85]
Branch {
Points [0, -70]
DstBlock "Overflow sensor"
DstPort 1
}
Branch {
DstBlock "water\nlevel"
DstPort 1
}
}
Branch {
DstBlock "sqrt(2gh)"
DstPort 1
}
}
Line {
SrcBlock "tank\nvolume"
SrcPort 1
DstBlock "1/area"
DstPort 1
}
Line {
SrcBlock "Overflow sensor"
SrcPort 1
DstBlock "overflow\nflag"
DstPort 1
}
Line {
SrcBlock "flow\nin"
SrcPort 1
DstBlock "sum"
DstPort 1
}
Line {
SrcBlock "sum"
SrcPort 1
DstBlock "tank\nvolume"
DstPort 1
}
}
}
Block {
BlockType Constant
Name "tank max\ninflow"
Position [410, 169, 455, 201]
Orientation "left"
Value "0.5"
VectorParams1D on
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
}
Line {
SrcBlock "tank 2"
SrcPort 2
Points [25, 0]
DstBlock "Scope4"
DstPort 1
}
Line {
SrcBlock "tank max\ninflow"
SrcPort 1
Points [-15, 0]
DstBlock "Subsystem"
DstPort 2
}
Line {
SrcBlock "Derivative"
SrcPort 1
DstBlock "change"
DstPort 1
}
Line {
SrcBlock "Mux1"
SrcPort 1
Points [0, 10]
DstBlock "Fuzzy Logic\nController"
DstPort 1
}
Line {
SrcBlock "change"
SrcPort 1
Points [-25, 0]
Branch {
Points [-35, 0]
DstBlock "Mux1"
DstPort 2
}
Branch {
Points [0, -60]
DstBlock "change\nscope"
DstPort 1
}
}
Line {
SrcBlock "Constant"
SrcPort 1
Points [15, 0; 0, 25]
DstBlock "Sum1"
DstPort 1
}
Line {
SrcBlock "Signal\nGenerator"
SrcPort 1
Points [10, 0; 0, -35]
DstBlock "Sum1"
DstPort 2
}
Line {
SrcBlock "Subsystem"
SrcPort 1
DstBlock "tank 2"
DstPort 1
}
Line {
SrcBlock "tank 2"
SrcPort 1
Points [15, 0]
Branch {
DstBlock "Mux2"
DstPort 2
}
Branch {
Points [0, 195]
Branch {
Points [0, 45; -415, 0; 0, -190]
DstBlock "error"
DstPort 2
}
Branch {
DstBlock "Derivative"
DstPort 1
}
}
}
Line {
SrcBlock "Sum1"
SrcPort 1
Points [15, 0]
Branch {
DstBlock "error"
DstPort 1
}
Branch {
Points [0, -115; 410, 0; 0, 60]
DstBlock "Mux2"
DstPort 1
}
}
Line {
SrcBlock "tank 2"
SrcPort 3
DstBlock "Scope2"
DstPort 1
}
Line {
SrcBlock "Switch"
SrcPort 1
DstBlock "Subsystem"
DstPort 1
}
Line {
SrcBlock "Mux2"
SrcPort 1
Points [0, 0]
Branch {
DstBlock "S-Function"
DstPort 1
}
Branch {
Points [5, 0; 0, 70]
DstBlock "Comparison"
DstPort 1
}
}
Line {
SrcBlock "error"
SrcPort 1
Points [0, 0]
Branch {
DstBlock "Mux1"
DstPort 1
}
Branch {
Points [10, 0; 0, -85]
DstBlock "PID Controller"
DstPort 1
}
}
Line {
SrcBlock "Fuzzy Logic\nController"
SrcPort 1
Points [20, 0]
DstBlock "Switch"
DstPort 3
}
Line {
SrcBlock "PID Controller"
SrcPort 1
Points [50, 0]
DstBlock "Switch"
DstPort 1
}
Line {
SrcBlock "const"
SrcPort 1
DstBlock "Switch"
DstPort 2
}
Annotation {
Position [62, 287]
VerticalAlignment "top"
Text "Try the demo\n\"sltank2\""
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -