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
}
}
Previous article:51proteus simulation: I2C bus and EEPROM2404 reading and writing
Next article:51proteus simulation: 7-segment digital tube display decimals
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- The ripple rate R of the inductor in the switching power supply is generally recommended to be around 0.4 as the best value? Then I started to ask?
- The embedded operating systems I have come into contact with - rtx51, freertos, etc.
- Design of high-speed counter based on FPGA.pdf
- 5G Common Terms and Abbreviations
- I found a very good introductory book on 51 single-chip microcomputers and recommend it to beginners. It is suitable for self-study by novices (Wang Yun)
- Application of Bypass Capacitors in High-Speed Circuit Environment
- Design of software and hardware C delay program for MSP430
- Optical module SFF-8472 problem solving
- Develop smart devices based on ESP32 to access the smart home ecosystem HomeAssistant
- Domestic MCU