Design of fully automatic washing machine based on 51 microcontroller
(Simulation + Program + Schematic + Design Report)
Function introduction
Specific functions:
1. Set 4 washing modes: “standard”, “economy”, “individual” and “drainage”.
2. Divided into strong washing and weak washing (motor speed).
3. The process is divided into “water intake”, “rinsing”, “washing” and “dehydration”.
4. Buttons control start, pause, and continue.
5. Different washing modes are divided into different washing processes.
Detailed process
Components used:
Microcontroller: STC89C51;
(Note: The microcontroller is universal, whether it is 51 or 52, whether it is stc or at, the pin functions are the same. The program is also the same.)
#include<reg51.h> #define uchar unsigned char #define uint unsigned int uchar num=0,num1=0,num2=0,num3=0,num4=0,num5=0,num6=0,flag=0,flag1=0,flag4=0,flag5=0,circle=0; sbit ledbiaozhun=P1^0; //LED indicator light sbit ledjingji =P1^1; sbit leddandu =P1^2; sbit ledpaishui =P1^3; sbit ledqiangxi =P1^4; sbit ledruoxi =P1^5; sbit ledxidi =P1^6; sbit ledpioxi =P1^7; sbit ledtuoshui =P2^0; sbit sshuiwei =P3^6; //water level switch sbit sgai =P3^7; //Lid switch sbit paishui=P2^3; //Drain valve control sbit jinshui=P2^2; //Water inlet valve control sbit U2=P2^4; sbit U3=P2^5; sbit k1=P3^0; // Stepwise change "standard, economical, separate, drainage" four modes sbit k2=P3^1; //Strong washing, weak washing sbit k3=P3^2; //Run, pause and cancel the alarm function void init() { uchar a=0,b=0,c=0; TMOD=0x01; //T0 works in mode 1 TH0=(65536-50000)/256; //Timing time 50ms TL0=(65536-50000)%6; EA=1; //Enable total interrupt ET0=1; //Enable T0 interrupt TR0=0; //Close T0 EX0=1; //Enable external interrupt 0 IT0=1; //External interrupt 0 edge trigger mode U2=1; //Motor stops U3=1; P0=0xff; } void delayms(uint xms) //Delay { uint i,j; for(i=xms;i>0;i--) for(j=110;j>0;j--); } void key() //Control button { circle=1; if(k1==0) //Standard, economical, separate, drainage pressed { delayms(10); //Delay debounce if(k1==0) //Rejudgment { num + +; //The number of K1 presses increases by 1 if(num==4) num=0; //Equal to 4, the number of presses is cleared to 0 while(!k1); //Wait for the key to be released } } \t if(k2==0) //Strong and weak selection { delayms(10); //Delay debounce if(k2==0) //Rejudgment { num1 + + ; //Add 1 to the number of presses if(num1==2) num1=0; //Equal to 2, the number of presses is cleared to 0 while(!k2); //Wait for the key to be released } } } void qiang() //strong { if(flag4==0) //Motor rotates forward { U2=0; U3=1; } if(flag4==1) //Motor reverses { U2=1; U3=0; } } void ruo() //weak { if(flag5==0) //Motor rotates forward { U2=0; U3=1; } if(flag5==1) //Motor reverses { U2=1; U3=0; } } void qbiaozhun() //strong standard { /************wash************/ num=0; num1=0; ledbiaozhun=0;//Standard washing LED lights up ledqiangxi=0; //Strong washing LED lights up jinshui=0; //Open the water inlet valve ledxidi=1; //washing ledpioxi=1; //Rinse LED bright ledtuoshui=1; //Dehydration LED lights up delayms(5000);//water level monitoring jinshui=1; //Close the water inlet valve ledxidi=0; flag1=1; // TR0=1; //Start timer T0 while(flag==0)//flag is the washing number flag { if(flag==0 & amp; & amp;num2==1) { TR0=1; flag1=1; // qiang(); } if(flag==0 & amp; & num2==2) { TR0=0; //Close timer T0 U2=1; //Motor stops U3=1; } }; //rinse U2=1; U3=1; TR0=0; flag1=0; paishui=0; //drainage ledtuoshui=1; ledpioxi=1; ledxidi=1; delayms(5000); paishui=1; //Close drainage delayms(100); jinshui=0; //Turn on water inlet delayms(5000); jinshui=1; //Close water inlet ledpioxi=0; flag1=2; TR0=1; num3=0; num4=0; while(flag==1) { if(flag==1 & amp; & amp;num2==1)//Strong rinse { TR0=1; flag1=2; qiang(); } if(flag==1 & amp; & num2==2)//Pause strong rinse { TR0=0; U2=1; U3=1; } }; //rinse U2=1; U3=1; TR0=0; flag1=0; paishui=0; ledtuoshui=1; ledpioxi=0; delayms(5000); paishui=1; delayms(100); jinshui=0; delayms(5000); jinshui=1; flag1=2; TR0=1; num3=0; num4=0; \t\t while(flag==2) { if(flag==2 & amp; & num2==1) { TR0=1; flag1=2; qiang(); } if(flag==2 & amp; & num2==2) { TR0=0; U2=1; U3=1; } } ; //dehydration U2=1; U3=1; TR0=0; flag1=0; paishui=0;//Open drainage ledtuoshui=0; ledpioxi=1; while(sgai); paishui=1; delayms(1000); flag1=3; TR0=1; num3=0; num4=0; while(flag==3) { if(flag==3 & amp; & amp;num2==1) { TR0=1; U2=0; U3=1; flag1=3; } if(flag==3 & amp; & amp;num2==2) { TR0=0; U2=1; U3=1; } }; ledtuoshui=1; U2=1; U3=1; flag1=0; } void qjingji() //Strong economy { /************wash************/ num=0; num1=0; ledjingji=0; ledqiangxi=0; ledtuoshui=1; ledpioxi=1; ledxidi=1; jinshui=0; delayms(5000); jinshui=1; flag1=1; //Control the washing indicator light in the timer TR0=1; while(flag==0) { if(flag==0 & amp; & amp;num2==1) { TR0=1; flag1=1; qiang(); } if(flag==0 & amp; & num2==2) { TR0=0; U2=1; U3=1; } }; \t\t //rinse TR0=0; U2=1; U3=1; flag1=0; paishui=0; ledjingji=0; ledtuoshui=1; ledxidi=1; delayms(5000); paishui=1; delayms(100); jinshui=0; delayms(5000); jinshui=1; ledpioxi=0; flag1=2; TR0=1; num3=0; num4=0; while(flag==1) { if(flag==1 & amp; & num2==1) { TR0=1; flag1=2; qiang(); } if(flag==1 & amp; & num2==2) { TR0=0; U2=1; U3=1; } }; //dehydration TR0=0; U2=1; U3=1; flag1=0; paishui=0; //Turn on drainage ledjingji=0; ledtuoshui=0; ledpioxi=1; delayms(5000); while(sgai); paishui=1; delayms(1000); flag1=3; TR0=1; flag=2; num3=0; num4=0; while(flag==2) { if(flag==2 & amp; & num2==1) { TR0=1; U2=0; U3=1; flag1=3; } if(flag==2 & amp; & num2==2) { TR0=0; U2=1; U3=1; } }; ledtuoshui=1; U2=1; U3=1; flag1=0; } void qdandu() //Strongly alone { num=0; num1=0; ledqiangxi=0; ledxidi=0; leddandu=0; jinshui=0; delayms(5000); jinshui=1;//Close the water inlet valve flag1=1; TR0=1; while(flag==0) { if(flag==0 & amp; & amp;num2==1) { TR0=1; flag1=1; qiang(); } if(flag==0 & amp; & num2==2) { TR0=0; U2=1; U3=1; } }; flag1=0; U2=1; U3=1; } void rbiaozhun() //Weak standard { /************wash************/ num=0; num1=0; ledbiaozhun=0; ledruoxi=0; ledtuoshui=1; ledpioxi=1; jinshui=0; delayms(5000); jinshui=1; ledxidi=0; flag1=1; TR0=1; while(flag==0) { if(flag==0 & amp; & amp;num2==1) { TR0=1; flag1=1; ruo(); } if(flag==0 & amp; & num2==2) { TR0=0; U2=1; U3=1; } }; //rinse U2=1; U3=1; TR0=0; flag1=0; paishui=0; ledtuoshui=1; ledxidi=1; delayms(5000); paishui=1; delayms(100); jinshui=0; delayms(5000); jinshui=1; ledpioxi=0; flag1=2; TR0=1; num3=0; num4=0; while(flag==1) { if(flag==1 & amp; & num2==1) { TR0=1; flag1=2; ruo(); } if(flag==1 & amp; & num2==2) { TR0=0; U2=1; U3=1; } }; //rinse U2=1; U3=1; TR0=0; flag1=0; paishui=0; ledtuoshui=1; ledpioxi=0; delayms(5000); paishui=1; delayms(100); jinshui=0; delayms(5000); jinshui=1; flag1=2; TR0=1; num3=0; num4=0; while(flag==2) { if(flag==2 & amp; & num2==1) { TR0=1; flag1=2; ruo(); } if(flag==2 & amp; & num2==2) { TR0=0; U2=1; U3=1; } } //dehydration U2=1; U3=1; TR0=0; flag1=0; paishui=0; delayms(5000); ledtuoshui=0; ledpioxi=1; while(sgai); paishui=1; delayms(1000); flag1=3; TR0=1; num3=0; num4=0; while(flag==3) { if(flag==3 & amp; & amp;num2==1) { TR0=1; U2=0; U3=1; flag1=3; } if(flag==3 & amp; & amp;num2==2) { TR0=0; U2=1; U3=1; } }; ledtuoshui=1; U2=1; U3=1; flag1=0; } void rjingji() //Weak economy { /************wash************/ num=0; num1=0; ledjingji=0; ledruoxi=0; ledtuoshui=1; ledpioxi=1; ledxidi=1; jinshui=0; delayms(5000); jinshui=1; //Open the water inlet valve and let in water flag1=1; TR0=1; while(flag==0) { if(flag==0 & amp; & amp;num2==1) //Weak economic wash { TR0=1; flag1=1; ruo(); } if(flag==0 & amp; & num2==2) //Weak economic wash pause { TR0=0; U2=1; U3=1; } }; \t\t //rinse TR0=0; U2=1; U3=1; flag1=0; paishui=0; //Drain valve opens ledjingji=0; ledtuoshui=1; ledxidi=1; delayms(5000); paishui=1; //Drain valve closed delayms(100); jinshui=0; //The water inlet valve is open delayms(5000); jinshui=1; //The water inlet valve is closed ledpioxi=0; flag1=2; TR0=1; num3=0; num4=0; while(flag==1) { if(flag==1 & amp; & num2==1)//rinse { TR0=1; flag1=2; ruo(); } if(flag==1 & amp; & num2==2)//rinsing pause { TR0=0; U2=1; U3=1; } }; //dehydration TR0=0; U2=1; U3=1; flag1=0; ledjingji=0; ledtuoshui=0; ledpioxi=1; paishui=0; //Drain valve opens delayms(5000); while(sgai); paishui=1; delayms(3000); flag1=3; TR0=1; num3=0; num4=0; while(flag==2) { if(flag==2 & amp; & num2==1) { TR0=1; U2=0; U3=1; flag1=3; } if(flag==2 & amp; & num2==2) { TR0=0; U2=1; U3=1; } }; ledtuoshui=1; U2=1; U3=1; flag1=0; } void rdandu() //weak alone { num=0; num1=0; ledruoxi=0; ledxidi=0; leddandu=0; jinshui=0; //Open the water inlet valve and let in water delayms(5000); jinshui=1; flag1=1; TR0=1; //Start timer T0 while(flag==0) { if(flag==0 & amp; & amp;num2==1) //Weak separate washing { TR0=1; flag1=1; ruo(); } if(flag==0 & amp; & num2==2)//Weak separate wash pause { TR0=0; U2=1; U3=1; } }; flag1=0; U2=1; U3=1; } void dpaishui() //drainage/dehydration { num=0; num1=0; ledpaishui=0; ledtuoshui=0; jinshui=1; paishui=0; delayms(3000); while(sgai); delayms(3000); flag1=3; TR0=1; num3=0; num4=0; while(flag==0) { if(flag==0 & amp; & num2==1) //Dehydration { TR0=1; flag1=3; U2=0; U3=1; } if(flag==0 & amp; & num2==2)//Pause dehydration { TR0=0; U2=1; U3=1; } }; U2=1; U3=1; flag1=0; ledtuoshui=1; paishui=1; drain valve closed }
Key function requirements
(1) Use the “K1” key to step by step change the four modes of “standard, economical, independent, and drainage” and execute the corresponding program. The corresponding indicator light is on.
(2) Use the “K2” key to step by step change the two modes of “strong washing and weak washing”, execute the corresponding program, and the corresponding indicator light will light up.
(3) Use the “K3” key to control the running, pausing and alarm functions of the washing machine.
Mode and function selection requirements
(1) Standard method: water inlet->washing->drainage->water inlet->rinse->drainage->water inlet->rinse->drainage->dehydration.
(2) Economical method: water inlet -> washing -> drainage -> water inlet -> rinsing -> drainage -> dehydration.
(3) Separate mode: water inlet -> washing.
(4) Drainage method: drainage -> dehydration.
Flowchart:
Design information
01 Simulation diagram
This design uses two versions of proteus7.8 and proteus8.9, and is backward compatible, no need to worry! Specifically as shown in the picture!
02 Schematic Diagram
The schematic diagram of this system is a PDF version, as shown in the figure!
?
03 Program
This design is programmed using two versions of the software keil4 and keil5, so there is no need to worry! Specifically as shown in the picture!
?
04 Design Report
Four thousand words design report, details are as follows!
?
05 Design information
All information includes simulation source files, programs (including comments), design reports, etc. The specific content is as follows, the most complete on the entire network! !
?
The following is the open source 51 microcontroller design information
?Everyone learns and makes progress together:
Link: https://pan.baidu.com/s/1ktPDU9wrF0fVSEVjqI9UrQ?pwd=js04
Extraction code: js04
Like and share, learn and progress together! Grow together.