机床数控技术课程设计汇本_第1页
机床数控技术课程设计汇本_第2页
机床数控技术课程设计汇本_第3页
机床数控技术课程设计汇本_第4页
机床数控技术课程设计汇本_第5页
免费预览已结束,剩余10页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、机床数控技术课程设计机床数控技术课程设计说明书说明书学校:航空航天大学专业:机械工程及自动化学号:姓名:设计题目:PL1DC21指导老师:时间:一课设任务:一课设任务:1.PL1-逐点比较法插补第 1 象限直线;2.DC21-DDA 法插补第 21 象限顺圆弧。二课设要求二课设要求: :1.具有数据输入界面,如输入直线插补的起点、终点,圆弧插补的起止点、圆心或半径、插补的步长等;2.具有插补过程的动态显示功能,如单步插补、连续插补等;3.插补的步长可调;4.直线的起点、圆弧的圆心在坐标系中的位置可变(即直线的起点、圆弧的圆心可不设定在坐标原点)5.建议使用 C 语言编程,有条件者可使用 VB、

2、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-x0

3、1)YNYE=E-1xm=fix(xx-x03)/b);ym=fix(yy+R-y03)/b)Yjvx=0;jvy=0m=2jxm0?jvx=jvx+yj-yyYNym0?jvy=jvy+xx-xjYjvx溢出?0?+X 前进一步Yjvy溢出?0?+Y前进一步ym=ym-1xm0|ym0?N二一象限顺圆?计算圆心坐标(xx,yy)xj=x03,yj=y03初始化, 输入起点坐标 (xr03,y03) ,终点坐标(x04,y04) 半径 R 步长 b和寄存器位数 j开始NY2、DDA 法圆弧插补法圆弧插补五程序及变量说明五程序及变量说明(MatlabMatlab)function varargo

4、ut = 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,);if nargin & ischar(varargin1)gui_State.gui_Callback = str2func(v

5、arargin1);endif nargout+X 前进一步-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结束varargout1:nargout = gui_mainfcn(gui_State, varargin:);elsegui_mainfcn(gui_State, varargin:);endfunctioncxy_050910610_OpeningFcn(hObject,eventdata,hand

6、les,varargin)global uu=0;global fla;fla=0;handles.output = hObject;guidata(hObject, handles);functionvarargout=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_C

7、reateFcn(hObject, eventdata, handles)ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);endfunction x2_Callback(hObject, eventdata, handles)global x02;x02=str2double(get(handles.x2,string);function x2_CreateFcn(hObject, eventdata,

8、 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(

9、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)

10、,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,defaultUicontrolBackg

11、roundColor)set(hObject,BackgroundColor,white);endfunction 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,Backg

12、roundColor,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);endfunctio

13、n 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, eventd

14、ata, 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);endfunction clear_Callback(hObject, eventdata, handles)cla;function strai

15、ghtline_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;fun

16、ction 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(R2-(l2)/4);

17、x0=(x03+x04)/2+(y04-y03)*k)/l;y0=(y03+y04)/2-(x04-x03)*k)/l;x=linspace(x03,x04,1000);y=y0+sqrt(R2-(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);y

18、01=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);end

19、E=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)

20、2)0.5;m=(y04-y03)/l;n=(x03-x04)/l;xx=(x03+x04)/2+(R2-l2/4)0.5*m;yy=(y03+y04)/2+(R2-l2/4)0.5*n;if (x03=xx&xx=yy&y04=yy)errordlg(请输入第二一象限的顺圆弧);elsexi=x03;yi=y03;xii=x03;yii=y03;jvx=0;jvy=0;xj=fix(xx-x03)/b);yj=fix(yy+R-y03)/b); %计算步数m=2j;%模while (xj0|yj0)if xj0jvx=jvx+yi-yy;endif yj0jvy=jvy+xx

21、-xi;endflag=0;if(jvxm)xj=xj-1;flag=1;xi=xi+b;jvx=mod(jvx,m);endif(jvym)yj=yj-1;flag=1;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=2j;axis au

22、to;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-1;flag=1;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

23、 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

24、,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;endendelseglobal fla;x03=str2double(get(handles.x3,string);x04=str2double(get(handles.x4,string);y03=str2double(get(handles.y3,string);y04=str2double(get(handles.y4,strin

25、g);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+(R2-l2/4)0.5*m;yy=(y03+y04)/2+(R2-l2/4)0.5*n;if (x03=xx&xx=yy&y04=yy)errordlg(请输入第二一象限的顺圆弧);else%第二象限的顺圆插

26、补xi=x03;yi=y03;jvx=0;jvy=0;xj=fix(xx-x03)/b);yj=fix(yy+R-y03)/b);%第二象限的计数器m=2j;k=1;while (xj0|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-1;flag=1;yi=yi+b;jvy=mod(jvy,m);endif flag=1XC(k)=xi;YC(k)=yi;k=k+1;endendendxi=xx;yi=

27、yy+R;xii=xx;yii=yy+R;%第一象限顺圆插补jvx=0;jvy=0;xn=fix(x04-xx)/b);yn=fix(yy+R-y04)/b);%第一象限的计数器m=2j;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;

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论