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

📄 lugr.txt

📁 私服系统低速摩擦的条件下PID控制Matlab仿真程序源码
💻 TXT
📖 第 1 页 / 共 2 页
字号:
%PID Control based on Lugre friction model
clear all;
close all;

ts=0.001;
u_1=0;
qq=zeros(3,1);

for k=1:1:15000
  
time(k)=k*ts;
rin(k)=0.05*sin(0.1*2*pi*k*ts);
drin(k)=0.05*0.1*2*pi*cos(0.1*2*pi*k*ts);;

%Lugre friction model
[tt,yy]=ode15s('chap9_1eq',[0 ts],qq,[],u_1);
qq=yy(length(yy),:);
yout(k)=qq(1); 
y2(k)=qq(2); 

u(k)=50*(rin(k)-yout(k))+0.010*(drin(k)-y2(k))/ts;
u_1=u(k);
end
figure(1);
plot(time,rin,'r',time,yout,'b');
xlabel('time(s)');ylabel('Position tracking');
figure(2);
plot(time,drin,'r',time,y2,'b');
xlabel('time(s)');ylabel('Speed tracking');


	function dy=dym(t,y,flag,uk)

	c0=260; 
	c1=2.5; 
	c2=0.02;
	Fc=0.28; 
	Fs=0.34;
	Vs=0.01;
	J=1.0;

	dy=[0,0,0]';

	g=Fc+(Fs-Fc)*exp(-(y(2)/Vs)^2)+c2*y(2);

	dy(3)=y(2)-(c0*abs(y(2))/g)*y(3);
	F=c0*y(3)+c1*dy(3)+c2*y(2);
	dy(2)=1/J*(uk-F);
	dy(1)=y(2);



