matlab曲柄滑块机构的运动学仿真.docx
《matlab曲柄滑块机构的运动学仿真.docx》由会员分享,可在线阅读,更多相关《matlab曲柄滑块机构的运动学仿真.docx(10页珍藏版)》请在冰豆网上搜索。
matlab曲柄滑块机构的运动学仿真
《系统仿真与matlab》综合试题
题目:
曲柄滑块机构的运动学仿真
编号:
21
难度系数:
姓名
班级
学号
联系方式
成绩
错误!
未定义书签
错误!
未定义书签错误!
未定义书签错误!
未定义书签错误!
未定义书签错误!
未定义书签错误!
未定义书签
一、引言
二、运动学分析
1、实例题目
2、运动分析
三、MATLA程序编写
四、使用指南和实例仿真
五、结语
、引言
曲柄滑块机构是指用曲柄和滑块来实现转动和移动相互转换的平面连杆机构,也称曲柄连杆机构。
曲柄滑块机构广泛应用于往复活塞式发动机、压缩机、冲床等的主机构中,把往复移动转换为不整周或整周的回转运动;压缩机、冲床以曲柄为主动件,把整周转动转换为往复移动。
这里使用运动学知识,对其运动进行解析,并用MATLAE为其设计仿真模块。
二、运动学分析
1、实例题目
对图示单缸四冲程发动机中常见的曲柄滑块机构进行运动学仿真。
已知连杆长度:
D0.1m,r30.4m,连杆的转速:
22,33,
设曲柄r2以匀速旋转,250r/s。
初始条件:
230。
仿真以2为
输入,计算3和A,仿真时间。
曲柄滑块机构示意图P
2、运动分析
建立封闭矢量方程:
将(9)式分解到x与y轴坐标上,得到:
r2cos02+r3cos03=r1
r2sin02+r3sin03=0
(10)
可得:
r1=r2cos02+r3cos03
03=-arcsin(r2/r3)
(11)
对(10)式对时间求导得:
「-r232sin02+r3w3sin03=v1
r2w2cos02+r3w3cos03=0(12)
将上式用矩阵形式表示,令:
-r3cos03
0]
A=[r3sin031
X=[s3
v1]
B=[-r232sin02
r232cos02]
则(12)可表示为:
AX=B。
(13)
从而可解出33与v1。
三、MATLA程序编写
源代码如下:
functionvarargout=z1(varargin)
%Z1MATLABcodefor
%Z1,byitself,createsanewZ1orraisestheexisting
%singleton*.
%H=Z1returnsthehandletoanewZ1orthehandleto
%theexistingsingleton*.
%
%Z1('CALLBACK',hObject,eventData,handles,...)calls
thelocal
%functionnamedCALLBACKinwiththegiveninputarguments.
%
%Z1('Property','Value',...)createsanewZ1orraisesthe
%existingsingleton*.Startingfromtheleft,propertyvaluepairsare
%appliedtotheGUIbeforez1_OpeningFcngetscalled.
An
%unrecognizedpropertynameorinvalidvaluemakespropertyapplication
%stop.Allinputsarepassedtoz1_OpeningFcnviavarargin.
%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone
%instancetorun(singleton)".
%
%Seealso:
GUIDE,GUIDATA,GUIHANDLES
%Edittheabovetexttomodifytheresponsetohelpz1
%LastModifiedbyGUIDE29-Dec-201622:
57:
13
%Begininitializationcode-DONOTEDITgui_Singleton=1;
gui_State=struct('gui_Name',mfilename,...
'gui_Singleton',gui_Singleton,...
'gui_OpeningFcn',z1_OpeningFcn,...
'gui_OutputFcn',z1_OutputFcn,...
'gui_LayoutFcn',[],...
'gui_Callback',[]);ifnargin&&ischar(varargin{1})=str2func(varargin{1});
endifnargout
[varargout{1:
nargout}]=gui_mainfcn(gui_State,varargin{:
});
else
gui_mainfcn(gui_State,varargin{:
});
end
%Endinitializationcode-DONOTEDIT
%---Executesjustbeforez1ismadevisible.
functionz1_OpeningFcn(hObject,eventdata,handles,varargin)
%Thisfunctionhasnooutputargs,seeOutputFcn.
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionof
MATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%varargincommandlineargumentstoz1(seeVARARGIN)
%Choosedefaultcommandlineoutputforz1
=hObject;
%Updatehandlesstructure
guidata(hObject,handles);
axes
map1=imread('');
imshow(map1)
%UIWAITmakesz1waitforuserresponse(seeUIRESUME)
%uiwait;
%---Outputsfromthisfunctionarereturnedtothecommandline.
functionvarargout=z1_OutputFcn(hObject,eventdata,handles)
%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionof
MATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Getdefaultcommandlineoutputfromhandlesstructure
varargout{1}=;
%---ExecutesonbuttonpressinpushbuttonRun.
functionpushbuttonRun_Callback(hObject,eventdata,handles)%主要计算程序
r2=;%单位m
r3=;%单位m
omiga2=str2double(get,'String'));;%单位rad/s
x11=1:
500%单位ms
fori=1:
500
theta2(i)=i*omiga2/1000;
theta3(i)=asin(-r2/r3*sin(theta2(i)));
B=[-r2*omiga2*sin(theta2(i));r2*omiga2*cos(theta2(i))];
A=[r3*sin(theta3(i))1;-r3*cos(theta3(i))0];
X=inv(A)*B;
omiga3(i)=X(1,1);
v3(i)=X(2,1);
end
axes%制表1plot(x11/1000,omiga3);
xlabel('时间(t/s)')
ylabel('连杆角速度33(rad/s)')
axes%制表2
plot(x11/1000,v3);
xlabel('时间(t/s)')
ylabel('滑块速度v1(m/s)')
%hObjecthandletopushbuttonRun(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionof
MATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
functionedit1_Callback(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Hints:
get(hObject,'String')returnscontentsofedit1astext
%str2double(get(hObject,'String'))returnscontents
ofedit1asadouble
%---Executesduringobjectcreation,aftersettingallproperties.
functionedit1_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoedit1(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterall
CreateFcnscalled
%Hint:
editcontrolsusuallyhaveawhitebackgroundonWindows.
%SeeISPCandCOMPUTER.
ifispc&&isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%---ExecutesonbuttonpressinpushbuttonExit.
functionpushbuttonExit_Callback(hObject,eventdata,handles)
ss=questdlg('确认退出','退出信息窗口!
','继续仿真!
','退出仿真!
','退出仿真!
');
switchss
case'退出仿真!
'
delete;
end
%hObjecthandietopushbuttonExit(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionof
MATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
四、使用指南和实例仿真进入MATLAB^件,打开并运行程序
初始界面:
对32的值进行修改,修改为实例中的50*2*pi=,点击开始仿真按
钮,得到仿真结果:
J也「鎚
曲柄滑块机构的
运动学仿貞
HI
■券#£改^i=drVdl>
r2_-Qiim
5=0.4m
uj2=314.16ra)d'5计上朮肖
r^FT-fnO55
t昨者:
UI
4£
2C
ir
QJD3
时|fi)0203
时IH(ft)
=•«1O老
£JQ
点击退出仿真按钮,进入退出界面:
点击继续仿真按钮,则回到程序界面;点击退出仿真按钮,则退出程序。
五、结语
由四,通过MATLA仿真得到的结果与实际情况符合。
通过该次作业,我了解并初步掌握了MATLAB勺语言编写和guide界面的使用,巩固并加深了对课上知识的理解,受益良多。