机床数控技术课程设计

上传人:daj****de2 文档编号:190415810 上传时间:2023-02-27 格式:DOCX 页数:18 大小:295.14KB
返回 下载 相关 举报
机床数控技术课程设计_第1页
第1页 / 共18页
机床数控技术课程设计_第2页
第2页 / 共18页
机床数控技术课程设计_第3页
第3页 / 共18页
点击查看更多>>
资源描述
机床数控技术课程设计说明书学校:南京航空航天大学专业:机械工程及自动化学 号:姓 名:设计题目:PL1 DC21 指导老师:时 间:一. 课设任务:1. PL1-逐点比较法插补第1象限直线;2. DC21-DDA法插补第21象限顺圆弧。二. 课设要求:1. 具有数据输入界面,如输入直线插补的起点、终点,圆弧插补的起止点、圆 心或半径、插补的步长等;2. 具有插补过程的动态显示功能,如单步插补、连续插补等;3. 插补的步长可调;4. 直线的起点、圆弧的圆心在坐标系中的位置可变(即直线的起点、圆弧的圆 心可不设定在坐标原点)5. 建议使用C语言编程,有条件者可使用VB、VC等语言编程。三. 程序界面及运行截图1.直线连续插补:3.圆弧连续插补:1 4!|I.!-1;-理想宜券理根圆弘蹈击补单步插朴四、程序流程图1.PL1:逐点比较法插补第1象限直线逐点比较法插补直线的过程为每进给一步需完成偏差判别,坐标进给,偏差 计算,终点判别四个步骤,具体流程如图1所示。开始结束E0F=0NNYYE=(abs(x01-x02)+abs(y01-y02)/k(总步数)F=0 (判别函数)向正Y方向前进一步F=F+(x02-x01)向正X方向前进一步F=F-(y02-y01)初始化,输入起点 x01、y01,终点 x02、y02,步长 kE=E-12、DDA法圆弧插补Y五. 程序及变量说明(Matlab)function varargout = cxy_050910610(varargin) gui Singleton = 1;mfilename, .gui_Singleton, .cxy_050910610_OpeningFcn, .cxy_050910610_OutputFcn, .,.);gui_State = struct(gui_Name,gui_Singleton,gui_OpeningFcn,gui_OutputFcn,gui_LayoutFcn,gui_Callback, if nargin & ischar(varargin1)gui_State.gui_Callback end= str2func(varargin1);if nargoutvarargout1:nargout = gui_mainfcn(gui_State, varargin:); elsegui_mainfcn(gui_State, varargin:);end function cxy_050910610_OpeningFcn(hObject, eventdata, handles, varargin) global u u=0;global fla; fla=0;handles.output = hObject;guidata(hObject, handles);function varargout = cxy_050910610_OutputFcn(hObject, eventdata, handles) varargout1 = handles.output;function x1_Callback(hObject, eventdata, handles) global x01;x01=str2double(get(handles.x1,string);function x1_CreateFcn(hObject, eventdata, handles) ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function x2_Callback(hObject, eventdata, handles) global x02;x02=str2double(get(handles.x2,string);function x2_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white); endfunction y1_Callback(hObject, eventdata, handles) global y01;y01=str2double(get(handles.y1,string);function y1_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white); endfunction y2_Callback(hObject, eventdata, handles) global y02;y02=str2double(get(handles.y2,string);function y2_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white); endfunction x3_Callback(hObject, eventdata, handles) global x03;x03=str2double(get(handles.x3,string);function x3_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);function y3_Callback(hObject, eventdata, handles) global y03;y03=str2double(get(handles.y3,string);function y3_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white); endfunction x4_Callback(hObject, eventdata, handles) global x04;x04=str2double(get(handles.x4,string);function x4_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white); endfunction y4_Callback(hObject, eventdata, handles) global y04;y04=str2double(get(handles.y4,string);function y4_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white); endfunction r_Callback(hObject, eventdata, handles) global R;R=str2double(get(handles.r,string);function r_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);function clear_Callback(hObject, eventdata, handles) cla;function straightline_Callback(hObject, eventdata, handles) global s;grid on;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);hold on;s=1;function circular_arc_Callback(hObject, eventdata, handles) grid on;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);axis equal;hold on;global ss=0;function lxcb_Callback(hObject, eventdata, handles) global s F X Y;if s=1x01=str2double(get(handles.x1,string);x02=str2double(get(handles.x2,string);y01=str2double(get(handles.y1,string);y02=str2double(get(handles.y2,string);k=str2double(get(handles.buchang,string);X=x01;Y=y01;F=0;E=(abs(x01-x02)+abs(y01-y02)/k;while E0if F=0X=X+k;m=linspace(X-k,X,100);n=Y;F=F-(y02-y01);plot(m,n,,r,);elseY=Y+k;P=X;q=linspace(Y-k,Y,100);F=F+(x02-x01);plot(p,q,,r,);endE=E-1;endelsex03=str2double(get(handles.x3,,string,);x04=str2double(get(handles.x4,,string,);y03=str2double(get(handles.y3,,string,);y04=str2double(get(handles.y4,,string,);b=str2double(get(handles.buchang,,string,);j=str2double(get(handles.jcq,,string,);R=str2double(get(handles.r,,string,);l=(y04-y03广2+(x04-x03广2广0.5;m=(y04-y03)/l;n=(x03-x04)/l;xx=(x03+x04)/2+(R”2-2/4广0.5*m;yy=(y03+y04)/2+(R2T2/4)”0.5*n;if (x03=xx&xx0|yj0)if xj0jvx=jvx+yi-yy;endif yj0jvy=jvy+xx-xi;endflag=0;if(jvxm)xj=xj-1;flag=1;xi=xi+b;jvx=mod(jvx,m);endif(jvym)yj=yj-i;fiag=i;yi=yi+b;jvy=mod(jvy,m);endif flag=1line(xii,xi,yii,yi,color,r);hold on;xii=xi;yii=yi;endendendline(xi,xx,yi,yy+R,color,r);xi=xx;yi=yy+R;xii=xx;yii=yy+R;jvx=0;jvy=0;xj=fix(x04-xx)/b);yj=fix(yy+R-y04)/b);m=2八j;axis auto;while (xj0|yj0)if xj0jvx=jvx+yi-yy;endif yj0jvy=jvy+xi-xx;endflag=0;if(jvxm)xj=xj-1;flag=1;xi=xi+b;jvx=mod(jvx,m);endif(jvym)yj=yj-i;flag=i;yi=yi-b;jvy=mod(jvy,m);endif flag=1line(xii,xi,yii,yi,color,r);xii=xi;yii=yi;hold on;endendendfunction dbcb_Callback(hObject, eventdata, handles) global X Y F u E s;if s=1x01=str2double(get(handles.x1,string);y01=str2double(get(handles.y1,string);x02=str2double(get(handles.x2,string);y02=str2double(get(handles.y2,string);k=str2double(get(handles.buchang,string);if u=0X=x01;Y=y01;u=u+1;E=(abs(x01-x02)+abs(y01-y02)/k;F=0;elseif E0if F=0X=X+k;m=linspace(X-k,X,1000);n=Y;F=F-(y02-y01);plot(m,n,r);hold on;elseY=Y+k;p=X;q=linspace(Y-k,Y);F=F+(x02-x01);plot(p,q,r);hold on;endE=E-1;elseu=0;end end else global fla; x03=str2double(get(handles.x3,string); x04=str2double(get(handles.x4,string); y03=str2double(get(handles.y3,string); y04=str2double(get(handles.y4,string); b=str2double(get(handles.buchang,string); j=str2double(get(handles.jcq,string); R=str2double(get(handles.r,string); l=(y04-y03)八2+(x04-x03)八2)八0.5; m=(y04-y03)/l; n=(x03-x04)/l; xx=(x03+x04)/2+(R八2-l八2/4)八0.5*m; yy=(y03+y04)/2+(R八2-l八2/4)八0.5*n; if (x03=xx&xx0 jvx=jvx+yi-yy; end if yj0 jvy=jvy+xx-xi; end flag=0; if(jvxm) xj=xj-1;flag=1; xi=xi+b; jvx=mod(jvx,m); end if(jvym) yj=yj-i;flag=i; yi=yi+b; jvy=mod(jvy,m);if flag=1XC(k)=xi;YC(k)=yi;k=k+1;endendendxi=xx;yi=yy+R;xii=xx;yii=yy+R;第一象限顺圆插补jvx=0;jvy=0;xn=fix(x04-xx)/b);yn=fix(yy+R-y04)/b); 第一象限的计数器 m=2八j;axis auto;while (xn0|yn0)if xn0jvx=jvx+yi-yy;endif yn0jvy=jvy+xi-xx;endflag=0;if(jvxm)xn=xn-1;flag=1;xi=xi+b;jvx=mod(jvx,m);endif(jvym)yn=yn-1;flag=1;yi=yi-b;jvy=mod(jvy,m);endif flag=1XC(k)=xi;YC(k)=yi;k=k+1;endenda=pi-atan(abs(y03-yy)/(x03-xx);b=atan(abs(y04-yy)/(x04-xx);alpha=b:pi/100:a;XQ=xx+R*cos(alpha);YQ=yy+R*sin(alpha);plot(XQ,YQ)hold on;plot(xx,yy,Ro);if fla=0fla=fla+1;elseif fla=1line(x03,XC(1),y03,YC(1),color,r);fla=fla+1;elseif fla=k-2line(XC(fla),XC(fla+1),YC(fla),YC(fla+1),color,r); fla=fla+1;elseerrordlg插补结束);fla=0;endendfunction buchang_Callback(hObject, eventdata, handles)function buchang_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);endfunction jcq_Callback(hObject, eventdata, handles)function jcq_CreateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);end六心得体会本次课设是在考研结束后的一周内做完的,时间其实应该是很够的,但是由于本 人不善于编程,所以最后完成得很仓促。通过这次课设,我对matlab的操作有 了更深的认识,对相关函数语句还有逻辑循环套用的应用有了更深的理解。而且 此次课设,让我对逐点比较法直线插补和DDA圆弧插补有了感性和理性的全面 认识,对我学习数控机床这门课也有非常大的帮助。最后,遇到困难不要着急, 静下心来总有解决办法
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 图纸设计 > 毕设全套


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!