51proteus simulation: adc0804 realizes analog-to-digital conversion

Publisher:素心静听Latest update time:2017-01-10 Source: eefocusKeywords:adc0804 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The signals collected by the system are almost all analog signals. It is necessary to learn the analog-to-digital AD conversion of the microcontroller.

This simulation uses adc0804 to convert analog voltage into digital signal, and then output it to the digital tube.

Since the maximum voltage does not exceed 5v, the digital tube only displays the units digit and the digits after the decimal point. I only display 3 digits after the decimal point without rounding.

Simulation circuit diagram:

 

c program:

 

#include
#include

#define uchar unsigned char

#define uint unsigned int

sbit duan=P3^0; //u1
sbit wei=P3^1;

sbit ADC_CS=P3^2;
sbit ADC_RD=P3^3;
sbit ADC_WR=P3^4;

uchar code table[]={
0x3f,0x06,0x5b,0x4f,
 0x66,0x6d,0x7d,0x07,
 0x7f,0x6f,0x77,0x7c,
 0x39,0x5e,0x79,0x71 };

void delay(uint xms)
{
  uint i,j;
  for(i=xms;i>0;i--)
  for(j=80;j>0;j--);
 }
 
void show6led(float num)
{
unsigned char i;

  P2=0xff;
 P3=0xff;
 i=num;
 duan=1;
 P2=table[i]+0x80; //Display units and decimal point
 duan=0;
 P2=0xff; //Turn off led first 
 wei=1;
 P2=0xfb; //Segment selection 3
 wei=0;
 delay(5);
 
  P2=0xff;
 P3=0xff;
 num=num-i;
 num=num*10;
 i=num;
 duan=1;
 P2=table[i];
 duan=0;
  P2=0xff;
  wei=1;
 P2=0xf7; //Segment selection 4, tenths
 wei=0;
 delay(5);
   P2=0xff;
 P3=0xff;
 num=num-i;
 num=num*10;
 i=num;
 duan=1;
 P2=table[i];
 duan=0;
 P2=0xff;
 wei=1;
 P2=0xef; //Segment selection 5, percentile
 wei=0;
 delay(5);

  P2=0xff;
 P3=0xff;
 num=num-i;
 num=num*10;
 i=num;
 duan=1;
 P2=table[i];
 duan=0;
 P2=0xff;
 wei=1;
 P2=0xdf; //Segment selection 6, thousandths
 wei=0;
 delay(5);
  
  
 }

 

void main()
{

uchar val;

 ADC_CS=0;

 
  ADC_WR=1;
  _nop_();
  ADC_WR=0;
  _nop_();
  ADC_WR=1;
  delay(50);
  P1=0xff;
  ADC_RD=1;
 _nop_();
  ADC_RD=0;
  _nop_();
   val=P1;
   ADC_RD =1;
   
  while(1)
  {
   show6led(val*0.02);//adc0832 is 8 bits, 5v/256=0.02v
  
   }


 }


Keywords:adc0804 Reference address:51proteus simulation: adc0804 realizes analog-to-digital conversion

Previous article:51proteus simulation: I2C bus and EEPROM2404 reading and writing
Next article:51proteus simulation: 7-segment digital tube display decimals

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号