资源简介
数控插补源程序代码以及课设报告模板,直线插补和圆弧插补都有,DDA直线插补和逐点比较圆弧插补

代码片段和文件信息
% init part
close all
clear all
clc
global x y speed steplengh;
%初始化参数------------------------------
clockwise=0;% 1:clockwise 0: anti-clockwise
speed=0.1; %speed of running插补速度.
xs =4; % x start point x起始点
ys =-4; % y start point y起始点
xe =4; % x end point x终点
ye =4; % y end point y终点
x0=0;%圆心坐标
y0=0;%圆心坐标
steplengh=0.5;%步长
%理论曲线绘制-----------------------------
if clockwise==1%顺时针理论曲线
r=sqrt((xe-x0)^2+(ye-y0)^2);%求半径
rr=1.5*r;
axis([0 rr -rr rr]);
jd=atan((ys-y0)/(xs-x0));
jd1=atan((ye-y0)/(xe-x0));
t=jd1:0.001:jd;
xt = r*cos(t)+x0;
yt = r*sin(t)+y0;
plot(xtyt‘g‘);
axis(‘equal‘);
grid on; %绘制网格
hold on;
elseif clockwise==0 %逆时针
r=sqrt((xe-x0)^2+(ye-y0)^2);
rr=1.5*r;
axis([0 rr -rr rr]);
jd=atan((ys-y0)/(xs-x0));
jd1=atan((ye-y0)/(xe-x0));
t=jd:0.001:jd1;
xt = r*cos(t)+x0;
yt = r*sin(t)+y0;
plot(xtyt‘g‘);
axis(‘equal‘);
grid on;
hold on;
end
% main part--------------------------------------------
%Go( )--进给函数,每步进给绘图
%Go(10)-- x方向正向进给一步
%Go(01)-- y方向正向进给一步
%Go(-10)-- x方向负向进给一步
%Go(0-1)-- y方向负向进给一步
Go(xsys); % move to start point.
f=0; %f--偏差函数
x=xs;
y=ys;
if ys*ye<0
zero=sqrt(r^2-y0^2)+x0;
N=abs(xe-zero)+abs(xs-zero)+abs(ye-ys);
else
N=abs(xe-xs)+abs(ye-ys); % 进给步数
end
if clockwise==1 %顺时针圆弧插补
while (N>0)
if y>0
if f >= 0 % check error.
Go(0-steplengh); % x go
f = f-2*(y-y0)+steplengh; % calculate new error f.
y = y-steplengh; % change x coordination.
N=N-steplengh;
else
Go(steplengh0); % y go
f = f+2*(x-x0)+steplengh; % calculate new error f.
x =x+steplengh; % change y coordination.
N=N-steplengh;
end
elseif y<=0
if f >= 0 % check error.
Go(-steplengh0); % x go
f = f-2*(x-x0)+steplengh; % calculate new error f.
x = x-steplengh; % change x coordination.
N=N-steplengh;
else
Go(0-steplengh); % y go
f = f-2*(y-y0)+steplengh; % calculate new error f.
y = y-steplengh; % change y coordination.
N=N-steplengh;
end
end
end
%逆时针圆弧插补
elseif clockwise==0
while (N>0)
if y>=0
if f >= 0 % check error.
Go(-steplengh0); % x go
f = f-2*(x-x0)+steplengh; % calculate new error f.
x =x-steplengh; % change x coordination.
N=N-steplengh;
else
Go(0steplengh); % y go
f = f+2*(y-y0)+steplengh; % calculate new error f.
y =y+steplengh; % change y coordination.
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 335797 2018-05-19 00:23 插补源程序\.doc.doc
文件 3724 2018-05-19 00:11 插补源程序\Comparecircle.m
文件 2017 2018-05-18 23:00 插补源程序\DDALINE.m
文件 3469 2018-05-18 23:16 插补源程序\DDAcircle.m
文件 161 2018-05-15 22:52 插补源程序\Go.m
文件 45436 2018-05-17 04:09 插补源程序\unti
文件 16315 2018-05-16 20:32 插补源程序\unti
目录 0 2018-05-19 00:27 插补源程序\
相关资源
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
- matlab识别系统
评论
共有 条评论