📄 optsim1.mdl
字号:
OutputWhenDisabled "held"
InitialOutput "[]"
}
Block {
BlockType RateLimiter
RisingSlewLimit "1"
FallingSlewLimit "-1"
SampleTimeMode "continuous"
InitialCondition "0"
LinearizeAsGain on
}
Block {
BlockType Saturate
UpperLimit "0.5"
LowerLimit "-0.5"
LinearizeAsGain on
ZeroCross on
SampleTime "-1"
}
Block {
BlockType Scope
ModelBased off
TickLabels "OneTimeTick"
ZoomMode "on"
Grid "on"
TimeRange "auto"
YMin "-5"
YMax "5"
SaveToWorkspace off
SaveName "ScopeData"
LimitDataPoints on
MaxDataPoints "5000"
Decimation "1"
SampleInput off
SampleTime "-1"
}
Block {
BlockType Step
Time "1"
Before "0"
After "1"
SampleTime "-1"
VectorParams1D on
ZeroCross on
}
Block {
BlockType SubSystem
ShowPortLabels on
Permissions "ReadWrite"
PermitHierarchicalResolution "All"
TreatAsAtomicUnit off
SystemSampleTime "-1"
RTWFcnNameOpts "Auto"
RTWFileNameOpts "Auto"
RTWMemSecFuncInitTerm "Inherit from model"
RTWMemSecFuncExecute "Inherit from model"
RTWMemSecDataConstants "Inherit from model"
RTWMemSecDataInternal "Inherit from model"
RTWMemSecDataParameters "Inherit from model"
SimViewingDevice off
DataTypeOverride "UseLocalSettings"
MinMaxOverflowLogging "UseLocalSettings"
}
Block {
BlockType Sum
IconShape "rectangular"
Inputs "++"
InputSameDT on
OutDataTypeMode "Same as first input"
OutDataType "sfix(16)"
OutScaling "2^0"
LockScale off
RndMeth "Floor"
SaturateOnIntegerOverflow on
SampleTime "-1"
}
Block {
BlockType ToWorkspace
VariableName "simulink_output"
MaxDataPoints "1000"
Decimation "1"
SampleTime "0"
FixptAsFi off
}
Block {
BlockType TransferFcn
Numerator "[1]"
Denominator "[1 2 1]"
AbsoluteTolerance "auto"
Realization "auto"
}
}
AnnotationDefaults {
HorizontalAlignment "center"
VerticalAlignment "middle"
ForegroundColor "black"
BackgroundColor "white"
DropShadow off
FontName "Helvetica"
FontSize 10
FontWeight "normal"
FontAngle "normal"
}
LineDefaults {
FontName "Helvetica"
FontSize 9
FontWeight "normal"
FontAngle "normal"
}
System {
Name "optsim1"
Location [182, 109, 751, 549]
Open on
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
ReportName "simulink-default.rpt"
Block {
BlockType SubSystem
Name "Controller"
Ports [1, 1]
Position [185, 49, 230, 81]
NamePlacement "alternate"
MinAlgLoopOccurrences off
RTWSystemCode "Auto"
FunctionWithSeparateData off
MaskHideContents off
MaskType "PID Controller"
MaskDescription "Enter expressions for proportional, integral, a"
"nd derivative terms."
MaskHelp "This block implements a PID controller where pa"
"ramaters are entered for the Proportional, Integral and Derivative terms."
MaskPromptString "Proportional:|Integral|Derivative:"
MaskStyleString "edit,edit,edit"
MaskTunableValueString "on,on,on"
MaskCallbackString "||"
MaskEnableString "on,on,on"
MaskVisibilityString "on,on,on"
MaskToolTipString "on,on,on"
MaskVarAliasString ",,"
MaskInitialization "P=@1; I=@2; D=@3;"
MaskDisplay "disp('PID')"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
MaskValueString "Kp|0|Kd"
MaskTabNameString ",,"
System {
Name "Controller"
Location [0, 0, 362, 244]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
Block {
BlockType Inport
Name "In_1"
Position [25, 65, 45, 85]
IconDisplay "Port number"
}
Block {
BlockType Gain
Name "D"
Position [105, 129, 125, 151]
Gain "D"
}
Block {
BlockType Gain
Name "D1"
Position [130, 13, 150, 37]
Gain "P"
}
Block {
BlockType Derivative
Name "Derivative"
Position [150, 128, 190, 152]
}
Block {
BlockType TransferFcn
Name "I"
Position [130, 57, 165, 93]
Numerator "[I]"
Denominator "[1 0]"
}
Block {
BlockType Sum
Name "Sum"
Ports [3, 1]
Position [255, 57, 275, 93]
Inputs "+++"
}
Block {
BlockType Outport
Name "Out_1"
Position [300, 65, 320, 85]
IconDisplay "Port number"
BusOutputAsStruct off
InitialOutput "0"
}
Line {
SrcBlock "In_1"
SrcPort 1
Points [15, 0]
Branch {
Points [15, 0]
Branch {
Points [0, -50]
DstBlock "D1"
DstPort 1
}
Branch {
DstBlock "I"
DstPort 1
}
}
Branch {
Points [0, 65]
DstBlock "D"
DstPort 1
}
}
Line {
SrcBlock "Sum"
SrcPort 1
DstBlock "Out_1"
DstPort 1
}
Line {
SrcBlock "D"
SrcPort 1
DstBlock "Derivative"
DstPort 1
}
Line {
SrcBlock "Derivative"
SrcPort 1
Points [10, 0; 0, -55]
DstBlock "Sum"
DstPort 3
}
Line {
SrcBlock "I"
SrcPort 1
DstBlock "Sum"
DstPort 2
}
Line {
SrcBlock "D1"
SrcPort 1
Points [55, 0; 0, 40]
DstBlock "Sum"
DstPort 1
}
}
}
Block {
BlockType SubSystem
Name "Double click\non this for demo.5"
Ports []
Position [230, 269, 301, 305]
ShowName off
OpenFcn "optsiminit"
MinAlgLoopOccurrences off
RTWSystemCode "Auto"
FunctionWithSeparateData off
MaskHideContents off
MaskDisplay "disp('optsiminit')"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
System {
Name "Double click\non this for demo.5"
Location [-10, 380, 117, 533]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
}
}
Block {
BlockType Integrator
Name "Integrator"
Ports [1, 1]
Position [285, 160, 315, 190]
ShowName off
IgnoreLimit off
}
Block {
BlockType Math
Name "Math\nFunction"
Ports [1, 1]
Position [195, 160, 225, 190]
ShowName off
Operator "square"
}
Block {
BlockType SubSystem
Name "Plant & Actuator"
Ports [1, 1]
Position [260, 44, 295, 86]
MinAlgLoopOccurrences off
RTWSystemCode "Auto"
FunctionWithSeparateData off
MaskHideContents off
System {
Name "Plant & Actuator"
Location [448, 142, 846, 359]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "usletter"
PaperUnits "inches"
TiledPaperMargins [0.500000, 0.500000, 0.500000, 0.500000]
TiledPageScale 1
ShowPageBoundaries off
ZoomFactor "100"
Block {
BlockType Inport
Name "u\n"
Position [15, 60, 35, 80]
IconDisplay "Port number"
}
Block {
BlockType Saturate
Name "Limit"
Position [70, 60, 95, 80]
UpperLimit "2"
LowerLimit "-2"
}
Block {
BlockType TransferFcn
Name "Plant"
Position [175, 46, 305, 94]
NamePlacement "alternate"
Numerator "[5]"
Denominator "[1 3 7 5 0]"
}
Block {
BlockType RateLimiter
Name "Rate"
Position [125, 60, 150, 80]
RisingSlewLimit "0.8"
FallingSlewLimit "-0.8"
}
Block {
BlockType Outport
Name "y"
Position [335, 60, 355, 80]
IconDisplay "Port number"
BusOutputAsStruct off
InitialOutput "0"
}
Line {
SrcBlock "Plant"
SrcPort 1
DstBlock "y"
DstPort 1
}
Line {
SrcBlock "u\n"
SrcPort 1
DstBlock "Limit"
DstPort 1
}
Line {
SrcBlock "Rate"
SrcPort 1
DstBlock "Plant"
DstPort 1
}
Line {
SrcBlock "Limit"
SrcPort 1
DstBlock "Rate"
DstPort 1
}
Annotation {
Name "Actuator Model"
Position [107, 43]
UseDisplayTextAsClickCallback off
}
}
}
Block {
BlockType Scope
Name "Scope"
Ports [1]
Position [375, 48, 405, 82]
Floating off
Location [189, 122, 662, 429]
Open off
NumInputPorts "1"
TickLabels "on"
ZoomMode "xonly"
List {
ListType AxesTitles
axes1 "Closed Loop Response"
}
TimeRange "100"
YMin "0"
YMax "1.4"
DataFormat "StructureWithTime"
SampleTime "0"
}
Block {
BlockType Step
Name "Step"
Position [85, 50, 105, 70]
Time "0"
SampleTime "0"
}
Block {
BlockType Sum
Name "Sum"
Ports [2, 1]
Position [135, 54, 150, 76]
ShowName off
Inputs "+-"
}
Block {
BlockType ToWorkspace
Name "To Workspace"
Position [370, 160, 430, 190]
ShowName off
VariableName "e2"
MaxDataPoints "1"
SampleTime "-1"
SaveFormat "Array"
}
Block {
BlockType Outport
Name "Out1"
Position [380, 118, 410, 132]
IconDisplay "Port number"
BusOutputAsStruct off
}
Line {
SrcBlock "Plant & Actuator"
SrcPort 1
Points [0, 0; 45, 0]
Branch {
Points [0, 60]
Branch {
Points [-230, 0; 0, -55]
DstBlock "Sum"
DstPort 2
}
Branch {
Labels [1, 0]
DstBlock "Out1"
DstPort 1
}
}
Branch {
DstBlock "Scope"
DstPort 1
}
}
Line {
SrcBlock "Sum"
SrcPort 1
Points [5, 0]
Branch {
DstBlock "Controller"
DstPort 1
}
Branch {
Points [0, 110]
DstBlock "Math\nFunction"
DstPort 1
}
}
Line {
SrcBlock "Step"
SrcPort 1
DstBlock "Sum"
DstPort 1
}
Line {
SrcBlock "Controller"
SrcPort 1
DstBlock "Plant & Actuator"
DstPort 1
}
Line {
SrcBlock "Math\nFunction"
SrcPort 1
DstBlock "Integrator"
DstPort 1
}
Line {
SrcBlock "Integrator"
SrcPort 1
DstBlock "To Workspace"
DstPort 1
}
Annotation {
Name "Double click here to initialize plant data and "
"optimization parameters."
Position [272, 322]
UseDisplayTextAsClickCallback off
}
Annotation {
Name "Tunable Variables are PID gains, Kp, Ki, and K"
"d."
Position [242, 17]
UseDisplayTextAsClickCallback off
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -