哈工大精密机械设计大作业MATLAB凸轮设计说明书.docx
《哈工大精密机械设计大作业MATLAB凸轮设计说明书.docx》由会员分享,可在线阅读,更多相关《哈工大精密机械设计大作业MATLAB凸轮设计说明书.docx(27页珍藏版)》请在冰豆网上搜索。
哈工大精密机械设计大作业MATLAB凸轮设计说明书
设计说明书
一、程序算法
1:
匀速运动
等速运动规律:
S=h/Φ1*Φ;
V=v0=h/Φ1*w;
a=0;
在行程开始位置,速度由v变成v0,其导数a=无穷;同理,在行程终止位置,速度由v0突变为0;加速度变为负无穷。
程序思路:
s0=(r*r-e*e)^(1/2);
j=0:
0.001:
2*pi;//均匀取点
s1(1:
6284)=0;
s1(1:
1571)=2*h/pi.*j(1:
1571);
s1(1572:
3142)=h;//等速运动曲线推程末端的位移量
s1(3143:
4713)=fliplr(s1(1:
1571));
x=e.*cos(j)+(s0+s1).*sin(j);//把极坐标转换成直角坐标
y=(s0+s1).*cos(j)-e*sin(j);
plot(x,y);//画凸轮轮廓
x1=r*sin(j);
y1=r*cos(j);
plot(x1,y1);//画基圆
plot(j,s1);//画速度曲线
s1v(1:
6284)=0;
s1v(1:
1571)=h/(pi/2);
s1v(1572:
3142)=0;
s1v(3143:
4713)=fliplr(s1v(1:
1571));
plot(j,s1v);//画加速度曲线
由于凸轮加速度在pi/2和3*pi/2两点为无穷,所以没有画出。
2:
等加速运动
等加速运动和等减速运动规律:
从动件做等加速或等减速运动时,如果其加速段或减速段的时间相等,则其运动曲线对称。
初速度为零的物体做加速运动时,其位移方程为s=0.5*a0*(Φ/w)^2;当Φ=Φ1/2,s=h/2,h/2=0.5a0a*(Φ1/2w)^2;故a0=4hw^2/((Φ)^2);将a0值代入位移方程并对时间求导数,得s=2*h*Φ^2/(Φ1)^2;v=4hwΦ/(Φ1)^2;
a=a0=4hw^2/(Φ1)^2;根据运动图线对称性,s=h-2*h*(Φ1-Φ)^2/(Φ1)^2;
v=4*h*w*(Φ1-Φ)/(Φ1)^2;a=-4*h*w^2/(Φ1)^2;
s0=(r*r-e*e)^(1/2);
j=0:
0.001:
2*pi;//均匀取点
s2(1:
6284)=0;
s2(1:
1571)=4*h/pi/pi.*(j(1:
1571).^2);
s2(1572:
3142)=h;//推程末端取s=h
s2(3143:
4713)=fliplr(s2(1:
1571));
x=e.*cos(j)+(s0+s2).*sin(j);//极坐标转换成直角坐标
y=(s0+s2).*cos(j)-e*sin(j);
plot(x,y);//画凸轮轮廓
x=r*sin(j);
y=r*cos(j);
plot(x,y);//画基圆
plot(j,s2);//画位移曲线
s2v(1:
6284)=0;
s2v(1:
1571)=8*h/pi/pi.*j(1:
1571);
s2v(1572:
3142)=0;
s2v(3143:
4713)=fliplr(s2v(1:
1571));
plot(j,s2v);//画速度曲线
s2a(1:
6284)=0;
s2a(1:
1571)=8*h/pi/pi;
s2a(1572:
3142)=0;
s2a(3143:
4713)=fliplr(s2a(1:
1571));
plot(j,s2a);//画加速度图像
3:
等减速运动
加速过程与加速过程类似,不再赘述,见上面等加速运动
s0=(r*r-e*e)^(1/2);
j=0:
0.001:
2*pi;
s3(1:
6284)=0;
s3(1:
1571)=h-4*h/pi/pi.*((pi/2-j(1:
1571)).^2);
s3(1572:
3142)=h;
s3(3143:
4713)=fliplr(s3(1:
1571));
x=e.*cos(j)+(s0+s3).*sin(j);
y=(s0+s3).*cos(j)-e*sin(j);
plot(x,y);
x=r*sin(j);
y=r*cos(j);
plot(x,y);
plot(j,s3);
s3v(1:
6284)=0;
s3v(1:
1571)=8*h/pi/pi.*(pi/2-j(1:
1571));
s3v(1572:
3142)=0;
s3v(3143:
4713)=fliplr(s3v(1:
1571));
plot(j,s3v);
s3a(1:
6284)=0;
s3a(1:
1571)=-8*h/pi/pi;
s3a(1572:
3142)=0;
s3a(3143:
4713)=fliplr(s3a(1:
1571));
plot(j,s3a);
4:
余弦加速运动
质点在圆周上做匀速运动时,它在这个圆的直径上投影所构成的运动就是简谐运动。
其位移曲线方程为s=R-R*cosθ,R=h/2;θ/pi=Φ/Φ1;将R及θ值带入上式并对时间求导,可得
S=h*(1-cos(pi*Φ/Φ1))/2;v=h*pi*w*sin(pi*Φ/Φ1)/(2*Φ1);a=h*pi^2*w^2*cos(pi*Φ/Φ1)/(2*Φ1^2)
s0=(r*r-e*e)^(1/2);
j=0:
0.001:
2*pi;//均匀取点
s4(1:
6284)=0;
s4(1:
1571)=h/2*(1-cos(2*j(1:
1571)));
s4(1572:
3142)=h;//推程末端位移s=hs
s4(3143:
4713)=fliplr(s4(1:
1571));
x=e.*cos(j)+(s0+s4).*sin(j);//极坐标转换成直角坐标
y=(s0+s4).*cos(j)-e*sin(j);
plot(x,y);//画凸轮轮廓
x=r*sin(j);
y=r*cos(j);
plot(x,y);//画基圆
plot(j,s4);//画位移曲线
s4v(1:
6284)=0;
s4v(1:
1571)=h.*sin(2*j(1:
1571));
s4v(1572:
3142)=0;
s4v(3143:
4713)=fliplr(s4v(1:
1571));
plot(j,s4v);//画速度曲线
s4a(1:
6284)=0;
s4a(1:
1571)=2*h.*cos(2*j(1:
1571));
s4a(1572:
3142)=0;
s4a(3143:
4713)=fliplr(s4a(1:
1571));
plot(j,s4a);//画加速度曲线
二、交互界面设计
对于四个曲线的显示,我选择
按钮拖面,产生四个AXES
下面的解说选用statictext
关于r、e的变化我选用两个slider
最后的设计说明书和使用说明书我用两个按钮连接到word
具体源程序不再赘述,见m文件
三、源程序代码
functionvarargout=my1(varargin)
%MY1M-fileformy1.fig
%MY1,byitself,createsanewMY1orraisestheexisting
%singleton*.
%
%H=MY1returnsthehandletoanewMY1orthehandleto
%theexistingsingleton*.
%
%MY1('CALLBACK',hObject,eventData,handles,...)callsthelocal
%functionnamedCALLBACKinMY1.Mwiththegiveninputarguments.
%
%MY1('Property','Value',...)createsanewMY1orraisesthe
%existingsingleton*.Startingfromtheleft,propertyvaluepairsare
%appliedtotheGUIbeforemy1_OpeningFcngetscalled.An
%unrecognizedpropertynameorinvalidvaluemakespropertyapplication
%stop.Allinputsarepassedtomy1_OpeningFcnviavarargin.
%
%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone
%instancetorun(singleton)".
%
%Seealso:
GUIDE,GUIDATA,GUIHANDLES
%Edittheabovetexttomodifytheresponsetohelpmy1
%LastModifiedbyGUIDEv2.506-Nov-201122:
50:
18
%Begininitializationcode-DONOTEDIT
gui_Singleton=1;
gui_State=struct('gui_Name',mfilename,...
'gui_Singleton',gui_Singleton,...
'gui_OpeningFcn',@my1_OpeningFcn,...
'gui_OutputFcn',@my1_OutputFcn,...
'gui_LayoutFcn',[],...
'gui_Callback',[]);
ifnargin&&ischar(varargin{1})
gui_State.gui_Callback=str2func(varargin{1});
end
ifnargout
[varargout{1:
nargout}]=gui_mainfcn(gui_State,varargin{:
});
else
gui_mainfcn(gui_State,varargin{:
});
end
%Endinitializationcode-DONOTEDIT
%---Executesjustbeforemy1ismadevisible.
functionmy1_OpeningFcn(hObject,eventdata,handles,varargin)
%Thisfunctionhasnooutputargs,seeOutputFcn.
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%varargincommandlineargumentstomy1(seeVARARGIN)
%Choosedefaultcommandlineoutputformy1
handles.output=hObject;
axes(handles.axeslunkuo);
linewidth=2;%¶¨Òå»Í¼µÄÏß¿í
color='g';%¶¨Òå»Í¼ÑÕÉ«
handles.r=get(handles.sliderr,'value');
handles.e=get(handles.slidere,'value');
handles.h=50;
handles.s0=(handles.r*handles.r-handles.e*handles.e)^(1/2);
handles.j=0:
0.001:
2*pi;
handles.s1(1:
6284)=0;
handles.s1(1:
1571)=2*handles.h/pi.*handles.j(1:
1571);
handles.s1(1572:
3142)=handles.h;
handles.s1(3143:
4713)=fliplr(handles.s1(1:
1571));
x=handles.e.*cos(handles.j)+(handles.s0+handles.s1).*sin(handles.j);
y=(handles.s0+handles.s1).*cos(handles.j)-handles.e*sin(handles.j);
plot(x,y);
holdon
x1=handles.r*sin(handles.j);
y1=handles.r*cos(handles.j);
plot(x1,y1);
axisequal
axes(handles.axesweiyi)
plot(handles.j,handles.s1);
axis([02*pi055])
handles.s1v(1:
6284)=0;
handles.s1v(1:
1571)=handles.h/(pi/2);
handles.s1v(1572:
3142)=0;
handles.s1v(3143:
4713)=fliplr(handles.s1v(1:
1571));
axes(handles.axessudu);
plot(handles.j,handles.s1v);
axis([02*pi0handles.h/(pi/2)+3])
set(handles.textr,'string',num2str(handles.r));
set(handles.texte,'string',num2str(handles.e));
%Updatehandlesstructure
guidata(hObject,handles);
%UIWAITmakesmy1waitforuserresponse(seeUIRESUME)
%uiwait(handles.figure1);
%---Outputsfromthisfunctionarereturnedtothecommandline.
functionvarargout=my1_OutputFcn(hObject,eventdata,handles)
%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Getdefaultcommandlineoutputfromhandlesstructure
varargout{1}=handles.output;
%---Executesonbuttonpressinjieshu.
functionjieshu_Callback(hObject,eventdata,handles)
%hObjecthandletojieshu(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
close;
%---Executesonbuttonpressincreate.
functioncreate_Callback(hObject,eventdata,handles)
%hObjecthandletocreate(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
winopen('Éè¼Æ˵Ã÷Êé.doc')
%---Executesonbuttonpressinuse.
functionuse_Callback(hObject,eventdata,handles)
%hObjecthandletouse(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
winopen('ʹÓÃ˵Ã÷Êé.doc')
%---Executesonslidermovement.
functionsliderr_Callback(hObject,eventdata,handles)
%hObjecthandletosliderr(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
handles.r=get(handles.sliderr,'value');
set(handles.textr,'string',num2str(handles.r));
axes(handles.axeslunkuo);
s0=(handles.r*handles.r-handles.e*handles.e)^(1/2);
x=handles.e.*cos(handles.j)+(s0+handles.s1).*sin(handles.j);
y=(s0+handles.s1).*cos(handles.j)-handles.e*sin(handles.j);
plot(x,y);
holdon
x1=handles.r*sin(handles.j);
y1=handles.r*cos(handles.j);
plot(x1,y1);
axisequal
guidata(hObject,handles);
%Hints:
get(hObject,'Value')returnspositionofslider
%get(hObject,'Min')andget(hObject,'Max')todeterminerangeofslider
%---Executesduringobjectcreation,aftersettingallproperties.
functionsliderr_CreateFcn(hObject,eventdata,handles)
%hObjecthandletosliderr(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
slidercontrolsusuallyhavealightgraybackground.
ifisequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9.9.9]);
end
%---Executesonslidermovement.
functionslidere_Callback(hObject,eventdata,handles)
%hObjecthandletoslidere(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
handles.e=get(handles.slidere,'value');
set(handles.texte,'string',num2str(handles.e));
axes(handles.axeslunkuo);
s0=(handles.r*handles.r-handles.e*handles.e)^(1/2);
x=handles.e.*cos(handles.j)+(s0+handles.s1).*sin(handles.j);
y=(s0+handles.s1).*cos(handles.j)-handles.e*sin(handles.j);
plot(x,y);
holdon
guidata(hObject,handles);
%Hints:
get(hObject,'Value')returnspositionofslider
%get(hObject,'Min')andget(hObject,'Max')todeterminerangeofslider
%---Executesduringobjectcreation,aftersettingallproperties.
functionslidere_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoslidere(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
slidercontrolsusuallyhavealightgrayback