[Graduation project] 14-Single-chip-based health detector_heartbeat_temperature_blood pressure design (schematic + source code + simulation engineering + thesis)

[Graduation project] 14-Single-chip microcomputer-based health detector/heartbeat/temperature/blood pressure design (schematic + source code + simulation engineering + thesis)

mission statement

People's concern about their own health has promoted the development of health status detectors. This project designs a multifunctional health status detector with heartbeat, body temperature, and blood pressure detection.
1. Complete the design of the entire system structure and draw the system block diagram;
2. Select the main control chip and appropriate sensors to complete the heartbeat detection, temperature detection, blood pressure detection and related circuit design;
3. Complete the design of the main and subroutine flow charts ;
4. Use Protues software to carry out system simulation test on the health status detector.
Data Links
Schematic Project Files
Source Code Project Files
Simulation Project Files
Paper with low repetition rate, 26851 words

design manual

Summary

This system is mainly composed of hardware and software. The hardware part consists of the smallest system unit of STC89C51 single-chip microcomputer, temperature detection circuit unit, pressure detection unit, body temperature detection unit, alarm unit, human-computer interaction unit, power supply unit, and liquid crystal display unit. In terms of design, the hardware needs to take into account the stability of the system and reliability. The software part draws the overall flow chart of the system software, and draws each sub-control driver, and then writes the driver program to complete the design of the system program. In the design of hardware and software, we choose to design according to functional partitions, so that the design can be organized and run reliably. The system design does not make the physical object but debugs it through the simulation mode. Use the simulation software Proteus to build the system hardware circuit, debug and test. Finally, the blood pressure detection, pulse detection, and body temperature detection are completed, and the threshold can be adjusted to realize the customized alarm setting of the system to prevent false alarms.

Design framework

insert image description here

Design instructions and design documents

insert image description here

insert image description here

Paper with low repetition rate, 26851 words
insert image description here

Source code display

insert image description here

