机床数控技术课程设计(可编辑)_第1页
机床数控技术课程设计(可编辑)_第2页
机床数控技术课程设计(可编辑)_第3页
机床数控技术课程设计(可编辑)_第4页
机床数控技术课程设计(可编辑)_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

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

文档简介

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

2、直线连续插补:直线单步插补:圆弧连续插补:4.圆弧单步插补:四、程序流程图1.pl1:逐点比较法插补第1象限直线逐点比较法插补直线的过程为每进给一步需完成偏差判别,坐标进给,偏差计算,终点判别四个步骤,具体流程如图1 所示。五程序及变量说明(matlab)function varargout cxy_050910610 varargin gui_singleton 1;gui_state struct gui_name, mfilename, . gui_singleton, gui_singleton, . gui_openingfcn, cxy_050910610_openingfcn,

3、. gui_outputfcn, cxy_050910610_outputfcn, . gui_layoutfcn, , . gui_callback, ;if nargin & ischar varargin 1 gui_state.gui_callback str2func varargin 1 ;endif nargout varargout 1:nargout gui_mainfcn gui_state, varargin : ;else gui_mainfcn gui_state, varargin : ;endfunction cxy_050910610_openingfcn ho

4、bject, eventdata, handles, varargin global uu 0;global fla;fla 0;handles.output hobject;guidata hobject, handles ;function varargout cxy_050910610_outputfcn hobject, eventdata, handles varargout 1 handles.output;function x1_callback hobject, eventdata, handles global x01;x01 str2double get handles.x

5、1,string ;function x1_createfcn hobject, eventdata, handles if ispc & 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_create

6、fcn hobject, eventdata, handles if ispc & 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, hand

7、les if ispc & 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 if ispc & isequal get ho

8、bject,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 if ispc & isequal get hobject,backgroundcolor , get

9、0,defaultuicontrolbackgroundcolor set hobject,backgroundcolor,white ;endfunction y3_callback hobject, eventdata, handles global y03;y03 str2double get handles.y3,string ;function y3_createfcn hobject, eventdata, handles if ispc & isequal get hobject,backgroundcolor , get 0,defaultuicontrolbackground

10、color set hobject,backgroundcolor,white ;endfunction x4_callback hobject, eventdata, handles global x04;x04 str2double get handles.x4,string ;function x4_createfcn hobject, eventdata, handles if ispc & isequal get hobject,backgroundcolor , get 0,defaultuicontrolbackgroundcolor set hobject,background

11、color,white ;endfunction y4_callback hobject, eventdata, handles global y04;y04 str2double get handles.y4,string ;function y4_createfcn hobject, eventdata, handles if ispc & isequal get hobject,backgroundcolor , get 0,defaultuicontrolbackgroundcolor set hobject,backgroundcolor,white ;endfunction r_c

12、allback hobject, eventdata, handles global r;r str2double get handles.r,string ;function r_createfcn hobject, eventdata, handles if ispc & isequal get hobject,backgroundcolor , get 0,defaultuicontrolbackgroundcolor set hobject,backgroundcolor,white ;endfunction clear_callback hobject, eventdata, han

13、dles 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

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

15、.2 ;k sqrt r2- l2 /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 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 1 x01 str2double get handles.x1,string ; x02 str2double ge

16、t 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 e 0 if f 0 x x+k; m linspace x-k,x,100 ; n y; f f- y02-y01 ; plot m,n,r ; else y y+k; p x; q linspace y

17、-k,y,100 ; f f+ x02-x01 ; plot p,q,r ; end e e-1; endelse 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 str2

18、double 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 x04&y03 yy&y04 yy errordlg 请输入第二一象限的顺圆弧 ;else xi x03;yi y03;xii x03;yii y03; jvx 0; jvy 0; xj fix xx-x03 /b ;yj fix yy+r-y03 /b ; %计算步数 m 2j;

19、%模 while xj 0|yj 0 if xj 0 jvx jvx+yi-yy; end if yj 0 jvy jvy+xx-xi; end flag 0; if jvx m xj xj-1;flag 1; xi xi+b; jvx mod jvx,m ; end if jvy m yj yj-1;flag 1; yi yi+b; jvy mod jvy,m ; end if flag 1 line xii,xi,yii,yi,color,r ; hold on; xii xi; yii yi; end endend line xi,xx,yi,yy+r,color,r ; xi xx;y

20、i 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 auto; while xj 0|yj 0 if xj 0 jvx jvx+yi-yy; end if yj 0 jvy jvy+xi-xx; end flag 0; if jvx m xj xj-1;flag 1; xi xi+b; jvx mod jvx,m ; end if jvy m yj yj-1;flag 1; yi yi-b; jvy mod jvy,m ; end if flag 1 line xii,x

21、i,yii,yi,color,r ; xii xi; yii yi; hold on; end end endfunction dbcb_callback hobject, eventdata, handles global x y f u e s;if s 1 x01 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

22、 get handles.buchang,string ; if u 0 x x01; y y01; u u+1; e abs x01-x02 +abs y01-y02 /k; f 0; else if e 0 if f 0 x x+k; m linspace x-k,x,1000 ; n y; f f- y02-y01 ; plot m,n,r ; hold on; else y y+k; p x; q linspace y-k,y ; f f+ x02-x01 ; plot p,q,r ; hold on; end e e-1; else u 0; end endelse global f

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

24、.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 x04&y03 yy&y04 yy errordlg 请输入第二一象限的顺圆弧 ;else %第二象限的顺圆插补 xi x03;yi y03; jvx 0; jvy 0; xj fix xx-x03 /b ;yj fix yy+r-y03 /b ; %第二象限的计数器 m 2j; k 1; while xj 0|yj 0 if xj 0 jvx jvx+yi-yy; end if yj 0 jvy

25、 jvy+xx-xi; end flag 0; if jvx m xj xj-1;flag 1; xi xi+b; jvx mod jvx,m ; end if jvy m yj yj-1;flag 1; yi yi+b; jvy mod jvy,m ; end if flag 1 xc k xi; yc k yi; k k+1; end endend xi 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 2j; axis auto; w

26、hile xn 0|yn 0 if xn 0 jvx jvx+yi-yy; end if yn 0 jvy jvy+xi-xx; end flag 0; if jvx m xn xn-1;flag 1; xi xi+b; jvx mod jvx,m ; end if jvy m yn yn-1;flag 1; yi yi-b; jvy mod jvy,m ; end if flag 1 xc k xi; yc k yi; k k+1; end end a pi-atan abs y03-yy / x03-xx ; b atan abs y04-yy / x04-xx ; alpha b:pi/

27、100:a; xq xx+r*cos alpha ; yq yy+r*sin alpha ; plot xq,yq hold on; plot xx,yy,ro ; if fla 0 fla fla+1; elseif fla 1 line x03,xc 1 ,y03,yc 1 ,color,r ; fla fla+1; elseif fla k-2 line xc fla ,xc fla+1 ,yc fla ,yc fla+1 ,color,r ; fla fla+1; else errordlg 插补结束 ; fla 0; endendfunction buchang_callback hobject, eventdata, handles function buchang_createfcn hobject, eventdata, handles if ispc & isequal get hobject,backgroundcolor , get 0,defaultuicontrolbackgroundcolor set hobject,backgroundcolor,white ;endfunction j

温馨提示

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

评论

0/150

提交评论