Model {
  Name			  "chap9_2"
  Version		  3.00
  SimParamPage		  "Solver"
  SampleTimeColors	  off
  InvariantConstants	  off
  WideVectorLines	  off
  ShowLineWidths	  off
  ShowPortDataTypes	  off
  StartTime		  "0.0"
  StopTime		  "20"
  SolverMode		  "Auto"
  Solver		  "ode45"
  RelTol		  "1e-3"
  AbsTol		  "auto"
  Refine		  "1"
  MaxStep		  "auto"
  InitialStep		  "auto"
  FixedStep		  "auto"
  MaxOrder		  5
  OutputOption		  "RefineOutputTimes"
  OutputTimes		  "[]"
  LoadExternalInput	  off
  ExternalInput		  "[t, u]"
  SaveTime		  on
  TimeSaveName		  "tout"
  SaveState		  off
  StateSaveName		  "xout"
  SaveOutput		  on
  OutputSaveName	  "yout"
  LoadInitialState	  off
  InitialState		  "xInitial"
  SaveFinalState	  off
  FinalStateName	  "xFinal"
  SaveFormat		  "Matrix"
  LimitMaxRows		  off
  MaxRows		  "1000"
  Decimation		  "1"
  AlgebraicLoopMsg	  "warning"
  MinStepSizeMsg	  "warning"
  UnconnectedInputMsg	  "warning"
  UnconnectedOutputMsg	  "warning"
  UnconnectedLineMsg	  "warning"
  InheritedTsInSrcMsg	  "warning"
  IntegerOverflowMsg	  "warning"
  UnnecessaryDatatypeConvMsg "none"
  Int32ToFloatConvMsg	  "warning"
  SignalLabelMismatchMsg  "none"
  ConsistencyChecking	  "off"
  ZeroCross		  on
  SimulationMode	  "normal"
  BlockDataTips		  on
  BlockParametersDataTip  on
  BlockAttributesDataTip  off
  BlockPortWidthsDataTip  off
  BlockDescriptionStringDataTip	off
  BlockMaskParametersDataTip off
  ToolBar		  on
  StatusBar		  on
  BrowserShowLibraryLinks off
  BrowserLookUnderMasks	  off
  OptimizeBlockIOStorage  on
  BufferReuse		  on
  BooleanDataType	  off
  RTWSystemTargetFile	  "grt.tlc"
  RTWInlineParameters	  off
  RTWRetainRTWFile	  off
  RTWTemplateMakefile	  "grt_default_tmf"
  RTWMakeCommand	  "make_rtw"
  RTWGenerateCodeOnly	  off
  ExtModeMexFile	  "ext_comm"
  ExtModeBatchMode	  off
  ExtModeTrigType	  "manual"
  ExtModeTrigMode	  "oneshot"
  ExtModeTrigPort	  "1"
  ExtModeTrigElement	  "any"
  ExtModeTrigDuration	  1000
  ExtModeTrigHoldOff	  0
  ExtModeTrigDelay	  0
  ExtModeTrigDirection	  "rising"
  ExtModeTrigLevel	  0
  ExtModeArchiveMode	  "off"
  ExtModeAutoIncOneShot	  off
  ExtModeIncDirWhenArm	  off
  ExtModeAddSuffixToVar	  off
  ExtModeWriteAllDataToWs off
  ExtModeArmWhenConnect	  off
  Created		  "Sun Sep 03 10:58:19 2000"
  UpdateHistory		  "UpdateHistoryNever"
  ModifiedByFormat	  "%<Auto>"
  ModifiedDateFormat	  "%<Auto>"
  LastModifiedDate	  "Thu Jun 10 22:46:13 2004"
  ModelVersionFormat	  "1.%<AutoIncrement:183>"
  ConfigurationManager	  "none"
  BlockDefaults {
    Orientation		    "right"
    ForegroundColor	    "black"
    BackgroundColor	    "white"
    DropShadow		    off
    NamePlacement	    "normal"
    FontName		    "Helvetica"
    FontSize		    10
    FontWeight		    "normal"
    FontAngle		    "normal"
    ShowName		    on
  }
  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		    "chap9_2"
    Location		    [5, 62, 805, 525]
    Open		    on
    ModelBrowserVisibility  off
    ModelBrowserWidth	    200
    ScreenColor		    "automatic"
    PaperOrientation	    "landscape"
    PaperPositionMode	    "auto"
    PaperType		    "usletter"
    PaperUnits		    "inches"
    ZoomFactor		    "100"
    AutoZoom		    on
    ReportName		    "simulink-default.rpt"
    Block {
      BlockType		      Derivative
      Name		      "Derivative"
      Position		      [525, 40, 555, 70]
    }
    Block {
      BlockType		      Gain
      Name		      "Gain"
      Position		      [380, 155, 410, 185]
      Gain		      "1/J"
      SaturateOnIntegerOverflow	on
    }
    Block {
      BlockType		      Integrator
      Name		      "Integrator"
      Ports		      [1, 1, 0, 0, 0]
      Position		      [430, 155, 460, 185]
      ExternalReset	      "none"
      InitialConditionSource  "internal"
      InitialCondition	      "0"
      LimitOutput	      off
      UpperSaturationLimit    "inf"
      LowerSaturationLimit    "-inf"
      ShowSaturationPort      off
      ShowStatePort	      off
      AbsoluteTolerance	      "auto"
    }
    Block {
      BlockType		      Integrator
      Name		      "Integrator1"
      Ports		      [1, 1, 0, 0, 0]
      Position		      [490, 155, 520, 185]
      ExternalReset	      "none"
      InitialConditionSource  "internal"
      InitialCondition	      "0"
      LimitOutput	      off
      UpperSaturationLimit    "inf"
      LowerSaturationLimit    "-inf"
      ShowSaturationPort      off
      ShowStatePort	      off
      AbsoluteTolerance	      "auto"
    }
    Block {
      BlockType		      SubSystem
      Name		      "Lugre friction"
      Ports		      [1, 1, 0, 0, 0]
      Position		      [255, 186, 300, 224]
      ShowPortLabels	      on
      System {
	Name			"Lugre friction"
	Location		[1, 42, 805, 608]
	Open			on
	ModelBrowserVisibility	off
	ModelBrowserWidth	200
	ScreenColor		"automatic"
	PaperOrientation	"landscape"
	PaperPositionMode	"auto"
	PaperType		"usletter"
	PaperUnits		"inches"
	ZoomFactor		"100"
	AutoZoom		on
	Block {
	  BlockType		  Inport
	  Name			  "In1"
	  Position		  [130, 143, 160, 157]
	  Port			  "1"
	  PortWidth		  "-1"
	  SampleTime		  "-1"
	  DataType		  "auto"
	  SignalType		  "auto"
	  Interpolate		  on
	}
	Block {
	  BlockType		  Demux
	  Name			  "Demux"
	  Ports			  [1, 3, 0, 0, 0]
	  Position		  [305, 105, 350, 195]
	  ShowName		  off
	  Outputs		  "3"
	}
	Block {
	  BlockType		  Derivative
	  Name			  "Derivative"
	  Position		  [415, 240, 445, 270]
	}
	Block {
	  BlockType		  Scope
	  Name			  "F"
	  Ports			  [1, 0, 0, 0, 0]
	  Position		  [665, 189, 695, 221]
	  Floating		  off
	  Location		  [202, 147, 634, 436]
	  Open			  on
	  NumInputPorts		  "1"
	  TickLabels		  "OneTimeTick"
	  ZoomMode		  "on"
	  List {
	    ListType		    AxesTitles
	    axes1		    "%<SignalLabel>"
	  }
	  Grid			  "on"
	  TimeRange		  "10"
	  YMin			  "-1"
	  YMax			  "1"
	  SaveToWorkspace	  off
	  SaveName		  "ScopeData"
	  DataFormat		  "StructureWithTime"
	  LimitMaxRows		  on
	  MaxRows		  "5000"
	  Decimation		  "1"
	  SampleInput		  off
	  SampleTime		  "0"
	}
	Block {
	  BlockType		  Fcn
	  Name			  "Fcn"
	  Position		  [550, 240, 610, 270]
	  Expr			  "rou0*u(1)+rou1*u(2)+af*u(3)"
	}
	Block {
	  BlockType		  Mux
	  Name			  "Mux1"
	  Ports			  [3, 1, 0, 0, 0]
	  Position		  [490, 221, 520, 289]
	  ShowName		  off
	  Inputs		  "3"
	  DisplayOption		  "none"
	}
	Block {
	  BlockType		  "S-Function"
	  Name			  "S-Function"
	  Ports			  [1, 1, 0, 0, 0]
	  Position		  [195, 134, 280, 166]
	  FunctionName		  "chap9_2s"
	  PortCounts		  "[]"
	  SFunctionModules	  "''"
	}
	Block {
	  BlockType		  Scope
	  Name			  "angle"
	  Ports			  [1, 0, 0, 0, 0]
	  Position		  [450, 104, 480, 136]
	  Floating		  off
	  Location		  [182, 297, 693, 536]
	  Open			  off
	  NumInputPorts		  "1"
	  TickLabels		  "OneTimeTick"
	  ZoomMode		  "on"
	  List {
	    ListType		    AxesTitles
	    axes1		    "%<SignalLabel>"
	  }
	  Grid			  "on"
	  TimeRange		  "10"
	  YMin			  "-1"
	  YMax			  "1"
	  SaveToWorkspace	  off
	  SaveName		  "ScopeData"
	  DataFormat		  "StructureWithTime"
	  LimitMaxRows		  on
	  MaxRows		  "5000"
	  Decimation		  "1"
	  SampleInput		  off
	  SampleTime		  "0"
	}
	Block {
	  BlockType		  Scope
	  Name			  "speed"
	  Ports			  [1, 0, 0, 0, 0]
	  Position		  [440, 324, 470, 356]
	  Floating		  off
	  Location		  [182, 297, 693, 536]
	  Open			  off
	  NumInputPorts		  "1"
	  TickLabels		  "OneTimeTick"
	  ZoomMode		  "on"
	  List {
	    ListType		    AxesTitles
	    axes1		    "%<SignalLabel>"
	  }
	  Grid			  "on"
	  TimeRange		  "10"
	  YMin			  "-1"
	  YMax			  "1"
	  SaveToWorkspace	  off
	  SaveName		  "ScopeData"
	  DataFormat		  "StructureWithTime"
	  LimitMaxRows		  on
	  MaxRows		  "5000"
	  Decimation		  "1"
	  SampleInput		  off
	  SampleTime		  "0"
	}
	Block {
	  BlockType		  Scope
	  Name			  "z"
	  Ports			  [1, 0, 0, 0, 0]
	  Position		  [540, 164, 570, 196]
	  Floating		  off
	  Location		  [182, 297, 693, 536]
	  Open			  on
	  NumInputPorts		  "1"
	  TickLabels		  "OneTimeTick"
	  ZoomMode		  "on"
	  List {
	    ListType		    AxesTitles
	    axes1		    "%<SignalLabel>"
	  }
	  Grid			  "on"
	  TimeRange		  "10"
	  YMin			  "-1"
	  YMax			  "1"
	  SaveToWorkspace	  off
	  SaveName		  "ScopeData"
	  DataFormat		  "StructureWithTime"
	  LimitMaxRows		  on
	  MaxRows		  "5000"
	  Decimation		  "1"
	  SampleInput		  off
	  SampleTime		  "0"
	}
	Block {
	  BlockType		  Outport
	  Name			  "Out1"
	  Position		  [685, 248, 715, 262]
	  Port			  "1"
	  OutputWhenDisabled	  "held"
	  InitialOutput		  "[]"
	}
	Line {
	  SrcBlock		  "S-Function"
	  SrcPort		  1
	  DstBlock		  "Demux"
	  DstPort		  1
	}
	Line {
	  SrcBlock		  "Demux"
	  SrcPort		  3
	  Points		  [40, 0]
	  Branch {
	    Points		    [0, 75]
	    DstBlock		    "Derivative"
	    DstPort		    1
	  }
	  Branch {
	    Points		    [60, 0]
	    Branch {
	      Points		      [0, 55]
	      DstBlock		      "Mux1"
	      DstPort		      1
	    }
	    Branch {
	      DstBlock		      "z"
	      DstPort		      1
	    }
	  }
	}

⌨️ 快捷键说明

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