1、机床数控技术课程设计 机床数控技术课程设计说明书学校:南京航空航天大学专业:机械工程及自动化学号:姓名:设计题目:P1 D1指导老师:时间:一课设任务:1PL1-逐点比较法插补第象限直线;2。DC21-A法插补第21象限顺圆弧。二.课设要求:1.具有数据输入界面,如输入直线插补的起点、终点,圆弧插补的起止点、圆心或半径、插补的步长等;2.具有插补过程的动态显示功能,如单步插补、连续插补等;3。插补的步长可调;4。直线的起点、圆弧的圆心在坐标系中的位置可变(即直线的起点、圆弧的圆心可不设定在坐标原点)5。建议使用语言编程,有条件者可使用B、V等语言编程。三.程序界面及运行截图1。直线连续插补:2
2、.直线单步插补:3.圆弧连续插补:4.圆弧单步插补:四、程序流程图。PL:逐点比较法插补第象限直线逐点比较法插补直线的过程为每进给一步需完成偏差判别,坐标进给,偏差计算,终点判别四个步骤,具体流程如图1 所示。2、DDA法圆弧插补五.程序及变量说明(tlab)nton varrout = cxy_0509061(vrari)guiSingleon = 1;uiStt struc(gui_Nme, fienam, 。. guiSingleon, ui_ingltn, 。. gu_pengF, y_59060_OpeningF, 。 gui_OutputFcn,cxy_05091610_puFcn
3、,。.。 gu_LayoutF, , 。 gui_allack, );if nargn & iscar(varargin1) uitae.gui_allbk= sr2fc(varrgn);ndifnargout arrou1:nrgou = guiainc(gu_Sta,varargi:);ee gi_main(gui_State, vrai:);enduction cy_0090610OeningFn(hObjet,eveata, ndes, arrgin)gobl uu=0;lobalfla;la;ndls。out = jec;gidata(hObet, anls);fion vaargo
4、t cxy00910610_tputcn(hOjec, eentdata, handle) vargou1 =nles。utut;funcon x1_Callback(hObjet,eenata, ndles)glob x0;01=st2double(get(andles。x1,trin);fnction _CeteFcn(hObjct, endata, andle)f ispc squa(get(hObject,BackgounColo), ge(0,efaultUicotrolBackgroundColo) et(hObjet,BackgounColo,wite);endfuct2_Cab
5、ak(Oc,eventdata, hds)a 0;x0=strdoue(get(handes.x2,strng));fncionx2_retFn(hObect, eventdat, handl)if isc & ieual(e(hObjct,acgrudColor), ge(,defultUicontrolckgruCoor)) set(hOe,BacrondColor,wie);ndunctoyCallbck(hObjct, vetda, hnles)globa y1;y01=tr2ue(ge(hadlesy1,sring));union y1reteFcn(hjct, etdata, ha
6、nles)if isp squal(get(hjct,BackgrodColor), ge(0,defaulUcontrolBaoundColr) t(hObec,Backgroundolo,hi);ndfncto y2_Calback(hObct,evntdata,handles)glol y02;02=srdoul(et(hane。y2,strng);uncion y2_reteFn(hObt, eventat, hadles)if spc &iqua(get(Obect,BackgndClor), gt(0,deaultUiconlBackgrudol) set(hObjet,Bacgr
7、oundoor,hite);endfnco xCalbc(hObct, eventdata, handles)gloal x03;x3=str2oule(get(handls.3,string);funcon x3_CreteFcn(hObjct, ventata, hadls)if ispc & seul(et(hOjec,ackroundCoor), get(0,defaltUiotrolBarndColor)) set(hObject,BackgroudColor,whit);edfuntion y3llac(hObjet, eventdata, handle)glbal03;0=str
8、2duble(get(hande。y3,string);fnction 3_Creatcn(bject, eentdat, hanles)i ispc&isequal(et(hOet,ackgounClor),get(0,dfultictrolBackgrouColor)) t(hObject,BkgroundClor,hit);endfunto x4Callbac(hObet, eetd, handles)lobal4;x04=strduble(e(dles。x4,sring));fuctinx4_CreatFcn(hObject, evtaa, aes)i ispc & iequal(et
9、(hObjec,BckgroudClr), get(0,defaltUntlBakgrundColor) se(hObect,BacroundClor,ite);ndfuncto _allback(hObjet,eentdata,andls)loal y0;y04=2double(get(handes。y4,ting));nction y4_reatFcn(hObjet, eventdata, handles)f spc &ieqal(get(hObjet,akgndoo), get(0,efaultUicntolBacgroCoor)) t(hbject,BckronCo,whte);end
10、functin r_Callack(hObject, eventdta, hdles)gobal R;=tr2double(get(handles。r,srng);function _CrteFn(hOje,eentdta, andles)if ispc& ieal(get(bjt,BakgronColr), et(,defultUicontlBckgroundolor)) st(Obct,BakgrounColr,white);edfunction cr_alck(hjct, ventdata, andles)cla;funcin aightli_allbck(hObjet, eentta,
11、 han)glal s;grido;x1=str2dub(get(hanles。x1,string));x02=tr2double(g(hanles.x,string));1=st2due(get(hndl。,stin));y0s2de(t(hanes.2,tring);=npace(x1,x2,1000);y=(y0y0)/(x2x01)(-x1)+01;lot(x,y,b);holdon;=1;unio circur_arcCalback(hObect, vnata,hadles)ri on;x3strdoue(get(hales。x3,strin));x04=sr2ub(get(hand
12、es。4,n));y3=str2doble(get(halesy,tin);y04=stru(ge(hndle。,sring);R=sr2dule(get(hadles。r,strng));=q((y043).2+(04).2);=sqrt(2(l2)/4);x0(x+x04)2+((y4-y03)*k)/l;y0(y03+y0)-((x04x0)k)/l;x=lsace(x0,04,00);y=y0sqr(2(xx0).2);plt(x,b);axis qua;hld on;lobalss=;funcilxcb_aba(bjec,ventat, ndls)globls FX ;if =1 0
13、1=tr2doub(get(hndles.1,strn)); 2=sr2doule(et(anles。x2,sting)); y1=str2dble(ge(hndles。y1,strin)); y022doub(get(hndles。y2,sring)); kt2doule(ge(hnls.buc,strn)); X=x;Y=01; F; (ab(02)+bs(y01y0)/k; hil E0 0 X=X+k; m=nsac(,00); n=; F=F(y2-y1); lo(m,n,r); es Y=+k; =X; q=insace(-,,100); FF+(x02x1); plo(p,q,)
14、; ed E=E1; endelse x03=str2dobe(g(aes。x,srg)); x0=stroul(ge(handles.x4,string); y3=rdoub(gt(adles.y,sti); y4=trdobe(t(handles.y,string)); =tr2dule(get(andles.bucang,sring); j=srdouble(et(hdles。jcq,stin)); Rr2dbe(get(andes。r,string)); =(y04y)2+(x03)2)。5; m(04y03)/l; =(x03-04)/l; x=(x3+x04)2+(Rl2/4)05
15、*m; yy=(3+y04)(2l2/)。5n;if(x03x&xx04&y03=yy&y04y) errordg(请输入第二一象限的顺圆弧);ele xi=x0;iy3;xii=03;yiiy03; jvx=0; j=0; jfix((x0)/);yj=ix(yy+Ry0)/b); %计算步数 m=j; %模 while (xjy0) f x0 jvvx+yi-yy; n if y0 jvy=vyxxxi; end fa=0; i(jvx) xjx1;ag=1; xi=xi+b; jv=mo(jx,); end (vym) y=j1;flag=; yi=; jyod(jy,m); e if
16、lag line(xi,xi,ii,y,cl,r); hol ; xi=; yii=y; en endend lie(,x,yi,yR,clor,r); i=x;i=R;xiixx;yii=+R; jvx=0; jvy=0; xjfi(x04xx));y=x((yy+R04)/); m=2j; axsau; hile (xj|y) if xj0 jvjvx+iy; end ij0 j=j+xi-xx; end lag=0; (jvxm) xj=xj1;lag=1; xi=xi+; jx=o(jvx,m); n f(jvm) yj=yj1;lg1; yi=yib; jvymd(v,m); n f
17、 flag lie(xii,xi,yi,y,color,r); xii=xi; yii=yi; holdo; nd endfunin db_Callback(hbject, eventta, dle)goblX Y F u E s;if x01=trdbl(get(andl.x1,sting)); y0=str2oule(ge(andles.y1,string)); x0=str2dobe(get(hanle。x2,srig); y02=sr2dubl(t(hanles。y2,string); k=stroble(get(hales。uchag,string); ifu=0 X=x01; Y=
18、y01; u=u; E(abs(x01-)+abs(y01y2))/k; F=0; ese if E0 i F0 X=Xk; m=linspae(X-k,X,000); n=Y; F=F(y2y0); pot(m,n,); hld ; else Y=Yk; p=; =linspe(k,Y); F+(x02x0); plot(,); holon; e =E-; els u0; en endelse loal a; x=sr2doube(g(handles3,trn)); 04sr2dule(t(handles。4,trin)); y03=str2doble(get(hanles.y,strig)
19、); y4=str2dube(get(anles。y4,stin)); bt2dule(get(anles。bchng,string)); j=str2doule(ge(handles.j,sti); Rsr2doble(et(hande。r,strig)); l=(04y03)2(x0x03)2)05;=(y04)l;n=(x004)/l;x=(03+x)/2(R2-2/)0。*m;yy(y3+y04)+(2l24)0。5n;if(x0=xxxx) i x0 jx=jxyiyy; end f yj0 jvyvyxxxi; end flg=0; i(jvxm) xjx-;fa=1; xixi+
20、b; jx=mod(v,m); end (jvym) yj=yj-1;fla=; yyi+; jvy=mod(jvy,); end if flag=1 XC()xi; C(k)yi; k=k+1; en endnd i=x;yi=yy+R;xii=xx;ii=yyR; %第一象限顺圆插补 jv=0; jv0; n=i(x04xx)/b);n=fix(+R-y04)/b); %第一象限的计数器 m=2j; xis auo; whie (x|yn0) if jvx=vx+yyy; end f n0 jvy=+xix; nd fag=0; if(jvxm) xn=xn1;lag=; i=i+b; jx=md(jvx,); end if(jym) y=n1;flg=1; yiyi-; jvyod(vy,m); end if lag= XC()=i; YC(k)=yi; k=k; end en a=piaan(as(y0yy)(x0-xx)); batan(abs((0yy)/(xx)); alphb:i/100:a; X=xx+R*cos(alpha); YQ=y+R*sin(alp); plot(Q,Q) hld n; pl(x,y,Ro); i l= a=fa; elseif fl= line(x03,XC(1),
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1