📄 testbcirobot.mdl
字号:
MaskStyleString "edit,edit,edit"
MaskTunableValueString "on,on,on"
MaskCallbackString "||"
MaskEnableString "on,on,on"
MaskVisibilityString "on,on,on"
MaskToolTipString "on,on,on"
MaskVarAliasString ",,"
MaskVariables "Nmax=@1;Ninc=@2;Ts=@3;"
MaskInitialization "Nmax = floor(abs(Nmax));\nNinc = max(1, floor(a"
"bs(Ninc)));\nif (Ninc > Nmax)\n error(['Stepper motor driver: Invalid "
"number of increments (Ninc = ' num2str(Ninc) '; value must be smaller or equa"
"l to Nmax = ' num2str(Nmax) ')'])\nend\n\n% work out pulse length\nTpulse_ = "
"1/Nmax/2;\n%disp(['Pulse length: ' num2str(1000*Tpulse_) ' ms.'])\n\n% ensure"
" that sample time is fixed multiple of 'Ts'\nTpulse = ceil(Tpulse_/Ts)*Ts;\ni"
"f (Tpulse > Tpulse_)\n disp('Decreasing maximum number of pulses per s"
"econd to ensure that the pulse duration is an integer multiple of ''Ts''')\n"
" \n % adjust Nmax\n Nmax = floor(1/Tpulse/2);\n d"
"isp(['New Nmax: ' num2str(Nmax) ' pulses per second.'])\nend\n \n% wor"
"k out quantization interval\ndQ = floor(Nmax/Ninc);"
MaskIconFrame on
MaskIconOpaque on
MaskIconRotate "none"
MaskIconUnits "autoscale"
MaskValueString "200|20|2e-3"
System {
Name "right stepper motor driver"
Location [115, 151, 1014, 474]
Open off
ModelBrowserVisibility off
ModelBrowserWidth 200
ScreenColor "white"
PaperOrientation "landscape"
PaperPositionMode "auto"
PaperType "A4"
PaperUnits "centimeters"
ZoomFactor "100"
Block {
BlockType Inport
Name "VelocityIn [-1 to 1]"
Position [825, 223, 855, 237]
Orientation "left"
}
Block {
BlockType Saturate
Name "0 ... 1"
Position [525, 215, 555, 245]
Orientation "left"
UpperLimit "1"
LowerLimit "0"
}
Block {
BlockType Abs
Name "Abs"
Position [575, 215, 605, 245]
Orientation "left"
ShowName off
SaturateOnIntegerOverflow off
}
Block {
BlockType Constant
Name "Constant"
Position [190, 40, 220, 70]
Orientation "left"
ShowName off
Value "0"
}
Block {
BlockType Constant
Name "Constant1"
Position [40, 85, 70, 115]
ShowName off
}
Block {
BlockType Constant
Name "Constant3"
Position [525, 175, 555, 205]
Orientation "left"
ShowName off
}
Block {
BlockType Constant
Name "Constant4"
Position [665, 180, 695, 210]
Orientation "left"
ShowName off
Value "0"
}
Block {
BlockType Constant
Name "Constant5"
Position [250, 260, 280, 290]
ShowName off
Value "Nmax"
}
Block {
BlockType Constant
Name "Constant6"
Position [350, 180, 380, 210]
Orientation "left"
ShowName off
}
Block {
BlockType DataTypeConversion
Name "Data Type Conversion"
Position [730, 86, 785, 114]
ShowName off
DataType "double"
}
Block {
BlockType DataTypeConversion
Name "Data Type Conversion1"
Position [730, 146, 785, 174]
ShowName off
DataType "double"
}
Block {
BlockType Gain
Name "Gain"
Position [400, 213, 445, 247]
Orientation "left"
Gain "Nmax"
}
Block {
BlockType Quantizer
Name "Quantizer"
Position [350, 215, 380, 245]
Orientation "left"
QuantizationInterval "dQ"
}
Block {
BlockType RelationalOperator
Name "Relational\nOperator"
Position [350, 82, 380, 113]
ShowName off
InputSameDT off
LogicOutDataTypeMode "Specify via dialog"
}
Block {
BlockType RelationalOperator
Name "Relational\nOperator1"
Position [250, 222, 280, 253]
Orientation "left"
ShowName off
Operator "=="
InputSameDT off
LogicOutDataTypeMode "Specify via dialog"
}
Block {
BlockType Sum
Name "Sum"
Ports [2, 1]
Position [105, 90, 125, 110]
NamePlacement "alternate"
ShowName off
IconShape "round"
Inputs "++|"
InputSameDT off
OutDataTypeMode "Inherit via internal rule"
SaturateOnIntegerOverflow off
}
Block {
BlockType Sum
Name "Sum1"
Ports [2, 1]
Position [480, 220, 500, 240]
Orientation "left"
NamePlacement "alternate"
ShowName off
IconShape "round"
Inputs "+-|"
InputSameDT off
OutDataTypeMode "Inherit via internal rule"
SaturateOnIntegerOverflow off
}
Block {
BlockType Sum
Name "Sum2"
Ports [2, 1]
Position [225, 125, 245, 145]
Orientation "left"
NamePlacement "alternate"
ShowName off
IconShape "round"
Inputs "|++"
InputSameDT off
OutDataTypeMode "Inherit via internal rule"
SaturateOnIntegerOverflow off
}
Block {
BlockType Sum
Name "Sum3"
Ports [2, 1]
Position [305, 185, 325, 205]
Orientation "up"
ShowName off
IconShape "round"
Inputs "|++"
InputSameDT off
OutDataTypeMode "Inherit via internal rule"
SaturateOnIntegerOverflow off
}
Block {
BlockType Switch
Name "Switch"
Position [190, 75, 220, 105]
Criteria "u2 > Threshold"
InputSameDT off
SaturateOnIntegerOverflow off
}
Block {
BlockType UnitDelay
Name "Unit Delay"
Position [245, 73, 280, 107]
ShowName off
SampleTime "Tpulse"
}
Block {
BlockType RelationalOperator
Name "compare"
Position [665, 142, 695, 173]
ShowName off
InputSameDT off
LogicOutDataTypeMode "Specify via dialog"
}
Block {
BlockType Outport
Name "PulseOut"
Position [825, 93, 855, 107]
}
Block {
BlockType Outport
Name "Sign"
Position [825, 153, 855, 167]
Port "2"
}
Line {
SrcBlock "Data Type Conversion1"
SrcPort 1
DstBlock "Sign"
DstPort 1
}
Line {
SrcBlock "Data Type Conversion"
SrcPort 1
DstBlock "PulseOut"
DstPort 1
}
Line {
SrcBlock "Switch"
SrcPort 1
DstBlock "Unit Delay"
DstPort 1
}
Line {
SrcBlock "Unit Delay"
SrcPort 1
Points [30, 0]
Branch {
DstBlock "Relational\nOperator"
DstPort 1
}
Branch {
Points [0, -60; -200, 0]
DstBlock "Sum"
DstPort 1
}
}
Line {
SrcBlock "Relational\nOperator"
SrcPort 1
Points [0, 0; 25, 0]
Branch {
DstBlock "Data Type Conversion"
DstPort 1
}
Branch {
Points [0, 35]
DstBlock "Sum2"
DstPort 1
}
}
Line {
SrcBlock "Sum"
SrcPort 1
DstBlock "Switch"
DstPort 3
}
Line {
SrcBlock "Constant"
SrcPort 1
Points [-20, 0; 0, 25]
DstBlock "Switch"
DstPort 1
}
Line {
SrcBlock "compare"
SrcPort 1
DstBlock "Data Type Conversion1"
DstPort 1
}
Line {
SrcBlock "Constant4"
SrcPort 1
Points [-15, 0; 0, -30]
DstBlock "compare"
DstPort 2
}
Line {
SrcBlock "Quantizer"
SrcPort 1
Points [0, 0; -30, 0]
Branch {
DstBlock "Relational\nOperator1"
DstPort 1
}
Branch {
DstBlock "Sum3"
DstPort 1
}
}
Line {
SrcBlock "Gain"
SrcPort 1
DstBlock "Quantizer"
DstPort 1
}
Line {
SrcBlock "VelocityIn [-1 to 1]"
SrcPort 1
Points [-105, 0; -80, 0]
Branch {
DstBlock "Abs"
DstPort 1
}
Branch {
Points [0, -80]
DstBlock "compare"
DstPort 1
}
}
Line {
SrcBlock "Constant3"
SrcPort 1
Points [-30, 0]
DstBlock "Sum1"
DstPort 1
}
Line {
SrcBlock "Abs"
SrcPort 1
DstBlock "0 ... 1"
DstPort 1
}
Line {
SrcBlock "Sum1"
SrcPort 1
DstBlock "Gain"
DstPort 1
}
Line {
SrcBlock "0 ... 1"
SrcPort 1
DstBlock "Sum1"
DstPort 2
}
Line {
SrcBlock "Constant5"
SrcPort 1
Points [10, 0]
DstBlock "Relational\nOperator1"
DstPort 2
}
Line {
SrcBlock "Sum2"
SrcPort 1
Points [-60, 0; 0, -45]
DstBlock "Switch"
DstPort 2
}
Line {
SrcBlock "Relational\nOperator1"
SrcPort 1
Points [-10, 0]
DstBlock "Sum2"
DstPort 2
}
Line {
SrcBlock "Constant6"
SrcPort 1
DstBlock "Sum3"
DstPort 2
}
Line {
SrcBlock "Sum3"
SrcPort 1
Points [0, -75]
DstBlock "Relational\nOperator"
DstPort 2
}
Line {
SrcBlock "Constant1"
SrcPort 1
DstBlock "Sum"
DstPort 2
}
}
}
Block {
BlockType Constant
Name "vleft"
Position [55, 155, 85, 185]
NamePlacement "alternate"
Value "-0.9"
}
Block {
BlockType Constant
Name "vright"
Position [55, 195, 85, 225]
Value "0.8"
}
Line {
SrcBlock "left stepper motor driver"
SrcPort 1
Points [100, 0]
DstBlock "Velocity left"
DstPort 1
}
Line {
SrcBlock "left stepper motor driver"
SrcPort 2
Points [100, 0]
DstBlock "Direction left"
DstPort 1
}
Line {
SrcBlock "right stepper motor driver"
SrcPort 1
Points [100, 0]
DstBlock "Velocity right"
DstPort 1
}
Line {
SrcBlock "right stepper motor driver"
SrcPort 2
Points [100, 0]
DstBlock "Direction right"
DstPort 1
}
Line {
SrcBlock "Motor Power\nControl"
SrcPort 1
DstBlock "Motor Enable Pin"
DstPort 1
}
Line {
SrcBlock "vleft"
SrcPort 1
Points [50, 0]
Branch {
DstBlock "Motor Power\nControl"
DstPort 1
}
Branch {
Points [0, -70]
DstBlock "left stepper motor driver"
DstPort 1
}
}
Line {
SrcBlock "vright"
SrcPort 1
Points [50, 0]
Branch {
DstBlock "Motor Power\nControl"
DstPort 2
}
Branch {
Points [0, 75]
DstBlock "right stepper motor driver"
DstPort 1
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -