机床数控技术课程设计
更新时间:2024-01-19 06:20:01 阅读量: 教育文库 文档下载
机床数控技术课程设计
说明书
学 专 学 姓
校:南京航空航天大学 业:机械工程及自动化 号: 名:
设计题目:PL1 DC21 指导老师: 时
间:
一.课设任务:
1.PL1-----逐点比较法插补第1象限直线; 2.DC21---DDA法插补第2~1象限顺圆弧。
二.课设要求:
1.具有数据输入界面,如输入直线插补的起点、终点,圆弧插补的起止点、圆心或半径、插补的步长等;
2.具有插补过程的动态显示功能,如单步插补、连续插补等; 3.插补的步长可调;
4.直线的起点、圆弧的圆心在坐标系中的位置可变(即直线的起点、圆弧的圆心可不设定在坐标原点)
5.建议使用C语言编程,有条件者可使用VB、VC等语言编程。
三.程序界面及运行截图
1.直线连续插补:
2.直线单步插补:
3.圆弧连续插补:
4.圆弧单步插补:
四、程序流程图
1.PL1:逐点比较法插补第1象限直线
逐点比较法插补直线的过程为每进给一步需完成偏差判别,坐标进给,偏差计算,
终点判别四个步骤,具体流程如图1 所示。 开始 初始化,输入起点x01、y01,终点x02、y02,步长k E=(abs(x01-x02)+abs(y01-y02))/k (总步数) F=0 (判别函数) E>0 N 结束 Y F>=0 N Y 向正X方向前进一步 F=F-(y02-y01) 向正Y方向前进一步 F=F+(x02-x01) E=E-1
2、DDA法圆弧插补
开始 初始化,输入起点坐标(xr03,y03),终点坐标(x04,y04) 半径R步长b和寄存器位数j N 二一象限顺圆? Y 计算圆心坐标(xx,yy) xj=x03,yj=y03 jvx=0;jvy=0 m=2^j xm=fix((xx-x03)/b); ym=fix((yy+R-y03)/b) N xm>0? Y jvx=jvx+yj-yy ym>0? Y jvy=jvy+xx-xj +X前进一步 xm=xm-1 Y jvx溢出? +Y前进一步 ym=ym-1 jvy溢出? Y xm>0||ym>0? N
N xn=fix((x04-xx)/b); yn=fix((yy+R-y04)/b); N xn>0? Y jvx=jvx+yj-yy yn>0? Y jvy=jvy+xj-xx +X前进一步 xn=xn-1 Y jvx溢出? >0? -Y前进一步 yn=yn-1 jvy溢出? >0? Y xn>0||yn>0? N 结束 五.程序及变量说明(Matlab)
function varargout = 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(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else
gui_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)
varargout{1} = handles.output;
function x1_Callback(hObject, eventdata, handles) 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 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','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')) 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,'defaultUicontrolBackgroundColor')) 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,'BackgroundColor'), 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 && 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, 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'));
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(get(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, 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 s s=0;
function lxcb_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,'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-k,Y,100); F=F+(x02-x01); plot(p,q,'r'); end E=E-1; end else
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&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=2^j; %模 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 end end
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=2^j;
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,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')); 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==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 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&&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=2^j;
k=1;
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 XC(k)=xi; YC(k)=yi; k=k+1; end end
end
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=2^j;
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(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; end end
function buchang_Callback(hObject, eventdata, handles)
function buchang_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function jcq_Callback(hObject, eventdata, handles)
function jcq_CreateFcn(hObject, eventdata, handles) if
ispc
&&
isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
六.心得体会
本次课设是在考研结束后的一周内做完的,时间其实应该是很够的,但是由于本人不善于编程,所以最后完成得很仓促。通过这次课设,我对matlab的操作有了更深的认识,对相关函数语句还有逻辑循环套用的应用有了更深的理解。而且此次课设,让我对逐点比较法直线插补和DDA圆弧插补有了感性和理性的全面认识,对我学习数控机床这门课也有非常大的帮助。最后,遇到困难不要着急,静下心来总有解决办法~
正在阅读:
机床数控技术课程设计01-19
砂轮机安全技术交底03-13
冰心散文推荐:我的老师03-30
西安市 高中物理-全反射测试题04-15
如何评价领导班子成员03-23
师德师风学习教师个人总结03-28
江西省农业厅关于印发《江西省名牌农产品评选认定管理办法》的通知12-26
龙飞监理平行检验数据用表01-22
丁香花作文800字07-06
数据结构学位考试试题06-10
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 数控技术
- 机床
- 课程
- 设计
- 沙湾区2014年下期六年级语文期中学生学业水平测试
- 国际支付考试题库
- 浙江农林大学统计学习题集附带答案
- 公务员考试时钟问题
- 北京三支一扶考试:公共基础地理知识之太阳
- 2017年中国纸浆发展现状与市场前景分析(目录) - 图文
- 安全生产三项制度
- 卫计委全部药食同源食品和新食品原料名单总览
- 水利水电02概预算规定及定额说明
- 货币银行学教学新大纲
- 申报评审中级专业技术职称(资格)综合报告样式
- ACI注册国际心理咨询CIPC模拟六及参考答案
- 化学工程与工艺专业本科培养方案 - 图文
- IPO财务造假案例专题总结 - 会计师与律师篇
- 汽车点火系统的电磁干扰研究
- 翻车机、斗轮机运行维护和事故应急要点
- 部编二年级下册语文二年级下册语文复习计划
- 天祝县财政局财务管理制度
- 热控仪表管路敷设安装作业指导书
- 市政工程施组