基于80c51单片机的数据采集与显示系统设计说明Word文件下载.docx
- 文档编号:14826497
- 上传时间:2022-10-25
- 格式:DOCX
- 页数:14
- 大小:135.45KB
基于80c51单片机的数据采集与显示系统设计说明Word文件下载.docx
《基于80c51单片机的数据采集与显示系统设计说明Word文件下载.docx》由会员分享,可在线阅读,更多相关《基于80c51单片机的数据采集与显示系统设计说明Word文件下载.docx(14页珍藏版)》请在冰豆网上搜索。
图四PCF8563
二、
软件设计
1、流程图见图五。
图五流程图
2程序
#include<
REG51.h>
intrins.h>
absacc.h>
#include"
VIIC_C51.h"
ZLG7290.h"
#definePCF85630xA2//定义器件地址
#defineWRADDR0x00//定义写单元首地址
#defineRDADDR0x02//定义读单元首地址
#defineucharunsignedchar
#defineuintunsignedint
#defineulongunsignedlong
#defineZLG72900x70//定义器件地址
//定义TLC549串行总线操作端口
sbitCLK=P1^0;
sbitDAT=P1^1;
sbitCS=P1^2;
//定义I2C总线控制端口
sbitSDA=P1^7;
sbitSCL=P1^6;
//显示缓冲区初始化:
DP-51PRO
unsignedchardisp_buf[8]={0,0,0,0,0,0,0,0};
//显示缓存
ucharbdataADCdata;
sbitADbit=ADCdata^0;
sbitKEY_INT=P3^2;
sbitRST=P1^0;
unsignedcharKEY;
//保存键值
/***************************************************
**函数名称:
TLC549ADC()
**函数功能:
读取上一次A/D转换的数据,启动下一次A/D转换
****************************************************/
ucharTLC549ADC(void)
{
uchari;
CLK=0;
DAT=1;
CS=0;
for(i=0;
i<
8;
i++)
{
CLK=1;
_nop_();
ADCdata<
<
=1;
ADbit=DAT;
CLK=0;
}
return(ADCdata);
}
/****************************************
delay()
硬件延时程序
**入口参数:
i
****************************************/
unsignedcharDelayNS(unsignedcharno)
{
unsignedchari,j;
//延时参数
for(;
no>
0;
no--)
for(i=0;
i<
100;
i++)
for(j=0;
j<
j++);
return0;
/*A/D数据转换处理和输出显示功能函数*/
/*******************************************
display()
处理A/D转换后的数据并输出显示
********************************************/
voiddisplay(ucharadvalue)
ulongad_disp;
ad_disp=((ulong)advalue)*500/255;
disp_buf[2]=(uchar)(ad_disp/100%10)+0x80;
disp_buf[1]=(uchar)(ad_disp/10%10);
disp_buf[0]=(uchar)(ad_disp/1%10);
disp_buf[3]=31;
disp_buf[4]=31;
disp_buf[5]=31;
disp_buf[6]=31;
disp_buf[7]=31;
ZLG7290_SendBuf(disp_buf,8);
unsignedchardisplay_time(unsignedchar*sd)
sd[0]=sd[0]&
0x7f;
//秒屏蔽保留位
sd[1]=sd[1]&
//分屏蔽保留位
sd[2]=sd[2]&
0x3f;
//时屏蔽保留位
disp_buf[0]=(sd[0]%16);
disp_buf[1]=(sd[0]/16);
disp_buf[2]=31;
disp_buf[3]=(sd[1]%16);
disp_buf[4]=(sd[1]/16);
disp_buf[6]=(sd[2]%16);
disp_buf[7]=(sd[2]/16);
ZLG7290_SendBuf(disp_buf,8);
return0;
unsignedchardisplay_date(unsignedchar*sd)
sd[0]=sd[0]&
//日屏蔽保留位
0x1f;
//月屏蔽保留位
disp_buf[0]=(sd[0]%16);
disp_buf[2]=(sd[2]%16)+0x80;
//后面加小数点
disp_buf[3]=(sd[2]/16);
disp_buf[4]=(sd[3]%16)+0x80;
disp_buf[5]=(sd[3]/16);
disp_buf[6]=0;
disp_buf[7]=2;
voidmain()
ucharad_sample;
ucharkey1_count=0,key2_count=0,key3_count=0;
unsignedcharcodetd[9]={0x00,0x12,0x00,0x15,0x12,0x13,0x05,0x01,0x11};
//定义初始化字
unsignedcharrd[7];
//定义接收缓冲区
RST=0;
DelayNS
(1);
RST=1;
ISendStr(PCF8563,WRADDR,td,0x5);
//初始化PCF8563
ISendStr(PCF8563,WRADDR+5,&
td[5],0x4);
//初始化PCF8563
ZLG7290_SendData(0X15,0X02);
disp_buf[7]=0x1f;
disp_buf[6]=0x1f;
disp_buf[5]=0x1f;
disp_buf[4]=0x1f;
disp_buf[3]=0x1f;
DelayNS(50);
IRcvStr(PCF8563,RDADDR,rd,0x7);
//读现在的时、分、秒
while
(1)
{if(KEY_INT==0)
{KEY=ZLG7290_GetKey();
if(KEY==1)//显示切换
{
key1_count++;
if(key1_count>
2)
key1_count=0;
}
if(KEY==2)//调整日期
{
key2_count++;
if(key2_count>
3)
key2_count=0;
}
if(KEY==3)//调整时间
key3_count++;
if(key3_count>
key3_count=0;
if(KEY==5)//采集电压
ad_sample=TLC549ADC();
/*修改日期*/
if(key2_count==1)//调整年
disp_buf[5]=31;
disp_buf[4]=31;
ZLG7290_SendBuf(disp_buf,8);
DelayNS
(2);
if(KEY==4)
{rd[6]++;
if((rd[6]&
0x0f)>
=0x0a)
rd[6]&
=0xf0;
rd[6]+=0x10;
}
elseif(key2_count==2)//调整月
disp_buf[3]=31;
disp_buf[2]=31;
{rd[5]++;
if((rd[5]&
rd[5]&
rd[5]+=0x10;
if(rd[5]>
=0x13)
rd[5]=0x01;
elseif(key2_count==3)//调整日
{disp_buf[1]=31;
disp_buf[0]=31;
rd[3]++;
if((rd[3]&
rd[3]&
rd[3]+=0x10;
}
if(rd[3]>
=0x32)
rd[3]=0x01;
/*修改时间*/
if(key3_count==1)//修改小时
disp_buf[6]=31;
disp_buf[7]=31;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 80 c51 单片机 数据 采集 显示 系统 设计 说明
![提示](https://static.bdocx.com/images/bang_tan.gif)