国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee
ELEOK
標(biāo)題:
51單片機(jī)半自動(dòng)洗衣機(jī)系統(tǒng)Proteus仿真程序
[打印本頁(yè)]
作者:
coolice
時(shí)間:
2020-1-23 00:29
標(biāo)題:
51單片機(jī)半自動(dòng)洗衣機(jī)系統(tǒng)Proteus仿真程序
基于c51單片機(jī),基本功能:按鍵調(diào)節(jié)模式,時(shí)間,電機(jī)轉(zhuǎn)動(dòng),led顯示,報(bào)警等功能
歡迎討論
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51單片機(jī)洗衣機(jī)程序.zip
(242.22 KB, 售價(jià): 1 E幣)
2020-1-23 00:29 上傳
點(diǎn)擊文件名下載附件
售價(jià): 1 E幣
[記錄](méi)
[
購(gòu)買(mǎi)
]
1.jpg
(135.38 KB)
下載附件
2020-1-23 00:27 上傳
單片機(jī)源程序如下:
#include<reg52.h>
#include<intrins.h>
#include<absacc.h>
sbit m=P2^0;
sbit time_set=P2^1;
sbit mode=P2^2;
sbit ma=P1^0;
sbit mb=P1^1;
sbit waterin=P1^3;
sbit washing=P1^2;
sbit waterout=P1^4;
sbit finish=P1^5;
sbit tuoshui=P1^6;
sbit T_key=P1^7;
sbit SPEAKER=P3^0;
sbit LCD_E=P3^1;
sbit Honggan=P3^4;
sbit motor=P3^5;
sbit LCD_RS=P3^6;
sbit LCD_RW=P3^7;
#define LCD_DB P0
#define daport XBYTE[0x8000] // 0832地址 Y0
#define uchar unsigned char
#define uint unsinged int
void LCD_init(void);
void LCD_write_command(uchar command);
void LCD_write_data(uchar dat);
void LCD_disp_char(uchar x,uchar y,uchar dat);
void delay_n40us(int n);
int time[3]={0,0,0};
int time1=0,t1,t2,t3;
unsigned char pos[6]={0x01,0x02,0x08,0x10,0x40,0x80};
unsigned char DSY_CODE[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
unsigned char code work_order[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
int count=0,time_wash=1,time_total=100,model=0,mo_shi=0;moshi_set=0,flag=9500,inte_wrong=0;
int z=0,begin=0,minute=0,second=0,hour=0,minute1=0,second1=0,hour1=0;
int water[2]={0,0};
sbit led=P0^0;
void delay1(unsigned char i1)
{
unsigned char ii;
unsigned int jj;
for (ii=0;ii<i1;ii++)
for (jj=0;jj<0x10;jj++);
}
void motor1()
{
char hight,low;
bit updown;
updown=1;
hight=0xff;
low=0x00;
while( time_total==7||time_total==6||time_total==5)
{
daport=0xff; // 輸出5V
delay1(hight);
daport=0x00; // -5V
delay1(low);
if (updown)
{ ma=1;
mb=0; //改變占空比
hight++;
low--;
if (hight==0xff) updown=0;
}
else
{ mb=0;
ma=1;
hight--;
low++;
if (hight==0x0) updown=1;
}
}
}
void delay()
{
unsigned char i;
for(i=0;i<20;i++);
}
void Delayms(int t)
{
int x,y;
for(x=t;x>0;x--)
for(y=120;y>0;y--);
}
void sound()
{
int i=0;
for(i=0;i<=10;i++)
SPEAKER=1;
for(i=0;i<=5;i++)
SPEAKER=0;
}
void LCD_init(void)
{
LCD_write_command(0x38);
LCD_write_command(0x0c);
LCD_write_command(0x06);
LCD_write_command(0x01);
LCD_write_command(0x02);
delay_n40us(100);
}
void LCD_write_command(uchar dat)
{
LCD_DB=dat;
LCD_RS=0;
LCD_RW=0;
LCD_E=1;
LCD_E=0;
delay_n40us(1);
}
void LCD_write_data(uchar dat)
{
LCD_DB=dat;
LCD_RS=1;
LCD_RW=0;
LCD_E=1;
LCD_E=0;
delay_n40us(1);
}
void LCD_disp_char(uchar x,uchar y,uchar dat)
{
uchar address;
if(y==1)
address=0x80+x;
else
address=0xc0+x;
LCD_write_command(address);
LCD_write_data(dat);
}
void delay_n40us(int n)
{
int i;
uchar j;
for(i=n;i>0;i--)
for(j=0;j<2;j++);
}
int main()
{
int i,d2;
IE=0x87;
TCON=0x05;
TMOD=0x11;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
ET1=1;
TR0=0;
LCD_init();
motor=0;
while(1)
{
int j=0,time_wash_dis;
//PA=work_order[w];
//PA=work_order[w];
while(begin==0)
{ waterout=1;
finish=1;
waterin=1;
tuoshui=1;
washing=1;
T_key=1;
//HEAT1=1;
//HEAT2=0;
if(Honggan==0)
{Delayms(200);
if(Honggan==0)
{mo_shi=mo_shi+1;
if(mo_shi==2)
{mo_shi=0;}}}
if(mode==0)
{Delayms(200);
if(mode==0)
{model=model+1;
if(model==4)
{model=0;}
}}
if(time_set==0)
{Delayms(200);
if(time_set==0)
{time_wash=time_wash+1;
if(time_wash==10)
{time_wash=1;}}}
if(m==0)
{Delayms(200);
if(m==0&&time_wash>0)
{time_wash=time_wash-1;
}
}
time_wash_dis=DSY_CODE[time_wash];
LCD_disp_char(14,1,time_wash_dis);
LCD_disp_char(15,1,'0');
if(mo_shi==0)
{
LCD_disp_char(0,2,'n');
LCD_disp_char(1,2,'o');
LCD_disp_char(2,2,'r');
LCD_disp_char(3,2,' ');
}
if(mo_shi==1)
{
LCD_disp_char(0,2,'s');
LCD_disp_char(1,2,'o');
LCD_disp_char(2,2,'f');
LCD_disp_char(3,2,'t');
}
time[1]=time_wash;
//writetlc5615(137);
}
//初始啟動(dòng)設(shè)置
while(inte_wrong)
{
sound();
}
if(time_total==9||time_total==8) //進(jìn)水
{
waterin=0;
}
if(time_total==7||time_total==6||time_total==5) //洗滌
{ waterin=1;
washing=0;
motor1();
}
if(time_total==4||time_total==3) // 排水
{ washing=1;
ma=0;
mb=0;
waterout=0;
}
if(time_total==2) //脫水
{ waterout=1;
tuoshui=0;
}
if(time_total==0)
{ sound();
finish=0;
tuoshui=1;
Delayms(200);
Delayms(200);
Delayms(200);
while(1){
LCD_disp_char(0,2,'f');
LCD_disp_char(1,2,'i');
LCD_disp_char(2,2,'n');
LCD_disp_char(3,2,'i');
LCD_disp_char(4,2,'s');
LCD_disp_char(5,2,'h');
LCD_disp_char(6,2,' ');
LCD_disp_char(7,2,' ');
LCD_disp_char(8,2,' ');
LCD_disp_char(9,2,' ');
LCD_disp_char(10,2,' ');
LCD_disp_char(11,2,' ');
LCD_disp_char(12,2,' ');
LCD_disp_char(13,2,' ');
LCD_disp_char(14,2,' ');
LCD_disp_char(15,2,' ');
LCD_disp_char(0,1,' ');
LCD_disp_char(1,1,' ');
LCD_disp_char(2,1,' ');
LCD_disp_char(3,1,' ');
LCD_disp_char(4,1,' ');
LCD_disp_char(5,1,' ');
LCD_disp_char(6,1,' ');
LCD_disp_char(7,1,' ');
LCD_disp_char(8,1,' ');
LCD_disp_char(9,1,' ');
LCD_disp_char(10,1,' ');
LCD_disp_char(11,1,' ');
LCD_disp_char(12,1,' ');
LCD_disp_char(13,1,' ');
LCD_disp_char(14,1,' ');
LCD_disp_char(15,1,' ');
T_key=1;
TR1=0; }
}
// SPEAKER=0;
/* for(i=0;i<3;i++)
{ t1=DSY_CODE[time[i]/10];
LCD_disp_char(j,1,t1);
t2=DSY_CODE[time[i]%10];
LCD_disp_char(j+1,1,t2);
j=j+3;
} */
}
return 0;
}
void time_interrrupt0() interrupt 1 // 定時(shí)中斷
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
if(++count==2)
{ time1+=1;
t1=DSY_CODE[time1/10];
LCD_disp_char(0,1,t1);
t2=DSY_CODE[time1%10];
LCD_disp_char(1,1,t2);
if(time1>=60&&second==0)
{time[1]=time[1]-1;
time[2]=9;
}
if(time1>=60&&second!=0)
{time[2]=time[2]-1;
}
if(time1>=60)
{time1=0;}
hour=time[0];
minute=time[1];
second=time[2];
time_total=10*minute+second;
hour1=DSY_CODE[hour];
minute1=DSY_CODE[minute];
second1=DSY_CODE[second];
LCD_disp_char(13,1,hour1);
LCD_disp_char(14,1,minute1);
LCD_disp_char(15,1,second1);
count=0;
}
}
void begain() interrupt 0 //啟動(dòng)中斷
{
begin=~begin;
TR0=1;
T_key=0;
}
void wrong() interrupt 2 //故障中斷
{
inte_wrong=~inte_wrong;
TR0=~TR0;
}
復(fù)制代碼
歡迎光臨 ELEOK (http://www.afoofa.cn/)
Powered by Discuz! X5.0