一、基本介绍
项目名:基于单片机的全自动洗碗机控制系统
项目名:洗碗机(实物+仿真)
项目编号:mcuclub-dz-138
单片机类型:STC89C52
具体功能:
1、清洗过程:加水——加洗涤剂(3s)——水温加热——清洗(10s)——排水——加水——清洗(10s)——排水——加热烘干及消毒(5s)——(6个继电器模拟),结束后,进行蜂鸣器报警3次
2、通过超声波检测加水水位,加水时,只有水位大于设置最大值,才停止加水。排水时,只有水位小于设置最小值,才停止排水
3、通过防水式DS18B20检测水温,只有水温大于设置最大值,才停止加热
3、通过按键设置各阈值、启停或直接结束清洗
4、通过显示屏显示测量值、当前清洗状态
二、资料总览
实物资料
仿真资料
三、51单片机部分资料展示
1、实物图展示
单片机型号:STC89C52
供电接口:TYPE-C
板子类型:PCB集成板,厚度1.2,两层板(上下层覆铜接地)
器件类型:元器件基本上为插针式,个别降压芯片会使用贴片式。
2、仿真图展示
3、原理图展示
软件版本:AD2013
电路连线方式:网络标号连线方式
注意:原理图只是画出了模块的引脚图,而并不是模块的内部结构图
4、PCB图展示
由原理图导出,中间有一个项目编号,隐藏在单片机底座下,插入单片机后不会看到。
两层板,上下覆铜接地。
四、系统框图
绘制软件:VISIO
本设计以单片机为核心控制器,加上其他模块一起组成此次设计的整个系统,其中包括中控部分、输入部分和输出部分。中控部分采用了单片机控制器,其主要作用是获取输入部分的数据,经过内部处理,逻辑判断,最终控制输出部分。输入由四部分组成,第一部分是超声波测距模块,通过该模块检测当前环境的温度值、读取水位距离值;第二部分是防水温度检测模块,通过该模块检测当前水温,第三部分是按键模块,通过该模块可以切换界面、设置阈值启停或直接结束清洗等;第四部分是供电模块,通过该模块可给整个系统进行供电。输出由三部分组成,第一部分是显示模块,通过该模块可以显示监测的数据以及设置的阈值,显示洗碗机当前状,第二部分是继电器模块,通过六个继电器分别控制加热和制冷;第三部分是声光报警模块,当监测值不在设置的阈值内时进行声光报警。具体系统框图如图3.1所示。
五、部分程序展示
软件版本:keil5
注意:逻辑程序和驱动程序分开,分布于main.c和其他.c文件
*******处理函数
*****/
void Manage_function(void)
{
if(flag_display == 0)
{
if(flag_begin == 1) //洗碗机开始
{
switch(flag_step)
{
case 0: //步骤0:第一次加水
if(distance_value > distance_min)
{
RELAY_JS = 0;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
else
{
flag_step = 1;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 1: //步骤1:加洗涤剂
flag_timer_begin = 1;
if(time_all > (time_rinse*2 + time_disinfect))
{
if(flag_timer_begin == 1) //倒计时开始,每1秒总时间-1
{
if(flag_1m == 1)
{
flag_1m = 0;
if(time_all != 0)
time_all--;
}
}
RELAY_JS = 1;
RELAY_JXD = 0;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
else
{
time_all = time_rinse*2 + time_disinfect + time_xidi; //总时间=清洗时间*2+消毒时间+洗涤剂时间
flag_timer_begin = 0;
flag_1m = 0;
flag_step = 2;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 2: //步骤2:第一次加热
if(temp_value < temp_max*10)
{
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 0;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
else
{
flag_step = 3;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 3: //步骤3:第一次清洗
flag_timer_begin = 1;
if(time_all > (time_rinse*1 + time_disinfect + time_xidi))
{
if(flag_timer_begin == 1) //倒计时开始,每1分钟总时间-1
{
if(flag_1m == 1)
{
flag_1m = 0;
if(time_all != 0)
time_all--;
}
}
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 0;
RELAY_PS = 1;
RELAY_XD = 1;
}
else
{
time_all = time_rinse*2 + time_disinfect + time_xidi; //总时间=清洗时间*2+消毒时间+洗涤剂时间
flag_timer_begin = 0;
flag_1m = 0;
flag_step = 4;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 4: //步骤4:第一次排水
if(distance_value < distance_max)
{
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 0;
RELAY_XD = 1;
}
else
{
flag_step = 5;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 5: //步骤3:第二次加水
if(distance_value > distance_min)
{
RELAY_JS = 0;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
else
{
flag_step = 6;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 6: //步骤6:第二次清洗
flag_timer_begin = 1;
if(time_all > time_rinse*1 + time_disinfect + time_xidi)
{
if(flag_timer_begin == 1) //倒计时开始,每1分钟总时间-1
{
if(flag_1m == 1)
{
flag_1m = 0;
if(time_all != 0)
time_all--;
}
}
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 0;
RELAY_PS = 1;
RELAY_XD = 1;
}
else
{
time_all = time_rinse*2 + time_disinfect + time_xidi; //总时间=清洗时间*2+消毒时间+洗涤剂时间
flag_timer_begin = 0;
flag_1m = 0;
flag_step = 7;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 7: //步骤7:第二次排水
if(distance_value < distance_max)
{
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 0;
RELAY_XD = 1;
}
else
{
flag_step = 8;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 8: //步骤8:第二次加热
if(temp_value < temp_max*10)
{
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 0;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
else
{
flag_step = 9;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 9: //步骤9:消毒
flag_timer_begin = 1;
if(time_all > time_rinse*2 + time_xidi)
{
if(flag_timer_begin == 1) //倒计时开始,每1分钟总时间-1
{
if(flag_1m == 1)
{
flag_1m = 0;
if(time_all != 0)
time_all--;
}
}
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 0;
}
else
{
time_all = time_rinse*2 + time_disinfect + time_xidi; //总时间=清洗时间*2+消毒时间+洗涤剂时间
flag_timer_begin = 0;
flag_1m = 0;
flag_step = 10;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
break;
case 10: //步骤10:结束清洗,蜂鸣器响三下,等待
while(BEEP_num<6)
{
BEEP = ~BEEP;
Delay_function(500); //延时50ms
BEEP_num++;
}
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
time_all =time_rinse*2 + time_disinfect + time_xidi; //总时间=加水时间*2+加热时间*2+清洗时间*2+排水时间*2+消毒时间+洗涤剂时间
flag_begin = 0;
BEEP_num=0;
break;
default:
break;
}
}
else
{
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
flag_timer_begin = 0;
}
}
else
{
flag_begin = 0;
LED = 1;
BEEP = 1;
RELAY_JS = 1;
RELAY_JXD = 1;
RELAY_JR = 1;
RELAY_QX = 1;
RELAY_PS = 1;
RELAY_XD = 1;
}
}