Project combat: DIY drive laser engraving machine - laser cutting machine (including production step-kind drawing program PC software) Download

After 51 MCU learning for some time, reference predecessors material using waste drive produced a laser engraving machine, laser cutting machine, here is my production process, to share with you about the success of the new, thanks to information predecessors again, let the younger and less He walked sixty kilometers detour.

Ado directly on the physical map:

First dismantling scrap drive

Here Insert Picture Description
↓ Remove rack stepping motor
Here Insert Picture Description
to drive the housing in this way is folded ↓

Here Insert Picture Description
Thus the screw and fix the stepping motor, the position of the laser is small iron bar.
Here Insert Picture Description
Here Insert Picture Description
The iron bars to make it perpendicular ↓
Here Insert Picture Description
Here Insert Picture Description
this floppy disk is ancient table, all ha recycling ↓
Here Insert Picture Description
starting welding Dupont line ↓
Here Insert Picture Description
basic shape
Here Insert Picture Description
molding
Here Insert Picture Description
PC software screenshot

Here Insert Picture Description

Simple wiring diagram
Here Insert Picture Description
parts lists

Desktop drive X2
L298N motor drive module X2
51 is the smallest system x1
USB-TTL module x1
ULN2003 module x1
250mW laser module x1
wire several

Reference C program

/*z地址定义
50 1=x+,2=x-,3=y+,4=y-
51 前进后退步数高
52 前进后退步数低
53
54/55 字宽
56
57 弱光开关
58/59 激光强度
60 x轴速度
61 y轴速度
62 开始打印0,57
63 暂停
64 停止标志
65
66 左右标记
100开始时灰度图数据
*/

#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define N z[60] //X速度
#define M z[61] //Y速度
sbit a=P1^3;//步进电机接线定义 移动激光头
sbit a_=P1^2;
sbit b=P1^1;
sbit b_=P1^0;
sbit xa=P1^4;
sbit xa_=P1^5;
sbit xb=P1^6;
sbit xb_=P1^7;
/*sbit a=P1^4;//步进电机接线定义 移动底板
sbit a_=P1^5;
sbit b=P1^6;
sbit b_=P1^7;
sbit xa=P1^3;
sbit xa_=P1^2;
sbit xb=P1^1;
sbit xb_=P1^0; */
sbit jg=P2^0;
sbit led=P2^1;//指示灯
uchar xdata z[500]={0};//缓存
uchar buff[3];//串口缓存
uchar x1,x0,y1,y0,cont2=0;
uchar xfb=4,yfb=4;//走步标志位

unsigned char HighRH = 0; //高电平重载值的高字节
unsigned char HighRL = 0; //高电平重载值的低字节
unsigned char LowRH = 0; //低电平重载值的高字节
unsigned char LowRL = 0; //低电平重载值的低字节

void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i–) //i=xms即延时约xms毫秒
for(j=110;j>0;j–);
}

/* 配置并启动PWM,fr-频率,dc-占空比 */
void ConfigPWM(unsigned int fr, unsigned char dc)
{
unsigned int high, low;
unsigned long tmp;

tmp = (11059200/12) / fr; //计算一个周期所需的计数值
high = (tmpdc) / 100; //计算高电平所需的计数值
low = tmp - high; //计算低电平所需的计数值
high = 65536 - high + 12; //计算高电平的重载值并补偿中断延时
low = 65536 - low + 12; //计算低电平的重载值并补偿中断延时
HighRH = (unsigned char)(high>>8); //高电平重载值拆分为高低字节
HighRL = (unsigned char)high;
LowRH = (unsigned char)(low>>8); //低电平重载值拆分为高低字节
LowRL = (unsigned char)low;
TMOD &= 0xF0; //清零T0的控制位
TMOD |= 0x01; //配置T0为模式1
TH0 = HighRH; //加载T0重载值
TL0 = HighRL;
ET0 = 1; //使能T0中断
TR0 = 1; //启动T0
jg = 1; //输出低电平,关闭激光
}
/
关闭PWM /
void ClosePWM()
{
TR0 = 0; //停止定时器0
ET0 = 0; //禁止定时器0中断
jg = 1; //输出低电平,关闭激光
}
/
T0中断服务函数,产生PWM输出 */
void InterruptTimer0() interrupt 1
{
if (jg == 1) //当前输出为低电平时,装载高电平值并输出高电平
{
TH0 = LowRH;
TL0 = LowRL;
jg = 0;
}
else //当前输出为高电平时,装载低电平值并输出低电平
{
TH0 = HighRH;
TL0 = HighRL;
jg = 1;
}
}

