[Experimental requirements]
The analog quantity between 0 and 5V is input from the analog channel of ADC0804, converted into digital quantity by ADC0804 and sent to the microcontroller. After being processed by the microcontroller, it is displayed in decimal on the digital tube.
[Purpose of the experiment]
Learn how to use a single-chip microcomputer to control the ADC0804 chip for digital-to-analog conversion, and master the principle of dynamic scanning display of digital tubes.
Dynamic scanning: Take the six-digit digital tube displaying 123456 as an example: first let the first digital tube display 1, and the rest are all dark. 1 is on for a few milliseconds and then goes out. Then immediately let the second digital tube display 2, and the rest are all dark. 2 is also on for a few milliseconds. This is how the sixth digital tube is lit, and then it comes back to display 1. This cycle continues at a very fast speed. Since the visual retention time of the human eye is about 20 milliseconds, it is not possible to feel that there are dark digital tubes. What we see is that six digital tubes are displaying the value of 123456 at the same time. If we slow down this process a little bit, we will see that the first digital tube displays 1, then moves to the second and then displays 2... That is to say, only one digital tube is lit at any time. This is the principle of dynamic scanning display of digital tubes.
ADC0804: ADC0804 is an 8-bit full MOS medium-speed A/D converter. It is a successive approximation A/D converter with a three-state data output latch on the chip, which can be directly interfaced with a single-chip microcomputer. Single-channel input, the conversion time is about 100us. The conversion timing of ADC0804 is: when CS=0, A/D conversion is allowed. When WR changes from low to high, A/D starts to convert, and a total of 66-73 clock cycles are required for one conversion. When CS and WR are valid at the same time, A/D conversion is started, and the INTR signal (low level is valid) is generated at the end of the conversion, which can be used for query or interrupt signal. The data results can be read under the control of CS and RD. The INTR signal is not used in this experiment.
[Hardware Circuit]
[source code]
//Twist the potentiometer next to AD, and the first three digits of the digital tube will display a value between 0 and 255. This is the conversion of analog signals into digital signals, i.e. analog-to-digital conversion.
#include
#include
#define uint unsigned int
#define uchar unsigned char
sbit adrd=P3^7; //IO port definition
sbit adwr=P3^6;
sbit diola=P2^5;
sbit dula=P2^6;
sbit wela=P2^7;
unsigned char j,k,adval;
void delay(unsigned char i) //delay program
{
for(j=i;j>0;j--)
for(k=125;k>0;k--);
}
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, //digital tube code
0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void display(uchar bai_c,uchar sh_c,uchar g_c) //display program
{
P0=table[bai_c]; //Display hundreds
dula=1;
dula=0;
P0=0xfe;
wela=1;
wela=0;
delay(5);
dula=0;
P0=table[sh_c]; //Display tens digit
dula=1;
dula=0;
wela=0;
P0=0xfd;
wela=1;
wela=0;
delay(5);
P0=table[g_c]; //Display the units digit
dula=1;
dula=0;
P0=0xfb;
wela=1;
wela=0;
delay(5);
}
void main() // Main program
{
uchar a,A1,A2,A2t,A3;
while(1)
{
wela=1;
P0=0; //Enable ADCS
adwr=0; //AD write (you can write anything, mainly to start AD conversion)
_nop_();
adwr=1;
P0=0xff; //turn off ADCS
delay(10);
wela=0; //Close the latch end of the AD chip select signal latch to prevent the AD chip select from changing when operating the digital tube
for(a=20;a>0;a--) //It should be noted that the time interval between writing and reading ADC0804 must be long enough, otherwise the data cannot be read out
{ //The reason for putting the display part here is to increase the time interval between writing and reading
display(A1,A2,A3);
} //Send to display to everyone.
wela=1; //Reopen the latch end with AD chip select signal latch
P1=0xff; //Write the full value before reading P1
P0=0; //Enable ADCS
adrd=0; //AD read enable
adval=P1; //AD data read and assigned to P1 port
adrd=1;
P0=0xff; //turn off ADCS
adwr=0;
P1=adval; //Send the AD value to eight LEDs for display at the same time
A1=adval/100; //separate hundreds, tens, and ones
A2t=adval%100;
A2=A2t/10;
A3=A2t%10;
};
}
Previous article:Overvoltage output protection circuit
Next article:Application of voltage divider model in analog circuit
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Jihai APM32E103VET6S MINI Development Board Review] Second post PLL and system clock questions
- Ink screen calendar based on AB32 and RT-Thread, open source
- Transistor common emitter amplifier circuit
- Square wave generator for msp430 microcontroller
- [RISC-V] Domestic IDE MRS V1.50+JLink! GD32VF103 development practice
- 28335 Clock, peripheral and register configuration
- The problem of too small spacing between chip leads in AD
- ARM+DSP+IPU heterogeneous multi-core processors communicate between cores through IPC components
- What is overshoot? How to solve the problem of overshoot in high-speed circuit signals
- "Operational Amplifier Parameter Analysis and LTspice Application Simulation" 3. Chapter 2 Phase Margin