The AD receiving UART transmitting module circuit schematic and PCB diagram drawn by Altium Designer are as follows:
【A brief description】
1. Dimensions: 50mm long x 25mm wide x 10mm high
2. Main chip: ATMEGA8
3. Working voltage: DC 5V
II. Features:
1. Detection analog voltage range 0~5V
2. Digital tube display range 0~5000
3. Four-digit digital tube display
4. Simple input and output wiring
5. AD conversion frequency 125K, 8-bit data conversion
6. Baud rate: 9600, error rate: 0.156%
3. Function: Convert the analog voltage of 0~5V into a digital value of 0~5000, which is displayed by a digital tube and converted into a hexadecimal value of 0~255. It is sent by the microcontroller UART (i.e., TXD port) and can communicate directly with the computer after 232 level conversion.
AD receiving UART sending module AD conversion value display
The microcontroller source program is as follows:
#include
#include #define uchar unsigned char #define uint unsigned int /******************************************************************** Digital tube segment code definition 0123456789 *********************************************************************/ uchar Table[10]={0xc0,0Xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //Bitcode of the required segment uchar wei[4]={0X10,0X20,0X40,0X80}; //bit control end (simulation) //uchar wei[4]={0Xe0,0Xd0,0Xb0,0X70}; //bit control end (board) uint date; //define data type uchar z,x,c,v; //define data type /********************************************************************** Delay function **********************************************************************/ void DelayMs(uint i) //0.25ms {uint j; for(;i!=0;i--) {for(j=8000;j!=0;j--) {;}} } /********************************************************************** Digital tube dynamic scanning *********************************************************************/ void Pre_Display() { /***********************Data conversion********************************/ z=date/1000; //Find the thousandth place x=date%1000/100; //get the hundredth place c=date%100/10; //Find the tenth digit v=date%10; //find the unit digit PORTD=wei[0]; PORTB=Table[z]; DelayMs(1); PORTD=wei[1]; PORTB=Table[x]; DelayMs(1); PORTD=wei[2]; PORTB=Table[c]; DelayMs(1); PORTD=wei[3]; PORTB=Table[v]; DelayMs(1); } /********************************************************************** Voltage value processing function **********************************************************************/ uint ADC_Convert(void) {uint temp1,temp2; temp1=(uint)ADCL;//先读ADCL temp2=(uint)ADCH;//再读ADCH temp2=(temp2<<8)+temp1;//evaluation temp2=temp2*49/10; //Calculate the displayed voltage value (0~5.12) V if(temp2>=5000)temp2=5000; return(temp2); } /********************************************************************** Initialize I/O port **********************************************************************/ void Init_IO(void) //Initialize I/O port { DDRC=0x00; //Set port C to input without pull-up; PORTC=0x00; DDRB=0xff; //Set port B to push-pull 1 output; PORTB=0xff; DDRD=0xFF; //Set port D to push-pull 1 output; PORTD=0xFF; } /******************************************************************** Serial port initialization subroutine *********************************************************************/ void Uart_Init(void) { UCSRB = 0x00; //disable while setting baud rate UCSRA = 0x00; //Bit1 is 1, then send at double speed UCSRC = 0x86; UBRRL = 0x33; //Baud rate: 9600 Bps UBRRH = 0x00; //Error rate: 0.156% UCSRB = 0x18; } /******************************************************************** Serial port send byte subroutine *********************************************************************/ void Putchar(unsigned char c) { while (!(UCSRA&(1< } /********************************************************************** Main function **********************************************************************/ void main(void) {uint i; uint B=50; uint TXD; Init_IO(); Uart_Init(); ADMUX=0x00; //Select the first channel; /**********************The conversion rate should be between 50~200K****************************/ ADCSR=0xe6; //125K conversion rate, free conversion mode; start AD converter; DelayMs(1); //Delay until the system is stable; while(1) { B--; i=ADC_Convert(); //Display voltage value (0~1024) ……………………
Previous article:TWI interrupt mode of AVR microcontroller
Next article:AVR Timer 1 Fast PWM Mode Setting
Recommended ReadingLatest update time:2024-11-22 20:34
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Another technical solution for power-type plug-in hybrid: A brief discussion on Volvo T8 plug-in hybrid technology
- The solution of communication between single chip microcomputer and Kingview software
- Make an appointment to get a gift: Replace electricity with light, learn about silicon photonic chips~ Join the Engineer Network Academy live broadcast and win gifts
- How to make the CLK of tms320c6678 SPI output 8 clock cycles each time
- The manufacturer sent another set of oscilloscopes, and the three of them competed with each other
- What is the effect of connecting the SW pin of the switching power supply to the capacitor and resistor in series to GND?
- EEWORLD University ----TI LED Driver
- NRF24LE1 2.4g wireless RF chip introduction
- Doorbell program + circuit made by AVR microcontroller timer
- [N32L43X Review] 2.IO Operation and Delay
- Some Misunderstandings in Circuit Design