标题:
Proteus仿真使用52单片机与ad0808进行ADC采集与显示
[打印本页]
作者:
_Zenith_
时间:
2020-4-15 17:02
标题:
Proteus仿真使用52单片机与ad0808进行ADC采集与显示
如题,附件自取
KZECC7JM@B_@%HZ})%5JI[7.png
(118.37 KB, 下载次数: 51)
下载附件
2020-4-15 17:01 上传
单片机源程序如下:
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define p0 P0
#define p3 P3
sbit en=P1^0;
sbit rs=P1^2;
sbit rw=P1^1;
sbit adda=P1^3;
sbit addb=P1^4;
sbit addc=P1^5;
sbit ale=P1^6;/*选择通道*/
sbit start=P1^7;/*上升ad沿复位,下降沿ad开始转换模数*/
sbit eoc=P3^0; /*为1时就可以取数据了(硬件自己干的)*/
sbit oe=P3^1; /*为0 ad输出高阻态,为1 ad向单片机输数据(你要做的)*/
uint vm0;
uchar v,v_2,v_1,v_0;
char cont[]={'0','1','2','3','4','5','6','7','8','9'};
void init();
void init2();
void delay(uint z);
void delay1(uint m);
void write_com(uchar com);
void write_data(uchar date);
void LCD_set_xy( unsigned char x, unsigned char y );
void LCD_write_char(unsigned char X,unsigned char Y,unsigned char data1)
{
LCD_set_xy( X, Y );
write_data( data1);
}
void LCD_set_xy( unsigned char x, unsigned char y )
{
unsigned char address;
if (y == 0) address = 0x80 + x;
else address = 0xc0 + x;
write_com( address);
}
void write_string(unsigned char X,unsigned char Y,unsigned char *s)
{
LCD_set_xy( X, Y );
while (*s)
{
write_data( *s );
s ++;
}
}
void main()
{
init();
init2();
delay(100);
while(1)
{
start=0;
start=1;
oe=0;
start=0;
while(eoc==1);
oe=1;
v=p0;
oe=0;
if(v>50)
{
vm0=((uint)v*196)/100;
}
else
{
vm0=(uint)v*2;
}
v_2=(vm0/100)%10;
v_1=(vm0%100)/10;
v_0=vm0%10;
write_string(0,0,"U:");
LCD_write_char(2,0,v_2+'0');
LCD_write_char(3,0,'.');
LCD_write_char(4,0,v_1+'0');
LCD_write_char(5,0,v_0+'0');
write_string(6,0,"v");
}
}
void init()
{
en=0;
rw=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void init2()
{
adda=0;
addb=0;
addc=0;
ale=0;
delay(10);
ale=1;
delay(10);
ale=0;
}
void delay(uint z)
{
uchar x,y;
for (x=z;x>0;x--)
for (y=10;y>0;y--);
}
void write_com(uchar com)
{
rs=0;
……………………
…………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
adc0808简单的实验(用lcd1602显示电压)有仿真和程序.rar
(41.13 KB, 下载次数: 75)
2020-4-15 17:01 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
westdog
时间:
2020-5-14 09:12
附件中的ad.dsn文件用proteus 8打不开呢
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1