#include <reg52.h>
#include <intrins.h>
#include "adc0832.h"
#define uint		unsigned int
#define uchar		unsigned char
#define ulong		unsigned long  /* 宏定义 */
#define LCD_DATA	P0/* 定义P0口为LCD_DATA */
sbit	LCD_RS	= P2 ^ 5;
sbit	LCD_RW	= P2 ^ 6;
sbit	LCD_E	= P2 ^ 7;    /* 定义LCD控制引脚 */
sbit	Xintiao = P1 ^ 0;     /* 心率检测输入端定义 */
sbit	speaker = P2 ^ 4;     /* 蜂鸣器引脚定义 */
sbit	DQ	= P3 ^ 7;
uchar blood = 0;
voiddelay5ms(void);                                                          /* 误差 0us */
voidLCD_WriteData(ucharLCD_1602_DATA);                                      /********LCD1602数据写入***********/
voidLCD_WriteCom(ucharLCD_1602_COM);                                        /********LCD1602命令写入***********/
void lcd_1602_word( uchar Adress_Com, uchar Num_Adat, uchar *Adress_Data );     /*1602字符显示函数,变量依次为字符显示首地址,显示字符长度,所显示的字符*/
voidInitLcd();                                                                 /* 液晶初始化函数 */
void Tim_Init();
uchar	Xintiao_Change=0;  /*  */
uint	Xintiao_Jishu;
uchar	stop;
uchar	View_Data[3];
uchar	View_L[3];
uchar	View_H[3];
uchar	Xintiao_H	= 100;          /*上限 */
uchar	Xintiao_L	= 40;         /*下限 */
uint	wendu		= 0;
uchar	Key_Change;
uchar	Key_Value;                                                              /*按键键值 */
uchar	View_Con;                                                               /* 设置的位(0正常工作,1设置上限,2设置下限) */
uchar	View_Change;
uchar bloodL = 139;
uchar bloodH = 160;
uint tempL = 360;
uint tempH = 373;
/*****延时子程序*****/
void Delay_DS18B20( int num )
{
	while ( num-- )		;
}
/*****初始化DS18B20*****/
void Init_DS18B20( void )
{
	unsigned char x = 0;
	DQ = 1;                 /* DQ复位 */
	Delay_DS18B20( 8 );     /*稍做延时 */
	DQ = 0;                 /* 单片机将DQ拉低 */
	Delay_DS18B20( 80 );    /* 精确延时,大于480us */
	DQ = 1;                 /* 拉高总线 */
	Delay_DS18B20( 34 );
}
/*****读一个字节*****/
unsigned char ReadOneChar( void )
{
	unsigned char	i	= 0;
	unsigned char	dat	= 0;
	for ( i = 8; i > 0; i-- )
	{
		DQ	= 0;    /* 给脉冲信号 */
		dat	>>= 1;
		DQ	= 1;    /* 给脉冲信号 */
		if ( DQ )
			dat |= 0x80;
		Delay_DS18B20( 4 );
	}
	return(dat);
}
void WriteOneChar( unsigned char dat )
{
	unsigned char i = 0;
	for ( i = 8; i > 0; i-- )
	{
		DQ	= 0;
		DQ	= dat & 0x01;
		Delay_DS18B20( 5 );
		DQ	= 1;
		dat	>>= 1;
	}
}
/*****读取温度*****/
unsigned int ReadTemperature( void )
{
	unsigned char	a	= 0;
	unsigned char	b	= 0;
	unsigned int	t	= 0;
	float		tt	= 0;
	Init_DS18B20();
	WriteOneChar( 0xCC );           /* 跳过读序号列号的操作 */
	WriteOneChar( 0x44 );           /* 启动温度转换 */
	Init_DS18B20();
	WriteOneChar( 0xCC );           /* 跳过读序号列号的操作 */
	WriteOneChar( 0xBE );           /* 读取温度寄存器 */
	a	= ReadOneChar();        /* 读低8位 */
	b	= ReadOneChar();        /* 读高8位 */
	t	= b;
	t	<<= 8;
	t	= t | a;
	tt	= t * 0.0625;
	t	= tt * 10 + 0.5;        /* 放大10倍输出并四舍五入 */
	return(t);
}
void main()                                                     /* 主函数 */
{
	InitLcd();
	Tim_Init();
	lcd_1602_word( 0x80, 16, "Heart Rate:     " );          /* 初始化显示 */
	lcd_1602_word( 0xC0, 16, "Te:      BP:    " );          /* 显示第二行数据 */
	TR0	= 1;
	TR1	= 1;                                            /* 打开定时器 */
	while ( 1 )                                             /* 进入循环 */
	{	  
		if ( View_Con == 0 )
		{
			wendu = ReadTemperature();
			lcd_1602_word( 0xC0, 3, "Te:" );        /* 显示第二行数据 */
			if ( wendu != 0 && wendu !=850)
			{
				LCD_WriteCom( 0x80 + 0x40 + 3 );
				LCD_WriteData( wendu / 100 + 0x30 );
				LCD_WriteData( wendu % 100 / 10 + 0x30 );
				LCD_WriteData( '.' );
				LCD_WriteData( wendu % 100 % 10 + 0x30 );
				LCD_WriteData( 0xdf );
				if(wendu>350 && wendu<450) {
					if (wendu >= tempH || wendu < tempL ) /* 不在范围内报警 */
						speaker=0;                                                                            /* 蜂鸣器响 */
					else
						speaker = 1;
				}
			
			}
			lcd_1602_word( 0xC0 + 8, 4, " BP:" ); /* 显示第二行数据 */
			LCD_WriteCom( 0x80 + 0x40 + 12 );
			LCD_WriteData( blood / 100 + 0x30 );
			LCD_WriteData( blood % 100 / 10 + 0x30 );
			LCD_WriteData( blood % 100 % 10 + 0x30 );
			lcd_1602_word( 0xC0 + 15, 1, " " ); /* 显示第二行数据 */
			if (blood >= bloodH || blood < bloodL )       /* 不在范围内报警 */
				speaker=0;                          /* 蜂鸣器响 */
			else
				speaker = 1;
		}
		if ( Key_Change )            /*有按键按下并已经得出键值 */
		{
			Key_Change	= 0;          /* 将按键使能变量清零,等待下次按键按下 */
			View_Change	= 1;
			switch ( Key_Value )      /* 判断键值 */
			{
			case 1:                  /* 设置键按下 */
			{
				View_Con++;          /* 设置的位加 */
				if ( View_Con == 3 )    /* 都设置好后将此变量清零 */
					View_Con = 0;
				break;         /* 跳出,下同 */
			}
			case 2:               /* 加键按下 */
			{
				if ( View_Con == 2 )      /* 判断是设置上限 */
				{
					if ( Xintiao_H < 150 )  /*上限数值小于150 */
						Xintiao_H++;     /*上限+ */
				}
				if ( View_Con == 1 )    /* 如果是设置下限 */
				{
					if ( Xintiao_L < Xintiao_H - 1 )  /*下限值小于上限-1(下限值不能超过上限) */
						Xintiao_L++;     /*下限值加 */
				}
				break;
			}
			case 3:          /* 减键按下 */
			{
				if ( View_Con == 2 )      /* 设置上限 */
				{
					if ( Xintiao_H > Xintiao_L + 1 ) /*上限数据大于下限+1(同样上限值不能小于下限) */
						Xintiao_H--;                    /*上限数据减 */
				}
				if ( View_Con == 1 )                      /* 设置下限 */
				{
					if ( Xintiao_L > 30 )                   /*下限数据大于30时 */
						Xintiao_L--;                    /*下限数据减 */
				}
				break;
			}
			}
		}
		if ( View_Change )               /* 开始显示变量 */
		{
			View_Change = 0;          /* 变量清零 */
			if ( stop == 0 )            /* 心率正常时 */
			{
				if ( View_Data[0] == 0x30 ) /* 最高位为0时不显示 */
					View_Data[0] = ' ';
			}else   { /* 心率不正常(计数超过5000,也就是两次信号时间超过5s)不显示数据 */
				View_Data[0]	= ' ';
				View_Data[1]	= ' ';
				View_Data[2]	= ' ';
			}
			switch ( View_Con )
			{
			case 0:                         /* 正常显示 */
			{
				lcd_1602_word( 0x80, 16, "Heart Rate:     " );  /* 显示一行数据 */
				lcd_1602_word( 0x8d, 3, View_Data );     /* 第1行显示心率 */
				break;
			}
			case 1:                     /* 设置下限时显示 */
			{
				lcd_1602_word( 0x80, 16, "Heart Rate:     " );  /* 第一行显示心率 */
				lcd_1602_word( 0x8d, 3, View_Data );
				View_L[0]	= Xintiao_L / 100 + 0x30;       /* 将下限数据拆字 */
				View_L[1]	= Xintiao_L % 100 / 10 + 0x30;
				View_L[2]	= Xintiao_L % 10 + 0x30;
				if ( View_L[0] == 0x30 )         /* 最高位为0时,不显示 */
					View_L[0] = ' ';
				lcd_1602_word( 0xC0, 16, "Warning L : " );/* 第二行显示下限数据 */
				lcd_1602_word( 0xCd, 3, View_L );
				break;
			}
			case 2:  /* 设置上限时显示(同上) */
			{
				lcd_1602_word( 0x80, 16, "Heart Rate:     " );
				lcd_1602_word( 0x8d, 3, View_Data );
				View_H[0]	= Xintiao_H / 100 + 0x30;
				View_H[1]	= Xintiao_H % 100 / 10 + 0x30;
				View_H[2]	= Xintiao_H % 10 + 0x30;
				if ( View_H[0] == 0x30 )
					View_H[0] = ' ';
				lcd_1602_word( 0xC0, 16, "Warning H :     " );
				lcd_1602_word( 0xCd, 3, View_H );
				break;
			}
			}
		}
	}
}

Guess you like

Origin blog.csdn.net/qq_22592979/article/details/128108703