void xfor(uint i) //x轴前进函数,前进多少步
{
while(1)
{
if(xfb4)
{
xa=xb=1;
xb_=xa_=0;
xfb=1;
i–;
delayms(N);
if(i
0){xa=xb=0; break;}
}
if(xfb1)
{
xb=xa_=1;
xa=xb_=0;
xfb=2;
i–;
delayms(N);
if(i
0){xa_=xb=0; break;}
}
if(xfb2)
{
xa_=xb_=1;
xb=xa=0;
xfb=3; //走步标志位
i–;
delayms(N);
if(i
0){xa_=xb_=0; break;}
}
if(xfb3)
{
xa_=xb=0;
xb_=xa=1;
xfb=4;
i–;
delayms(N);
if(i
0){xa=xb_=0; break;}
}

            }

}

void xbac(uint i) //xxx后退函数
{
while(1)
{
if(xfb1)
{
xa_=xb=0;
xb_=xa=1;
xfb=4;
i–; //走步标志位
delayms(N);
if(i
0){xa=xb_=0; break;}
}
if(xfb4)
{
xa_=xb_=1;
xb=xa=0;
xfb=3;
i–;
delayms(N);
if(i
0){xa_=xb_=0; break;}
}
if(xfb3)
{
xb=xa_=1;
xa=xb_=0;
xfb=2; //走步标志位
i–;
delayms(N);
if(i
0){xa_=xb=0; break;}
}
if(xfb2)
{
xa=xb=1;
xb_=xa_=0;
xfb=1;
i–;
delayms(N);
if(i
0){xa=xb=0; break;}
}
}
}

void yfor(uint i) //y轴前进函数
{
while(1)
{
switch(yfb)
{
case 4:{a=b=1; b_=a_=0; yfb=1; i–; delayms(M); if(i0){a=b=0;break;}}
case 1:{b=a_=1; a=b_=0; yfb=2; i–; delayms(M); if(i
0){a_=b=0;break;}}
case 2:{a_=b_=1; b=a=0; yfb=3; i–; delayms(M); if(i0){a_=b_=0;break;}}
case 3:{b_=a=1; a_=b=0; yfb=4; i–; delayms(M); if(i
0){a=b_=0;break;}}
}
if(i==0) break;
}
}

void ybac(uint i) //yy后退函数
{
while(1)
{
switch(yfb)
{
case 1:{a=b_=1; b=a_=0; yfb=4; i–; delayms(M); if(i0){a=b_=0;break;}}
case 4:{b_=a_=1; a=b=0; yfb=3; i–; delayms(M); if(i
0){a_=b_=0;break;}}
case 3:{a_=b=1; b_=a=0; yfb=2; i–; delayms(M); if(i0){a_=b=0;break;}}
case 2:{b=a=1; a_=b_=0; yfb=1; i–; delayms(M); if(i
0){a=b=0;break;}}
}
if(i==0) break;
}
}

void dazi(uint zik)//打印函数 打印函数已更改
{
uint x;
jg=0;

for(x=0;x<zik;x++)//执行zik个循环,x轴右移zik步
{
while(z[63]); //暂停等待
if(z[64]==1) break;//停止标志 跳出循环
SBUF=255; // 每开始打印一个点,向上位机发送255,上位机进度显示用
jg=0; //开激光
delayms((z[99+x]*(z[58]*256+z[59]))/100);
jg=1; //关闭激光
if(z[66]1)
{
xbac(1);
}
else
{
xfor(1);
}
}
if(z[64
1]) z[64]=0;
else{yfor(1);} //y轴进一行
z[62]=0; //一行打印完成
SBUF=1; //发送信息,表示打印一行完成

}

/* 串口配置函数,baud-通信波特率 */
void ConfigUART(unsigned int baud)
{
SCON = 0x50; //配置串口为模式1
TMOD &= 0x0F; //清零T1的控制位
TMOD |= 0x20; //配置T1为模式2
TH1 = 256 - (11059200/12/32)/baud; //计算T1重载值
TL1 = TH1; //初值等于重载值
ET1 = 0; //禁止T1中断
ES = 1; //使能串口中断
TR1 = 1; //启动T1
}

void chuanlo() interrupt 4
{
if(RI)
{
buff[cont2]=SBUF;//每次3字节,地址高,地址低,数据,,

++ CONT2;
IF (== CONT2. 3) // 3 bytes for each received, the data is written to the address
{
Z [(BUFF [0] 256) BUFF + [. 1]] = BUFF [2];
CONT2 = 0;
SBUF = 0; // here to add this line test
*************
}
the RI = 0;

}
If (TI)
{
TI = 0;

}
}

Given space limitations, only write part of the code

Finally, if you have any comments or suggestions welcome message to me, let's learn together and progress together,
if the program complete source code and design documents, please leave a message below or private letter I, after seeing will be the first time reply.

Thank you!

Published 74 original articles · won praise 159 · views 70000 +

Guess you like

Origin blog.csdn.net/weixin_44212493/article/details/104334011