MCU AD receiving UART sending module circuit diagram PCB and vb host computer source code

Publisher:温馨生活Latest update time:2019-11-07 Source: 51heiKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The AD receiving UART transmitting module circuit schematic and PCB diagram drawn by Altium Designer are as follows:
0.png0.png

【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

image016.jpg

image017.png 

image014.jpgimage012.jpgimage004.jpgimage010.jpg 

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<   UDR=c;

    }

    /**********************************************************************

                                                                    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)

           

    ……………………


    Keywords:MCU Reference address:MCU AD receiving UART sending module circuit diagram PCB and vb host computer source code

    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

    AVR single chip passive infrared alarm experiment
    The alarm consists of an infrared transmitter, receiver, buzzer and LED indicator. Under normal circumstances, the green LED flashes constantly, indicating that the monitored area is normal. Once someone breaks into the monitored area, the green LED goes out, the red LED flashes quickly, and the buzzer sounds an ala
    [Industrial Control]
    AVR single chip passive infrared alarm experiment
    What is a microcontroller? How should we learn about it?
    1. What can you do by learning MCU?  MCU is widely used. You can see MCU everywhere, such as remote control cars, washing machines, refrigerators, color TVs, and air conditioners. After learning MCU, you can play small productions that you like, or you can design some small products with MCU. The most important thin
    [Microcontroller]
    STM32 MCU Learning (8) Program Encryption
    There are two ways to encrypt STM32 programs 1. Prohibit reading Flash memory contents 2. Use ID encryption program   u8 Sys_ID ,i; for(i=0;i 12;i++) { Sys_ID =*(u8*)(0x1FFFF7E8+i); //Product unique identification register (96 bits) printf(" %0.2X",Sys_ID ); //Refer to the other two articles Serial port int
    [Microcontroller]
    ARM and 51 MCU communication
    The hardware is a mini2440 core board and another MCU learning board with a serial port (with DS18B20). The learning board continuously outputs the temperature value of DS18B20 with a baud rate of 19200. Create a new file in a folder, mine is voltage_set.c (to be used for voltage adjustment later)   #include stdio
    [Microcontroller]
    Using the interrupt structure, compile a pulse counting 8051 microcontroller program
    Connect an external pulse signal to the INTO pin of the 8051 microcontroller. It is required that each time a pulse is sent, the value of the 30H unit is increased by 1. If the 30H unit is full, the 31H unit is carried forward. Try to use the interrupt structure to compile a pulse counting program. Solution: ORG 0000H
    [Microcontroller]
    Programming Skills of EH78 Series MCU
    The author used the EM78P447 chip in the development of a smart water meter, and gained a deeper understanding of the EM78 series chips. In practice, he summarized some issues that should be paid attention to when developing such chips, and also gave programming tips in the application. The common reference book
    [Industrial Control]
    Programming Skills of EH78 Series MCU
    Features and Applications of Configurable Analog Microcontroller PIC16C781/782
    1 Overview The PIC series 8-bit microcontrollers launched by MICROCHIP in the United States are the first cost-effective embedded controllers in the industry to adopt RISC structure. Their high speed, high reliability, low operating voltage, low power consumption, large driving capability, low-cost OTP technolo
    [Microcontroller]
    Features and Applications of Configurable Analog Microcontroller PIC16C781/782
    Control design of AT89C52 microcontroller BH1415F FM station
    BH1415F FM console control C program uses keilC51 through debugging //Use AT89C52 microcontroller, 12MHz crystal oscillator, and common anode four-digit LED digital tube //P0 port outputs segment code, P2 port scans //#pragmaSRC(d:aa.asm) #include“reg52.h” #include "intrins.h" //_nop_(); for delay function #defineDi
    [Microcontroller]
    Control design of AT89C52 microcontroller BH1415F FM station
    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号