speedcontrol_pwm.mdl

来自「simulink real-time workshop for dragon12」· MDL 代码 · 共 736 行 · 第 1/2 页

MDL
736
字号
      System {
	Name			"ADC Input"
	Location		[584, 145, 1067, 361]
	Open			off
	ModelBrowserVisibility	off
	ModelBrowserWidth	200
	ScreenColor		"white"
	PaperOrientation	"landscape"
	PaperPositionMode	"auto"
	PaperType		"A4"
	PaperUnits		"centimeters"
	ZoomFactor		"100"
	Block {
	  BlockType		  "S-Function"
	  Name			  "Analog Input SFcn"
	  Ports			  [0, 1]
	  Position		  [25, 25, 145, 65]
	  FunctionName		  "adc_sfcn_9S12"
	  Parameters		  "bank-1, firstChannel, numChannels, use10bit"
"s-1, normalize, sampletime"
	  MaskIconFrame		  on
	  MaskIconOpaque	  on
	  MaskIconRotate	  "none"
	  MaskIconUnits		  "autoscale"
	}
	Block {
	  BlockType		  Demux
	  Name			  "Demux"
	  Ports			  [1, 1]
	  Position		  [240, 23, 245, 207]
	  BackgroundColor	  "black"
	  ShowName		  off
	  Outputs		  "1"
	}
	Block {
	  BlockType		  Outport
	  Name			  "Out1"
	  Position		  [410, 26, 430, 44]
	}
	Line {
	  SrcBlock		  "Analog Input SFcn"
	  SrcPort		  1
	  Points		  [0, 70]
	  DstBlock		  "Demux"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Demux"
	  SrcPort		  1
	  Points		  [30, 0; 0, -80]
	  DstBlock		  "Out1"
	  DstPort		  1
	}
      }
    }
    Block {
      BlockType		      Constant
      Name		      "Bias"
      Position		      [95, 45, 125, 75]
    }
    Block {
      BlockType		      Mux
      Name		      "Mux"
      Ports		      [2, 1]
      Position		      [270, 171, 275, 209]
      ShowName		      off
      Inputs		      "2"
      DisplayOption	      "bar"
    }
    Block {
      BlockType		      Reference
      Name		      "PID Controller"
      Ports		      [1, 1]
      Position		      [310, 95, 340, 125]
      SourceBlock	      "simulink_extras/Additional\nLinear/PID Controll"
"er"
      SourceType	      "PID Controller"
      P			      "1.0"
      I			      ".2"
      D			      "0.00"
    }
    Block {
      BlockType		      SubSystem
      Name		      "Pulse width modulation"
      Ports		      [1]
      Position		      [580, 70, 710, 150]
      AncestorBlock	      "mc9S12tool/Pulse width modulation"
      FontSize		      12
      TreatAsAtomicUnit	      off
      MaskHelp		      "helpview('C:\\Documents and Settings\\fwornle\\"
"My Documents\\frank\\_cProgs\\Motorola\\rtmc9S12_CW_R13\\bin\\mc9S12.map', 'm"
"c9S12_PWM_In_blkref')"
      MaskPromptString	      "Sample time|Resolution           |PWM period (8"
"-bit : up to 0.699 s, 16-bit : up to 179 s)|Pulse pin (PTP)    |Sign port    "
"           |Sign pin                |Saturation input level [simulated voltag"
"e]|Signal monitoring"
      MaskStyleString	      "edit,popup(8 bit|16 bit),edit,popup(0  (8-bit)|"
"1  (8-bit / 16-bit)|2  (8-bit)|3  (8-bit / 16-bit)|4  (8-bit)|5  (8-bit / 16-"
"bit)|6  (8-bit)|7  (8-bit / 16-bit)),popup(PORTA|PORTB|PTH|PTJ|PTM|PTP|PTT|PT"
"S),popup(0|1|2|3|4|5|6|7),edit,checkbox"
      MaskTunableValueString  "on,on,on,off,off,off,on,on"
      MaskCallbackString      "|||||||"
      MaskEnableString	      "on,on,on,on,on,on,on,on"
      MaskVisibilityString    "on,on,on,on,on,on,on,on"
      MaskToolTipString	      "on,on,on,on,on,on,on,on"
      MaskVarAliasString      ",,,,,,,"
      MaskVariables	      "sampletime=@1;resolution=@2;PWMper=@3;pulse_pin"
"=@4;sign_port=@5;sign_pin=@6;Vmax=@7;sig_mon=@8;"
      MaskInitialization      "[pulsepinstr, signportstr, signpinstr, periodst"
"r, clkABstr, resstr] = mbc_pwmoutput(sampletime, resolution, PWMper, pulse_pi"
"n, sign_port, sign_pin, Vmax, sig_mon);"
      MaskDisplay	      "fprintf('PWM-%s, %s-bit\\nPulse pin: PTP.%s\\nS"
"ign pin: %s.%s\\nPeriod: %s (s)\\nSaturation: %d', clkABstr, resstr, pulsepin"
"str, signportstr, signpinstr, periodstr, Vmax)"
      MaskSelfModifiable      on
      MaskIconFrame	      on
      MaskIconOpaque	      on
      MaskIconRotate	      "none"
      MaskIconUnits	      "autoscale"
      MaskValueString	      "0.01 |16 bit|0.01|1  (8-bit / 16-bit)|PTH|1|5|o"
"ff"
      System {
	Name			"Pulse width modulation"
	Location		[440, 403, 875, 514]
	Open			off
	ModelBrowserVisibility	off
	ModelBrowserWidth	200
	ScreenColor		"white"
	PaperOrientation	"landscape"
	PaperPositionMode	"auto"
	PaperType		"A4"
	PaperUnits		"centimeters"
	ZoomFactor		"100"
	Block {
	  BlockType		  Inport
	  Name			  "In1"
	  Position		  [50, 40, 70, 60]
	  FontSize		  12
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "MC"
	  Tag			  "MC9S12target_pwm"
	  Ports			  [1]
	  Position		  [140, 30, 255, 70]
	  List {
	    ListType		    RTWdata
	    pulsepinStr		    "1"
	    pulsepinMask	    "2"
	    signportStr		    "PTH"
	    signportddrStr	    "DDRH"
	    signpinMask		    "2"
	    signpinStr		    "1"
	    resolutionStr	    "16"
	    CLKselectStr	    "0"
	    useSCLStr		    "1"
	    PCKStr		    "0"
	    PWMSCLStr		    "2"
	    PERIODStr		    "60000"
	  }
	  FontSize		  12
	  FunctionName		  "pwm_sfcn_9S12"
	  Parameters		  "sampletime, PWMper, pulse_pin, sign_port, s"
"ign_pin, Vmax, sig_mon"
	}
	Line {
	  SrcBlock		  "In1"
	  SrcPort		  1
	  DstBlock		  "MC"
	  DstPort		  1
	}
      }
    }
    Block {
      BlockType		      Saturate
      Name		      "Saturation"
      Position		      [425, 93, 455, 127]
      UpperLimit	      "5"
      LowerLimit	      "0"
    }
    Block {
      BlockType		      Scope
      Name		      "Scope"
      Ports		      [1]
      Position		      [370, 174, 400, 206]
      Location		      [21, 490, 345, 729]
      Open		      on
      NumInputPorts	      "1"
      List {
	ListType		AxesTitles
	axes1			"%<SignalLabel>"
      }
      List {
	ListType		SelectedSignals
	axes1			""
      }
      TimeRange		      "8"
      YMin		      "-0.5"
      YMax		      "5.5"
      DataFormat	      "StructureWithTime"
    }
    Block {
      BlockType		      Scope
      Name		      "Scope2"
      Ports		      [1]
      Position		      [370, 24, 400, 56]
      Location		      [357, 491, 681, 730]
      Open		      on
      NumInputPorts	      "1"
      List {
	ListType		AxesTitles
	axes1			"%<SignalLabel>"
      }
      List {
	ListType		SelectedSignals
	axes1			""
      }
      TimeRange		      "8"
      YMin		      "-5.5"
      YMax		      "5.5"
      SaveName		      "ScopeData2"
      DataFormat	      "StructureWithTime"
    }
    Block {
      BlockType		      Scope
      Name		      "Scope3"
      Ports		      [1]
      Position		      [510, 24, 540, 56]
      Location		      [695, 490, 1019, 729]
      Open		      on
      NumInputPorts	      "1"
      List {
	ListType		AxesTitles
	axes1			"%<SignalLabel>"
      }
      List {
	ListType		SelectedSignals
	axes1			""
      }
      TimeRange		      "8"
      YMin		      "-0.5"
      YMax		      "5.5"
      SaveName		      "ScopeData3"
      DataFormat	      "StructureWithTime"
    }
    Block {
      BlockType		      Sum
      Name		      "Sum"
      Ports		      [2, 1]
      Position		      [175, 100, 195, 120]
      ShowName		      off
      IconShape		      "round"
      Inputs		      "++|"
      InputSameDT	      off
      OutDataTypeMode	      "Inherit via internal rule"
    }
    Block {
      BlockType		      Sum
      Name		      "Sum1"
      Ports		      [2, 1]
      Position		      [235, 100, 255, 120]
      ShowName		      off
      IconShape		      "round"
      Inputs		      "|+-"
      InputSameDT	      off
      OutDataTypeMode	      "Inherit via internal rule"
    }
    Block {
      BlockType		      DiscretePulseGenerator
      Name		      "set point"
      Position		      [90, 93, 135, 127]
      PulseType		      "Time based"
      Amplitude		      "4"
      Period		      "4"
      PulseWidth	      "50"
    }
    Line {
      SrcBlock		      "Saturation"
      SrcPort		      1
      Points		      [20, 0]
      Branch {
	Points			[0, -70]
	DstBlock		"Scope3"
	DstPort			1
      }
      Branch {
	DstBlock		"Pulse width modulation"
	DstPort			1
      }
    }
    Line {
      SrcBlock		      "ADC Input"
      SrcPort		      1
      Points		      [100, 0]
      Branch {
	DstBlock		"Mux"
	DstPort			2
      }
      Branch {
	DstBlock		"Sum1"
	DstPort			2
      }
    }
    Line {
      SrcBlock		      "PID Controller"
      SrcPort		      1
      DstBlock		      "Saturation"
      DstPort		      1
    }
    Line {
      SrcBlock		      "Mux"
      SrcPort		      1
      DstBlock		      "Scope"
      DstPort		      1
    }
    Line {
      SrcBlock		      "Bias"
      SrcPort		      1
      Points		      [55, 0]
      DstBlock		      "Sum"
      DstPort		      1
    }
    Line {
      SrcBlock		      "set point"
      SrcPort		      1
      DstBlock		      "Sum"
      DstPort		      2
    }
    Line {
      SrcBlock		      "Sum"
      SrcPort		      1
      Points		      [5, 0]
      Branch {
	DstBlock		"Sum1"
	DstPort			1
      }
      Branch {
	Points			[0, 70]
	DstBlock		"Mux"
	DstPort			1
      }
    }
    Line {
      SrcBlock		      "Sum1"
      SrcPort		      1
      Points		      [15, 0]
      Branch {
	DstBlock		"PID Controller"
	DstPort			1
      }
      Branch {
	Points			[0, -70]
	DstBlock		"Scope2"
	DstPort			1
      }
    }
    Annotation {
      Name		      "Test program - Speed controller"
      Position		      [27, 17]
      HorizontalAlignment     "left"
      VerticalAlignment	      "top"
      FontName		      "Times New Roman"
      FontSize		      14
      FontWeight	      "bold"
    }
  }
}

⌨️ 快捷键说明

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