The washing machine controller based on the single chip microcomputer
uses a two-digit digital tube to display the washing time, and uses a driver chip to control the motor rotation .
The course design of the fully automatic washing machine
is based on the 51 single chip microcomputer and implemented in C language.
Basic requirements
Simulate the working process of the fully automatic washing machine. Replace the washing machine motor with a motor. Display the working status of the washing machine (water inlet, soaking, washing, dehydration, end). Display the remaining working time (the washing program can be customized, the time accuracy is: seconds).
Alternate forward and reverse when washing.
Extension requirements
Different motor speeds during washing and dehydration. Add water level sensor input. Fault alarm. Add sound prompts. Other custom functions.
Design with Preteus simulation:
0.png (203.38 KB, Downloads: 13)
Download attachments and save them to the photo album
Uploaded on 2018-6-25 06:57
The simulation diagram is as follows:
#include //****************************// #define uchar unsigned char #define uint unsigned int //*******************************// //***************************// sbit mo_r = P3^2; //Motor right control line sbit mo_l = P3^3; //motor left control line //****************************// sbit key_menu = P3^4; // Menu button sbit key_on = P3^5; // Start button sbit key_off = P3^6; // End key sbit key_se = P3^7; // Menu selection button //***************************// sbit led_in = P0^0; // Water inlet indicator light sbit led_xi = P0^1; // laundry indicator light sbit led_pao = P0^2; //bath indicator light sbit led_xx = P0^3; // Dehydration indicator light sbit led_out = P0^4; // Water out indicator light sbit led_over = P0^5; // Washing end indicator light sbit led_work = P0^6; // Motor working indicator light sbit led_wring = P0^7; // Alarm indicator light sbit other = P3^1; // Dehydration power control switch sbit anther = P3^0; // Washing machine power control switch //******************************// uchar code num[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; // //*********************************// char sec = 0; // time seconds char min = 0; // time division uchar count=0; // interrupt count uchar flag0=0; //Washing machine working status flag uchar flag1=0; //Water inflow times flag uchar flag2=0; //Water discharge times flag uchar flag3=0; // Washing times flag uchar err =0; // alarm flag uchar quan = 0; // forward and reverse count //**********************************// // Function declaration //****************************************// void delay(); // Delay function void in(); // Water inlet subroutine void out(); // water out subroutine void over(); // End subroutine void xi(); // laundry subroutine void pao(); // bubble clothing subroutine void xx(); // dehydration subroutine void on(); //Work on processing subroutine void se(); // Display menu selection void SEG_display(); //Display time subroutine void key_scan(); //Key scanning subroutine //*********************************// // Delay function //****************************// void delay(uint i) { uint x,y; for(x=i;x>0;x--) for(y=120;y>0;y--); } //******************************// //Work on processing subroutine //************************************// void on() { TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; P0 = 0xff; if(flag0 == 0) in(); if(flag0 == 1) xi(); if(flag0 == 2) pao(); if(flag0 == 3) xx(); if(flag0 == 4) out(); } //*******************************// // End subroutine //*************************************// void over() {other=0; anther=0; P0 = 0xff; mo_r=0; mo_l=0; led_over = 0; EA=0; } //*************************************// // Water inlet subroutine //*************************************// void in() { anther=0; other=0; P0 = 0xff; led_in = 0; flag1++; mo_r = 0; mo_l = 0; min = 0; sec = 8; } //*************************************// // Laundry subroutine //*************************************// void xi() { anther=1; other=0; P0 = 0xff; led_work = 0; led_xi = 0; mo_r = 1; mo_l = 0; min = 1; sec = 36; quan = 0; } //*************************************// // Soaking clothes subroutine //*************************************// void pao() { another=1; other=0; P0 = 0xff; led_pao = 0; led_work = 0; flag3++; mo_r = 1; mo_l = 0; min = 1; sec = 35; quan = 0; } //*************************************// // Dehydration subroutine //*************************************// void xx() {other=1; anther=0; P0 = 0xff; led_xx = 0; mo_r = 0; mo_l = 1; min = 0; sec = 50; } //*************************************// // Water outlet subroutine //*************************************// void out() { anther=0; other=0; P0 = 0xff; led_out = 0; flag2++; mo_r = 0; mo_l = 0; min = 0; sec = 5; } //*************************************// // Display menu selection //*************************************// void se() { P0 = 0xff; if(flag0 >= 5) flag0 = 0; if(flag0 == 0) { led_in = 0; } if(flag0 == 1) { led_xi=0; } if(flag0 == 2) { led_pao=0; } if(flag0 == 3) { led_xx=0; } if(flag0 == 4) { led_out=0; } } //************************************// //Menu processing subroutine //**********************************// void menu() { min = 0; sec = 0; mo_r=0; mo_l=0; SEG_display(); while(1) { if(key_on == 0) { delay(5); if(key_on == 0) { while(!key_on); on(); break; } } //**************************// if(key_off == 0) { delay(5); if(key_off == 0) { while(!key_off); over(); break; } } //****************************// if(key_se == 0) { delay(5); if(key_se == 0) { while(!key_se); flag0++; se(); } } } } //*************************************// //Key scanning subroutine //*************************************// void key_scan() { if(key_menu == 0) { delay(5); if(key_menu == 0) { while(!key_menu); menu(); } } //************************************// if(key_on == 0) { delay(5); if(key_on == 0) { while(!key_on); on(); } } //*************************************// if(key_off == 0) { delay(5); if(key_off == 0) { while(!key_off); over(); } } } //*******************************// // Display subroutine //*************************************// void SEG_display() { P1=0x01; P2 = num[min/10]; delay(10); P1 = 0x02; P2 = num[min%10]; delay(10); P1 = 0x04; P2 = num[sec/10]; delay(10); P1 = 0x08; P2 = num[sec%10]; delay(10); } //*************************************// // Main function //*************************************// void main() { led_in=0; anther=0; other=0; while(1) { SEG_display(); key_scan(); } } //**********************************// // Timer 0 interrupt handler //**********************************// void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%256; count++; if(count==20) { count = 0; sec--; if((flag0==1)||(flag0==2)) { quan++; switch(quan) { case 1:mo_r=1;mo_l=0;break; case 10:mo_r=0;mo_l=0;break; case 15:mo_r=0;mo_l=1;break; case 25:mo_r=0;mo_l=0;break; default:; } if(quan==30) { quan=0; } } //**********************************// if((sec == 0)&&(min != 0)) { min--; sec = 59; } //**********************************// if((sec<0)&&(min==0)&&(flag0==0)) //Water inflow ends { switch(flag1) { case 1:flag0=1;xi();break; case 2:flag0=2;pao();break; case 3:flag0=2;pao();break;
Previous article:Single chip electronic clock class design assembly language code and proteus simulation
Next article:VL53L0X laser ranging module MCU driver
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- [GD32L233C-START Review] 5. UART+DMA receives variable length data
- 【TI Course】What is the resolution within 5 meters?
- Class AB amplifiers are replaced by Class D amplifiers
- Design of Internet Radio Based on RVB2601
- About MSP430 MCU serial communication data loss
- ccs5.5 printf console output cannot be displayed
- How to lay out the multi-rail power supply design of the application circuit board
- Made a power module with LM317
- Live streaming portal is now open | How TI can develop AI camera applications faster, simpler and at a lower cost
- What kind of operation circuit is U2?