機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)_第1頁(yè)
機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)_第2頁(yè)
機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)_第3頁(yè)
機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)_第4頁(yè)
機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩12頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、 機(jī)床數(shù)控技術(shù)課程設(shè)計(jì)說(shuō)明書學(xué)校:南京航空航天大學(xué)專業(yè):機(jī)械工程及自動(dòng)化學(xué)號(hào):姓名:設(shè)計(jì)題目:PL1 DC21指導(dǎo)老師:時(shí)間:一課設(shè)任務(wù):1.PL1-逐點(diǎn)比較法插補(bǔ)第1象限直線;2.DC21-DDA法插補(bǔ)第21象限順圓弧。二課設(shè)要求:1.具有數(shù)據(jù)輸入界面,如輸入直線插補(bǔ)的起點(diǎn)、終點(diǎn),圓弧插補(bǔ)的起止點(diǎn)、圓心或半徑、插補(bǔ)的步長(zhǎng)等;2.具有插補(bǔ)過(guò)程的動(dòng)態(tài)顯示功能,如單步插補(bǔ)、連續(xù)插補(bǔ)等;3.插補(bǔ)的步長(zhǎng)可調(diào);4.直線的起點(diǎn)、圓弧的圓心在坐標(biāo)系中的位置可變(即直線的起點(diǎn)、圓弧的圓心可不設(shè)定在坐標(biāo)原點(diǎn))5.建議使用C語(yǔ)言編程,有條件者可使用VB、VC等語(yǔ)言編程。三程序界面及運(yùn)行截圖1.直線連續(xù)插補(bǔ):2.

2、直線單步插補(bǔ):3. 圓弧連續(xù)插補(bǔ):4.圓弧單步插補(bǔ):四、程序流程圖1.PL1:逐點(diǎn)比較法插補(bǔ)第1象限直線逐點(diǎn)比較法插補(bǔ)直線的過(guò)程為每進(jìn)給一步需完成偏差判別,坐標(biāo)進(jìn)給,偏差計(jì)算,終點(diǎn)判別四個(gè)步驟,具體流程如圖1 所示。開始E=E-1YNY向正Y方向前進(jìn)一步F=F+(x02-x01)向正X方向前進(jìn)一步F=F-(y02-y01)F>=0E>0N結(jié)束E=(abs(x01-x02)+abs(y01-y02)/k (總步數(shù))F=0 (判別函數(shù))初始化,輸入起點(diǎn)x01、y01,終點(diǎn)x02、y02,步長(zhǎng)k2、DDA法圓弧插補(bǔ)xm=fix(xx-x03)/b);ym=fix(yy+R-y03)/b)

3、Yjvx=0;jvy=0m=2jxm>0?jvx=jvx+yj-yyYNym>0?jvy=jvy+xx-xjYjvx溢出?>0?+X前進(jìn)一步xm=xm-1Yjvy溢出?>0?+Y前進(jìn)一步y(tǒng)m=ym-1xm>0|ym>0?N二一象限順圓?計(jì)算圓心坐標(biāo)(xx,yy)xj=x03,yj=y03初始化,輸入起點(diǎn)坐標(biāo)(xr03,y03),終點(diǎn)坐標(biāo)(x04,y04) 半徑R步長(zhǎng)b和寄存器位數(shù)j開始NY+X前進(jìn)一步xn=xn-1-Y前進(jìn)一步y(tǒng)n=yn-1xn=fix(x04-xx)/b);yn=fix(yy+R-y04)/b);Nxn>0?jvx=jvx+yj-yy

4、YNyn>0?jvy=jvy+xj-xxYjvx溢出?>0?Yjvy溢出?>0?xn>0|yn>0?NY結(jié)束五程序及變量說(shuō)明(Matlab)function varargout = cxy_050910610(varargin)gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, . 'gui_Singleton', gui_Singleton, . 'gui_OpeningFcn', cxy_050910610_OpeningFcn, . '

5、gui_OutputFcn', cxy_050910610_OutputFcn, . 'gui_LayoutFcn', , . 'gui_Callback', );if nargin && ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end f

6、unction cxy_050910610_OpeningFcn(hObject, eventdata, handles, varargin)global uu=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, ha

7、ndles)global x01;x01=str2double(get(handles.x1,'string'); function x1_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end function

8、x2_Callback(hObject, eventdata, handles)global x02;x02=str2double(get(handles.x2,'string'); function x2_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor&#

9、39;,'white');end function y1_Callback(hObject, eventdata, handles)global y01;y01=str2double(get(handles.y1,'string'); function y1_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')

10、set(hObject,'BackgroundColor','white');end function y2_Callback(hObject, eventdata, handles)global y02;y02=str2double(get(handles.y2,'string'); function y2_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defa

11、ultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end function x3_Callback(hObject, eventdata, handles)global x03;x03=str2double(get(handles.x3,'string'); function x3_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'Back

12、groundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end function y3_Callback(hObject, eventdata, handles)global y03;y03=str2double(get(handles.y3,'string'); function y3_CreateFcn(hObject, eventdata, handles)if ispc &&

13、amp; isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end function x4_Callback(hObject, eventdata, handles)global x04;x04=str2double(get(handles.x4,'string'); function x4_CreateFcn(hObject,

14、 eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end function y4_Callback(hObject, eventdata, handles)global y04;y04=str2double(get(handles.y4,'string'

15、;); function y4_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end function r_Callback(hObject, eventdata, handles)global R;R=str2double(g

16、et(handles.r,'string'); function r_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end function clear_Callback(hObject, eventdata,

17、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,

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

19、(get(handles.y4,'string');R=str2double(get(handles.r,'string');l=sqrt(y04-y03).2+(x04-x03).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 l

20、xcb_Callback(hObject, eventdata, handles)global s F X Y;if s=1 x01=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,'str

21、ing'); 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-k,Y,100); F=F+(x02-x01); plot(p,q,'r'); end E=E-1; endelse x03=str2double(get(handles.x3,'string'

22、;); 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=(

23、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('請(qǐng)輸入第二一象限的順圓弧');else xi=x03;yi=y03;xii=x03;yii=y03; jvx=0; jvy=0; xj=fix(xx-x03)/b);yj=fix(yy+R-y03)/b);

24、%計(jì)算步數(shù) m=2j; %模 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; y

25、ii=yi; end endend line(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 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; jv

26、x=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'); xii=xi; yii=yi; hold on; end end end function dbcb_Callback(hObject, eventdata, handles)global X Y F u E s;if s=1 x01=str2double(get(handles.x1,'string'); y0

27、1=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=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=lin

28、space(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 fla; x03=str2double(get(handles.x3,'string'); x04=str2double(get(handles.x4,'string'); y03

29、=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=

30、(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('請(qǐng)輸入第二一象限的順圓弧');else %第二象限的順圓插補(bǔ) xi=x03;yi=y03; jvx=0; jvy=0; xj=fix(xx-x03)/b);yj=fix(yy+R-y03)/b); %第二象限的計(jì)數(shù)器 m=2j; k=1; while (xj>0|yj>0) if xj

31、>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 XC(k)=xi; YC(k)=yi; k=k+1; end end end xi=xx;yi=yy+R;xii=xx;yii=yy+R; %第一象限順圓插補(bǔ) jvx=0; jvy=0; xn=fix(x04-xx)/b)

32、;yn=fix(yy+R-y04)/b); %第一象限的計(jì)數(shù)器 m=2j; axis auto; while (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/100:a; XQ=xx+R*cos

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論