Proteus8.12 基于51单片机的家用供暖系统

        使用STC89C51单片机进行proteus仿真,包括ADC0832、LCD1602、DS18B20串口发送、单位按键等。效果如下所示。

        其中NF表示流度,AL为流量,流量大小是根据流速与时间的乘积得来的。NT为DS18B20测的实时温度,当温度小于按键设计的阈值ST时,电磁阀闭合,打开水泵并发出报警声。

        硬件框架如下:

        程序设计流程图如下:

        部分代码如下:

#include <reg52.h>
#include <stdio.h>
#include "LCD1602.h"
#include "ADC0832.h"
#include "DS18B20.h"

sbit Beep = P3^6;
sbit Motor = P3^7;

typedef unsigned char uint8_t;
typedef unsigned int uint16_t;

#define FOSC 11059200L
#define T1MS (65536-FOSC/12/1000)   //1ms timer calculation method in 12T mode
#define BAUD 9600 //UART baudrate

bit busy;

uint16_t count = 0;

uint16_t Per = 0;//设定流量
uint16_t All_Per = 0;//总流量
uint16_t Tem = 0;//当前温度
uint16_t Set_Tem = 28;//设置温度


void Init();
void Keyscan();

void main() {
    uint8_t Buff[20];
    Init();
    LCD1602_Init();
    Ds18b20Init();
    while(1) {
        Per = Get_ADC0832(0);
        Tem = Ds18b20ReadTemp();
        Keyscan();
        LCD_pos(0,0);//显示设定流量
        sprintf(Buff,"NF:%hdcfm ", (uint16_t)Per);
        LCD_Str(Buff);
        LCD_pos(1,0);//显示设定温度
        sprintf(Buff,"ST:%hd%cC ", (uint16_t)Set_Tem, 0xdf);
        LCD_Str(Buff);
        LCD_pos(0,10);//显示总的流量
        sprintf(Buff,"AF:%hdL  ", (uint16_t)All_Per/1000);
        LCD_Str(Buff);
        LCD_pos(1,8);//显示当前温度
        sprintf(Buff,"NT:%hd%cC ", (uint16_t)Tem/100, 0xdf);
        LCD_Str(Buff);
        
        if(Tem/100 > Set_Tem) {
            Beep = 0;
            Motor = 0;
        }
        else {
            Beep = 1;
            Motor = 1;
        }
    }
}

/* Timer0 interrupt routine */
void tm0_isr() interrupt 1
{
    TL0 = T1MS;                     //reload timer0 low byte
    TH0 = T1MS >> 8;                //reload timer0 high byte
    if (count-- == 0)               //1ms * 1000 -> 1s
    {
        count = 1000;               //reset counter
        All_Per += Per;
    }
}

/*----------------------------
UART interrupt service routine
----------------------------*/
void Uart_Isr() interrupt 4
{
    if (RI)
    {
        RI = 0;             //Clear receive interrupt flag
        Set_Tem = SBUF;          //P0 show UART data
    }
    if (TI)
    {
        TI = 0;             //Clear transmit interrupt flag
        busy = 0;           //Clear transmit busy flag
    }
}

void Init() {
    
    //定时器0
    TMOD = 0x01;                    //set timer0 as mode1 (16-bit)
    TL0 = T1MS;                     //initial timer0 low byte
    TH0 = T1MS >> 8;                //initial timer0 high byte
    TR0 = 1;                        //timer0 start running
    ET0 = 1;                        //enable timer0 interrupt
    EA = 1;                         //open global interrupt switch
    
    //串口
    SCON = 0x50;            //8-bit variable UART
    TMOD = 0x20;            //Set Timer1 as 8-bit auto reload mode
    TH1 = TL1 = -(FOSC/12/32/BAUD); //Set auto-reload vaule
    TR1 = 1;                //Timer1 start run
    ES = 1;                 //Enable UART interrupt
    EA = 1;  
}

void Keyscan() {
    P1 = 0x07;
    if((P1&0x07) != 0x07) {
        switch(P1&0x07) {
            case 0x06:Set_Tem++;
                break;
            case 0x05:if(Set_Tem != 0)Set_Tem--;
                break;
        }
    }while((P1&0x07) != 0x07);
}

 文件下载链接:

基于51单片机的家用集中供暖系统 - 细胞盘-付费下载平台 内容支付后下载可见 文件付费网盘 (xibaopan.com)https://www.xibaopan.com/i/MW71e3dbe1Vhg

文件内资源:

  • 4
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值