⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pid_sim.mdl

📁 this is matlab pid tuning code
💻 MDL
📖 第 1 页 / 共 5 页
字号:
	  OutScaling		  "2^0"
	}
	Block {
	  BlockType		  Saturate
	  Name			  "Saturation1"
	  Position		  [135, 165, 165, 195]
	  UpperLimit		  "1-1/2^10"
	  LowerLimit		  "0"
	  SampleTime		  "pidfix_ts "
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	}
	Block {
	  BlockType		  Constant
	  Name			  "ki_fixed_point\nts = 0.1s1"
	  Position		  [50, 294, 105, 326]
	  BackgroundColor	  "green"
	  Value			  "205"
	  OutDataTypeMode	  "int16"
	  OutDataType		  "fixdt(1,16,12)"
	  ConRadixGroup		  "Best Precision: Vector-wise"
	  SampleTime		  "pidfix_ts "
	  Port {
	    PortNumber		    1
	    Name		    "ki"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  Constant
	  Name			  "kp_fixed_point1"
	  Position		  [50, 229, 105, 261]
	  BackgroundColor	  "green"
	  Value			  "2048"
	  OutDataTypeMode	  "int16"
	  OutDataType		  "fixdt(1,16,12)"
	  ConRadixGroup		  "Best Precision: Vector-wise"
	  SampleTime		  "pidfix_ts "
	  Port {
	    PortNumber		    1
	    Name		    "kp"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  Constant
	  Name			  "no rounding1"
	  Position		  [40, 439, 95, 471]
	  BackgroundColor	  "green"
	  Value			  "0"
	  OutDataTypeMode	  "int16"
	  OutDataType		  "fixdt(1,16,12)"
	  ConRadixGroup		  "Best Precision: Vector-wise"
	  SampleTime		  "pidfix_ts "
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "pid_dp_SFUN\ngenerated by LCT"
	  Ports			  [5, 1]
	  Position		  [360, 230, 790, 260]
	  FunctionName		  "pid_dp_SFUN"
	  MaskType		  "Legacy Function"
	  MaskDescription	  "This block allows the user to call the following C function(s) in Simulink:\n\n InitializeConditionsFcn: none\n\n StartFcn: none\n\n OutputFcn: int16 y1 = pid_dp(int16 u1,int16 u2,int16 u3,int16 u4,int16 u5,int32 work1[1])\n\n TerminateFcn: none\n"
	  MaskPromptString	  "SFunctionSpec|Display function specification"
	  MaskStyleString	  "edit,checkbox"
	  MaskTunableValueString  "off,on"
	  MaskCallbackString	  "|if strcmp(get_param(gcbh, 'ShowSpec'), 'on')\n  set_param(gcbh, 'MaskDisplay', sprintf('fprintf(''%s'');', get_param(gcbh, 'SFunctionSpec')));\nelse\n  set_param(gcbh, 'MaskDisplay', sprintf('fprintf(''%s'');', get_param(gcbh, 'FunctionName')));\nend"
	  MaskEnableString	  "on,on"
	  MaskVisibilityString	  "off,on"
	  MaskToolTipString	  "on,on"
	  MaskVarAliasString	  ","
	  MaskVariables		  "SFunctionSpec=&1;ShowSpec=@2"
	  MaskDisplay		  "fprintf('int16 y1 = pid_dp(int16 u1,int16 u2,int16 u3,int16 u4,int16 u5,int32 work1[1])');"
	  MaskSelfModifiable	  on
	  MaskIconFrame		  on
	  MaskIconOpaque	  on
	  MaskIconRotate	  "port"
	  MaskIconUnits		  "normalized"
	  MaskValueString	  "int16 y1 = pid_dp(int16 u1,int16 u2,int16 u3,int16 u4,int16 u5,int32 work1[1])|on"
	  MaskTabNameString	  ","
	}
	Block {
	  BlockType		  Constant
	  Name			  "rounding1"
	  Position		  [40, 379, 95, 411]
	  BackgroundColor	  "green"
	  OutDataTypeMode	  "int16"
	  OutDataType		  "fixdt(1,16,12)"
	  ConRadixGroup		  "Best Precision: Vector-wise"
	  SampleTime		  "pidfix_ts "
	}
	Block {
	  BlockType		  Outport
	  Name			  "uc"
	  Position		  [1025, 258, 1055, 272]
	  IconDisplay		  "Port number"
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	}
	Line {
	  SrcBlock		  "no rounding1"
	  SrcPort		  1
	  Points		  [30, 0]
	  DstBlock		  "Manual Switch1"
	  DstPort		  2
	}
	Line {
	  SrcBlock		  "rounding1"
	  SrcPort		  1
	  Points		  [30, 0]
	  DstBlock		  "Manual Switch1"
	  DstPort		  1
	}
	Line {
	  Name			  "ki"
	  Labels		  [0, 0]
	  SrcBlock		  "ki_fixed_point\nts = 0.1s1"
	  SrcPort		  1
	  Points		  [235, 0]
	  DstBlock		  "pid_dp_SFUN\ngenerated by LCT"
	  DstPort		  4
	}
	Line {
	  Name			  "kp"
	  Labels		  [0, 0]
	  SrcBlock		  "kp_fixed_point1"
	  SrcPort		  1
	  DstBlock		  "pid_dp_SFUN\ngenerated by LCT"
	  DstPort		  3
	}
	Line {
	  Name			  "rounding"
	  Labels		  [3, 0]
	  SrcBlock		  "Manual Switch1"
	  SrcPort		  1
	  Points		  [80, 0; 0, -170]
	  DstBlock		  "pid_dp_SFUN\ngenerated by LCT"
	  DstPort		  5
	}
	Line {
	  SrcBlock		  "pid_dp_SFUN\ngenerated by LCT"
	  SrcPort		  1
	  DstBlock		  "Gain2"
	  DstPort		  1
	}
	Line {
	  Name			  "yr"
	  Labels		  [0, 0]
	  SrcBlock		  "yr"
	  SrcPort		  1
	  DstBlock		  "Saturation"
	  DstPort		  1
	}
	Line {
	  Name			  "ym"
	  Labels		  [0, 0]
	  SrcBlock		  "ym"
	  SrcPort		  1
	  DstBlock		  "Saturation1"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Data Type Conversion"
	  SrcPort		  1
	  Points		  [30, 0]
	  DstBlock		  "pid_dp_SFUN\ngenerated by LCT"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Data Type Conversion1"
	  SrcPort		  1
	  Points		  [30, 0]
	  DstBlock		  "pid_dp_SFUN\ngenerated by LCT"
	  DstPort		  2
	}
	Line {
	  Name			  "u_fxp_dp"
	  Labels		  [1, 0]
	  SrcBlock		  "Gain2"
	  SrcPort		  1
	  Points		  [115, 0]
	  DstBlock		  "uc"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Gain1"
	  SrcPort		  1
	  DstBlock		  "Data Type Conversion"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Gain3"
	  SrcPort		  1
	  DstBlock		  "Data Type Conversion1"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Saturation"
	  SrcPort		  1
	  DstBlock		  "Gain1"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Saturation1"
	  SrcPort		  1
	  DstBlock		  "Gain3"
	  DstPort		  1
	}
      }
    }
    Block {
      BlockType		      SubSystem
      Name		      "16-bits pid controller single precision\n(discrete)"
      Ports		      [2, 1]
      Position		      [245, 405, 385, 460]
      Orientation	      "left"
      BackgroundColor	      "magenta"
      MinAlgLoopOccurrences   off
      RTWSystemCode	      "Auto"
      FunctionWithSeparateData off
      Port {
	PortNumber		1
	Name			"u_fxp_sp"
	PropagatedSignals	"u_fxp_dp"
	RTWStorageClass		"Auto"
	DataLoggingNameMode	"SignalName"
      }
      System {
	Name			"16-bits pid controller single precision\n(discrete)"
	Location		[127, 235, 1233, 686]
	Open			off
	ModelBrowserVisibility	off
	ModelBrowserWidth	200
	ScreenColor		"white"
	PaperOrientation	"landscape"
	PaperPositionMode	"auto"
	PaperType		"A4"
	PaperUnits		"centimeters"
	TiledPaperMargins	[0.500000, 0.500000, 0.500000, 0.500000]
	TiledPageScale		1
	ShowPageBoundaries	off
	ZoomFactor		"100"
	Block {
	  BlockType		  Inport
	  Name			  "yr"
	  Position		  [50, 43, 80, 57]
	  IconDisplay		  "Port number"
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	  Port {
	    PortNumber		    1
	    Name		    "yr"
	    PropagatedSignals	    "yr"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  Inport
	  Name			  "ym"
	  Position		  [50, 93, 80, 107]
	  Port			  "2"
	  IconDisplay		  "Port number"
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	  Port {
	    PortNumber		    1
	    Name		    "ym"
	    PropagatedSignals	    "ym_fxp_sp"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  DataTypeConversion
	  Name			  "Data Type Conversion"
	  Position		  [290, 33, 320, 67]
	  OutDataTypeMode	  "int16"
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	  ConvertRealWorld	  "Stored Integer (SI)"
	  RndMeth		  "Floor"
	  SaturateOnIntegerOverflow off
	  SampleTime		  "pidfix_ts "
	}
	Block {
	  BlockType		  DataTypeConversion
	  Name			  "Data Type Conversion1"
	  Position		  [290, 83, 320, 117]
	  OutDataTypeMode	  "int16"
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	  ConvertRealWorld	  "Stored Integer (SI)"
	  RndMeth		  "Floor"
	  SaturateOnIntegerOverflow off
	  SampleTime		  "pidfix_ts "
	}
	Block {
	  BlockType		  Gain
	  Name			  "Gain1"
	  Position		  [200, 29, 240, 71]
	  Gain			  "2^10"
	  ParameterDataTypeMode	  "double"
	  ParameterDataType	  "sfix(16)"
	  ParameterScaling	  "2^0"
	  OutDataTypeMode	  "double"
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	  SaturateOnIntegerOverflow off
	  SampleTime		  "pidfix_ts "
	}
	Block {
	  BlockType		  Gain
	  Name			  "Gain2"
	  Position		  [885, 99, 925, 141]
	  Gain			  "1/2^10"
	  ParameterDataTypeMode	  "double"
	  ParameterDataType	  "sfix(16)"
	  ParameterScaling	  "2^0"
	  OutDataTypeMode	  "double"
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	  SaturateOnIntegerOverflow off
	  SampleTime		  "pidfix_ts "
	  Port {
	    PortNumber		    1
	    Name		    "u_fxp_dp"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  Gain
	  Name			  "Gain3"
	  Position		  [200, 79, 240, 121]
	  Gain			  "2^10"
	  ParameterDataTypeMode	  "double"
	  ParameterDataType	  "sfix(16)"
	  ParameterScaling	  "2^0"
	  OutDataTypeMode	  "double"
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	  SaturateOnIntegerOverflow off
	  SampleTime		  "pidfix_ts "
	}
	Block {
	  BlockType		  Reference
	  Name			  "Manual Switch"
	  Ports			  [2, 1]
	  Position		  [215, 317, 245, 353]
	  SourceBlock		  "simulink/Signal\nRouting/Manual Switch"
	  SourceType		  "Manual Switch"
	  ShowPortLabels	  "FromPortIcon"
	  SystemSampleTime	  "-1"
	  FunctionWithSeparateData off
	  RTWMemSecFuncInitTerm	  "Inherit from model"
	  RTWMemSecFuncExecute	  "Inherit from model"
	  RTWMemSecDataConstants  "Inherit from model"
	  RTWMemSecDataInternal	  "Inherit from model"
	  RTWMemSecDataParameters "Inherit from model"
	  sw			  "0"
	  action		  "0"
	  varsize		  off
	  Port {
	    PortNumber		    1
	    Name		    "rounding"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  Saturate
	  Name			  "Saturation"
	  Position		  [135, 35, 165, 65]
	  UpperLimit		  "1-1/2^10"
	  LowerLimit		  "0"
	  SampleTime		  "pidfix_ts "
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	}
	Block {
	  BlockType		  Saturate
	  Name			  "Saturation1"
	  Position		  [135, 85, 165, 115]
	  UpperLimit		  "1-1/2^10"
	  LowerLimit		  "0"
	  SampleTime		  "pidfix_ts "
	  OutDataType		  "sfix(16)"
	  OutScaling		  "2^0"
	}
	Block {
	  BlockType		  Constant
	  Name			  "ki_fixed_point\nts = 0.1s"
	  Position		  [110, 184, 165, 216]
	  BackgroundColor	  "green"
	  Value			  "205"
	  OutDataTypeMode	  "int16"
	  OutDataType		  "fixdt(1,16,12)"
	  ConRadixGroup		  "Best Precision: Vector-wise"
	  SampleTime		  "pidfix_ts "
	  Port {
	    PortNumber		    1
	    Name		    "ki"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  Constant
	  Name			  "kp_fixed_point"
	  Position		  [110, 134, 165, 166]
	  BackgroundColor	  "green"
	  Value			  "2048"
	  OutDataTypeMode	  "int16"
	  OutDataType		  "fixdt(1,16,12)"
	  ConRadixGroup		  "Best Precision: Vector-wise"
	  SampleTime		  "pidfix_ts "
	  Port {
	    PortNumber		    1
	    Name		    "kp"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  Constant
	  Name			  "no rounding"
	  Position		  [110, 354, 165, 386]
	  BackgroundColor	  "green"
	  Value			  "0"
	  OutDataTypeMode	  "int16"
	  OutDataType		  "fixdt(1,16,12)"
	  ConRadixGroup		  "Best Precision: Vector-wise"
	  SampleTime		  "pidfix_ts "
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "pid_sp_SFUN\ngenerated by LCT"
	  Ports			  [5, 1]
	  Position		  [390, 105, 820, 135]
	  FunctionName		  "pid_sp_SFUN"
	  MaskType		  "Legacy Function"
	  MaskDescription	  "This block allows the user to call the following C function(s) in Simulink:\n\n InitializeConditionsFcn: none\n\n StartFcn: none\n\n OutputFcn: int16 y1 = pid_sp(int16 u1,int16 u2,int16 u3,int16 u4,int16 u5,int16 work1[1])\n\n TerminateFcn: none\n"
	  MaskPromptString	  "SFunctionSpec|Display function specification"
	  MaskStyleString	  "edit,checkbox"
	  MaskTunableValueString  "off,on"
	  MaskCallbackString	  "|if strcmp(get_param(gcbh, 'ShowSpec'), 'on')\n  set_param(gcbh, 'MaskDisplay', sprintf('fprintf(''%s'');', get_param(gcbh, 'SFunctionSpec')));\nelse\n  set_param(gcbh, 'MaskDisplay', sprintf('fprintf(''%s'');', get_param(gcbh, 'FunctionName')));\nend"
	  MaskEnableString	  "on,on"
	  MaskVisibilityString	  "off,on"
	  MaskToolTipString	  "on,on"
	  MaskVarAliasString	  ","
	  MaskVariables		  "SFunctionSpec=&1;ShowSpec=@2"
	  MaskDisplay		  "fprintf('int16 y1 = pid_sp(int16 u1,int16 u2,int16 u3,int16 u4,int16 u5,int16 work1[1])');"
	  MaskSelfModifiable	  on
	  MaskIconFrame		  on
	  MaskIconOpaque	  on
	  MaskIconRotate	  "port"
	  MaskIconUnits		  "normalized"
	  MaskValueString	  "int16 y1 = pid_sp(int16 u1,int16 u2,int16 u3,int16 u4,int16 u5,int16 work1[1])|on"
	  MaskTabNameString	  ","
	  Port {
	    PortNumber		    1
	    Name		    "u_fixed_point_sp"
	    RTWStorageClass	    "Auto"
	    DataLoggingNameMode	    "SignalName"
	  }
	}
	Block {
	  BlockType		  Constant
	  Name			  "rounding to the nearest"
	  Position		  [110, 294, 165, 326]
	  BackgroundColor	  "green"
	  OutDataTypeMode	  "int16"
	  OutDataType		  "fixdt(1,16,12)"
	  ConRadixGroup		  "Best Precision: Vector-wise"
	  SampleTime		  "pidfix_ts "
	}
	Block {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -