EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / Send multiple analog signals with UART PIC16f877A

Send multiple analog signals with UART PIC16f877A

|

Microcontroller › PIC › Send multiple analog signals with UART PIC16f877A

  • This topic has 0 replies, 1 voice, and was last updated 6 years, 8 months ago by Raed.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • November 29, 2015 at 11:53 pm #4134
    Raed
    Participant

    Hi

    i am trying to get 2 analog signal from 2 sensors and send the data to a PC through a USB to UART bridge ….the code works with one analog signal but when i get it to 2 signals ,,,it doesnet work …. the 2 analog signals read the same signal some how …

    can anyone help me? ,, thanx

     

    unsigned int analogValX;
    unsigned int analogValY;
    char x[4];
    char y[4];
    void main()
    {
          CMCON = 7 ;
          TRISA = 0XFF;
          ADCON1 = 0XC0;
          ADCON0 = 0X41;

         // TRISB = 0X00;
          //TRISD = 0X00;

          UART1_Init(9600);

         while (1)
         {
           ADCON0=0x41;

           delay_us(50);
           ADCON0.B2 = 1;
           while (ADCON0.B2);

           analogValX = ((unsigned int) ADRESH << 8)|ADRESL;
           IntToStr(analogValX,x);                                     // Read A0

           ADCON0=0x59;
           delay_us(50);
           ADCON0.B2 = 1;
           while(ADCON0.B2);

           analogValY = ((unsigned int) ADRESH << 8)|ADRESL;
           IntToStr(analogValY,y);                                     //Read A1

           UART1_Write_Text("AnalogX = ");
           UART1_Write_Text(x);
           UART1_Write_Text("$     ");
           UART1_Write_Text("AnalogY = ");
           UART1_Write_Text(y);
           UART1_Write_Text("$");
           UART1_Write(13);

           strcpy(x,"");
           strcpy(y,"");

           //PORTB = ADRESL;
           //PORTD = ADRESH;
         }
    }

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • 2nd pcb design program? August 10, 2022
  • My NE555 chips gone bad August 10, 2022
  • Nokia 5110 HW in Oshonsoft August 10, 2022
  • alternate of 80386/486 microprocessor August 10, 2022
  • Drill speed controller fault August 10, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools