您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 制造加工工艺 > 机床数控技术课程设计
机床数控技术课程设计说明书学校:南京航空航天大学专业:机械工程及自动化学号:姓名:设计题目:PL1DC21指导老师:时间:一.课设任务:1.PL1-----逐点比较法插补第1象限直线;2.DC21---DDA法插补第2~1象限顺圆弧。二.课设要求:1.具有数据输入界面,如输入直线插补的起点、终点,圆弧插补的起止点、圆心或半径、插补的步长等;2.具有插补过程的动态显示功能,如单步插补、连续插补等;3.插补的步长可调;4.直线的起点、圆弧的圆心在坐标系中的位置可变(即直线的起点、圆弧的圆心可不设定在坐标原点)5.建议使用C语言编程,有条件者可使用VB、VC等语言编程。三.程序界面及运行截图1.直线连续插补:2.直线单步插补:3.圆弧连续插补:4.圆弧单步插补:四、程序流程图1.PL1:逐点比较法插补第1象限直线逐点比较法插补直线的过程为每进给一步需完成偏差判别,坐标进给,偏差计算,终点判别四个步骤,具体流程如图1所示。开始初始化,输入起点x01、y01,终点x02、y02,步长kE=(abs(x01-x02)+abs(y01-y02))/k(总步数)F=0(判别函数)E0结束NF=0向正X方向前进一步F=F-(y02-y01)向正Y方向前进一步F=F+(x02-x01)YNYE=E-1xm=fix((xx-x03)/b);ym=fix((yy+R-y03)/b)Yjvx=0;jvy=0m=2^jxm0?jvx=jvx+yj-yyYNym0?jvy=jvy+xx-xjYjvx溢出?0?+X前进一步xm=xm-1Yjvy溢出?0?+Y前进一步ym=ym-1xm0||ym0?N二一象限顺圆?计算圆心坐标(xx,yy)xj=x03,yj=y03初始化,输入起点坐标(xr03,y03),终点坐标(x04,y04)半径R步长b和寄存器位数j开始NY2、DDA法圆弧插补+X前进一步xn=xn-1-Y前进一步yn=yn-1xn=fix((x04-xx)/b);yn=fix((yy+R-y04)/b);Nxn0?jvx=jvx+yj-yyYNyn0?jvy=jvy+xj-xxYjvx溢出?0?Yjvy溢出?0?xn0||yn0?NY结束五.程序及变量说明(Matlab)functionvarargout=cxy_050910610(varargin)gui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@cxy_050910610_OpeningFcn,...'gui_OutputFcn',@cxy_050910610_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});endfunctioncxy_050910610_OpeningFcn(hObject,eventdata,handles,varargin)globaluu=0;globalfla;fla=0;handles.output=hObject;guidata(hObject,handles);functionvarargout=cxy_050910610_OutputFcn(hObject,eventdata,handles)varargout{1}=handles.output;functionx1_Callback(hObject,eventdata,handles)globalx01;x01=str2double(get(handles.x1,'string'));functionx1_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionx2_Callback(hObject,eventdata,handles)globalx02;x02=str2double(get(handles.x2,'string'));functionx2_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctiony1_Callback(hObject,eventdata,handles)globaly01;y01=str2double(get(handles.y1,'string'));functiony1_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctiony2_Callback(hObject,eventdata,handles)globaly02;y02=str2double(get(handles.y2,'string'));functiony2_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionx3_Callback(hObject,eventdata,handles)globalx03;x03=str2double(get(handles.x3,'string'));functionx3_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctiony3_Callback(hObject,eventdata,handles)globaly03;y03=str2double(get(handles.y3,'string'));functiony3_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionx4_Callback(hObject,eventdata,handles)globalx04;x04=str2double(get(handles.x4,'string'));functionx4_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctiony4_Callback(hObject,eventdata,handles)globaly04;y04=str2double(get(handles.y4,'string'));functiony4_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionr_Callback(hObject,eventdata,handles)globalR;R=str2double(get(handles.r,'string'));functionr_CreateFcn(hObject,eventdata,handles)ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionclear_Callback(hObject,eventdata,handles)cla;functionstraightline_Callback(hObject,eventdata,handles)globals;gridon;x01=str2double(get(handles.x1,'string'));x02=str2double(get(handles.x2,'string'));y01=str2double(get(handles.y1,'string'));y02=str2double(get(handles.y2,'string'));x=linspace(x01,x02,1000);y=((y02-y01)/(x02-x01))*(x-x01)+y01;plot(x,y,'b');holdon;s=1;functioncircular_arc_Callback(hObject,eventdata,handles)gridon;x03=str2double(get(handles.x3,'string'));x04=str2double(get(handles.x4,'string'));y03=str2double(get(handles.y3,'string'));y04=str2double(get(handles.y4,'string'));R=str2double(get(handles.r,'string'));l=sqrt((y04-y03).^2+(x04-x03).^2);k=sqrt(R^2-(l^2)/4);x0=(x03+x04)/2+((y04-y03)*k)/l;y0=(y03+y04)/2-((x04-x03)*k)/l;x=linspace(x03,x04,1000);y=y0+sqrt(R^2-(x-x0).^2);plot(x,y,'b');axisequal;holdon;globalss=0;functionlxcb_Callback(hObject,eventdata,handles)globa
本文标题:机床数控技术课程设计
链接地址:https://www.777doc.com/doc-5202642 .html