基于51单片机及MAX6675的8通道测温系统 protues仿真

硬件设计

链接:https://pan.baidu.com/s/1OKhXA_rhCJotATu8nzzxLQ
提取码:qcmg

仿真图:
在这里插入图片描述

代码设计

主程序:

#include <reg52.h>
#include "lcd.h"
#include "disp_temp.h"
#include "read_temp.h"

bit up_temp = 0;

void InitTimer0(void)
{
    TMOD = 0x01;
    TH0 = 0x0B1;
    TL0 = 0x0E0;
    EA = 1;
    ET0 = 1;
    TR0 = 1;
}

main()
{
		uint tem_buf, temp[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
		uchar i;
		InitLcd1602();
		InitTimer0();

		while(1)
		{
				if(up_temp)
				{
						EA = 0;
						up_temp = 0;
						for(i=0; i<8; i++)
						{
								tem_buf = read_tem(i);
								if(tem_buf!=temp[i])
								{
										temp[i] = tem_buf;				
										dis_tem(i, temp[i]);
								}
						    EA = 1;
				     }
				}
		}
}

void Timer0Interrupt(void) interrupt 1
{
		static uchar count = 0;
    TH0 = 0x0B1;
    TL0 = 0x0E0;
		
		if(count >=100)
		{
			 count = 0;
			 up_temp = 1;
		}
		else
			 count++;
}

显示部分:

#include "lcd.h"
void Read_Busy()           //忙检测函数,判断bit7是0,允许执行;1禁止
{
    unsigned char sta;      //
    LCD1602_DB = 0xff;
    LCD1602_RS = 0;
    LCD1602_RW = 1;
    do
    {
        LCD1602_EN = 1;
        sta = LCD1602_DB;
        LCD1602_EN = 0;    //使能,用完就拉低,释放总线
    }while(sta & 0x80);
}

void Write_Cmd(unsigned char cmd)     //写命令
{
    Read_Busy();
    LCD1602_RS = 0;
    LCD1602_RW = 0;
    LCD1602_DB = cmd;
    LCD1602_EN = 1;
    LCD1602_EN = 0;    
}

void Write_Data(unsigned char dat)   //写数据
{
      Read_Busy();
      LCD1602_RS = 1;
      LCD1602_RW = 0;
      LCD1602_DB = dat;
      LCD1602_EN = 1;
      LCD1602_EN = 0;
}


void InitLcd1602()              //1602初始化
{
    Write_Cmd(0x38);    //打开,5*8,8位数据
    Write_Cmd(0x0c);
    Write_Cmd(0x06);
    Write_Cmd(0x01);    //清屏   
}

.

.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值