51 single chip microcomputer - ADC0808 - 05 - ①

Publisher:a407895356Latest update time:2015-09-30 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I have nothing to do sooner or later~~ I might as well post something simple. After all, the so-called complexity is just a bunch of simple things~~~ In essence, there is nothing complicated~[Reprint] 51 MCU - ADC0808 - 05 - ①

After all, ADC is a widely used and mature thing, and many things have been made, so I will use two or three experiments to describe this thing~

Let me first talk about the introduction of the ADC0808 A/D converter:

1. Introduction to ADC0808

An A/D converter is a circuit chip that can convert input analog voltage or current information into digital information proportional to it. An A/D converter is used to achieve the conversion from analog to digital.

ADC0808 is a typical 8-channel analog input 8-bit parallel digital output successive approximation A/D converter. The converter adopts CMOS technology and can realize time-sharing acquisition of 8 analog signals. There are 8 analog selection switches and corresponding channel address latch decoding circuits on the chip.

1) Introduction of ADC0808 chip

[Reprint] 51 MCU - ADC0808 - 05 - ①

2) ADC0808 pinout

[Reprint] 51 MCU - ADC0808 - 05 - ①

[Reprint] 51 MCU - ADC0808 - 05 - ①

3) ADC0808 workflow

[Reprint] 51 MCU - ADC0808 - 05 - ①

4) Interface with 51 MCU

[Reprint] 51 MCU - ADC0808 - 05 - ①
Basically, that's all. It's very simple, right? I think so too.[Reprint] 51 MCU - ADC0808 - 05 - ①

[Reprint] 51 MCU - ADC0808 - 05 - ①[Reprint] 51 MCU - ADC0808 - 05 - ①[Reprint] 51 MCU - ADC0808 - 05 - ①Fuck, I spent a lot of time adjusting the program for nothing, just a little error, wasted a lot of time, it's really frustrating~~~


Check out the pictures~~

[Reprint] 51 MCU - ADC0808 - 05 - ①

[Reprint] 51 MCU - ADC0808 - 05 - ①

Since modular programming will be used in the future, it will be convenient for me to call it directly in the future~~~ [Reprint] 51 MCU - ADC0808 - 05 - ①, this main function:


//------------------------------------------------------------------------------
//Realize the voltage test of the resistor by using ADC0808 as an A/D converter
//The data range of the digital tube display is 0~255
#include"reg52.h"
#include"macroandconst.h"
#include"delay.h"
#include"adc0808.h"
//------------------------------------------------------------------------------
uchar code seg_disp[4]={0x10,0x20,0x40,0x00};   //LED display control code
uchar count;           //LED display bit control
sbit   tem=P2^0;
uchar temp_0=0;
//------------------------------------------------------------------------------
//Timer initialization function
void timer_init()
{
 TMOD=0X12;           //T0 works in mode 2, T1 works in mode 1
 TH0=(256-50)/256;
 TL0=TH0;
 TH1=(65536-4000)/256;
 TL1=(65536-4000)%6;

    ET0=1;
 ET1=1;
 TR0=1;
 TR1=1;
//  PT1=1;

 EA=1; 
}
//---------------------------------------------- ----------------------------------
//main
void main()
{
 timer_init();
 while(1 )
 {
  ADC0808_init();
 }
}
//---------------------------------------- -------------------------------------
//timer0
void timer0() interrupt 1
{
 CLK= ~CLK;
 if(temp_0==100)
 {
  temp_0=0;
  tem=~tem;
  
}
//-------------------------- -------------------------------------------------- --
//timer1
void timer1() interrupt 3
{
 TH1=(65536-4000)/256;
 TL1=(65536-4000)%6;
 for(count=0;count<4;count++)
 {
  P1=seg_disp[count ]|display[count];
  delay(10);
    
  

Then comes the initialization function of ADC0808 (I won’t post some auxiliary functions, such as macro definition, software delay, pin definition, etc.):

//------------------------------------------------------------------------------
//file function of adc0808
#include "reg52.h"
#include "delay.h"
#include "macroandconst.h"
//------------------------------------------------------------------------------
sbit START=P3^0;         //conversion start signal
sbit OE=P3^1;         //output enable signal
sbit EOC=P3^2;         //conversion end status signal
sbit CLK=P3^7;         //clock signal input terminal, there is no clock circuit inside ADC0808, the required clock signal is input from the outside, usually the frequency is 500KHz
uchar get_data;         //ADC0808 converted value
uchar temp;          //used to store temporary value in the post-conversion processing of ADC0808
uchar display[3];        //store decimal value
//------------------------------------------------------------------------------
//ADC0808 startup and conversion initialization function
void ADC0808_init()
{
 START=0;           //START signal rising edge, clear all internal registers to 0
 START=1;           
 START=0;         //The falling edge of the START signal starts the A/D conversion. During the conversion process, START remains at a low level.

 while(EOC==0);        //Wait for the conversion to end

 OE=1;          // Allow the device to output the conversion result

 get_data=P0;        //P0 port connects to ADC0808, you know~~
 temp=get_data;        //temporarily store the conversion result

 OE=0;

 display[0]=get_data/100;     //Convert the result to decimal number
 display[1]=get_data0/10;
 display[2]=get_data;

Reference address:51 single chip microcomputer - ADC0808 - 05 - ①

Previous article:51 single chip microcomputer - DAC0832 - 06 - ①
Next article:Introduction to 89C51 Microcontroller Series

Recommended ReadingLatest update time:2024-11-17 13:50

Assembly language design of digital voltage meter digital tube based on 51 single chip microcomputer and ADC0808
Preface Hello everyone, the last blog post was about a digital voltmeter based on the 51 single-chip microcomputer and ADC0808, but it used C language. This chapter will talk about using assembly language to achieve voltage measurement, also using digital tube display. hardware design The MCU used in this design is
[Microcontroller]
Assembly language design of digital voltage meter digital tube based on 51 single chip microcomputer and ADC0808
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号