+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Newbie level 4
    Points: 904, Level: 6

    Join Date
    Aug 2013
    Posts
    5
    Helped
    0 / 0
    Points
    904
    Level
    6

    Woking with internal ADC of PIC16f877a

    Can any one help me on this. I am working on voltmeter using the adc of pic6f877a with lcd , my code works perfect on proteus but when i implement it, it won't respond fine. At times it display, at times it don't. Pls i need help.

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 1
    Points: 2,880, Level: 12

    Join Date
    Feb 2013
    Location
    Chennai,India
    Posts
    421
    Helped
    38 / 38
    Points
    2,880
    Level
    12

    Re: Woking with internal ADC of PIC16f877a

    Check the delay for display LCD, the delay might be low or high in your code. In proteus delay not a problem. What you seen in the display.



  3. #3
    Advanced Member level 3
    Points: 5,481, Level: 17

    Join Date
    Apr 2011
    Posts
    926
    Helped
    184 / 184
    Points
    5,481
    Level
    17

    Re: Woking with internal ADC of PIC16f877a

    Quote Originally Posted by IKPE80 View Post
    Can any one help me on this. I am working on voltmeter using the adc of pic6f877a with lcd , my code works perfect on proteus but when i implement it, it won't respond fine. At times it display, at times it don't. Pls i need help.
    No one can help you better with out your code and hardware connection.Post the code and circuit.
    Please marked the thread solved if your problem is answered it will take few seconds of you but saves lot of time for others to get answers for same problems..



  4. #4
    Newbie level 4
    Points: 904, Level: 6

    Join Date
    Aug 2013
    Posts
    5
    Helped
    0 / 0
    Points
    904
    Level
    6

    Re: Woking with internal ADC of PIC16f877a

    Quote Originally Posted by ud23 View Post
    No one can help you better with out your code and hardware connection.Post the code and circuit.
    I am using mickroC compiler so my code and the proteus design are below

    Code:
                                  // LCD module connections
    sbit LCD_RS at RB4_bit;
    sbit LCD_EN at RB5_bit;
    sbit LCD_D4 at RB0_bit;
    sbit LCD_D5 at RB1_bit;
    sbit LCD_D6 at RB2_bit;
    sbit LCD_D7 at RB3_bit;
    
    sbit LCD_RS_Direction at TRISB4_bit;
    sbit LCD_EN_Direction at TRISB5_bit;
    sbit LCD_D4_Direction at TRISB0_bit;
    sbit LCD_D5_Direction at TRISB1_bit;
    sbit LCD_D6_Direction at TRISB2_bit;
    sbit LCD_D7_Direction at TRISB3_bit;
    // End LCD module connections
    //char look(int a);
    void main()
    {
    
      int v;
      char volt[5];
      ADC_INIT();
      Lcd_Init();
      Lcd_Cmd(_LCD_CLEAR);
      Lcd_Cmd(_LCD_CURSOR_OFF);
    
      do
      {
           v = ADC_Read(2);
           v = v*0.2246;
    
           IntToStr(v,volt);
           LTrim(volt);
           Lcd_Out(1,1,"Voltage = ");
           Lcd_Out(1,11,volt);
           Lcd_Out(1,16,"V");
      } while(1);
    
    }
    Click image for larger version. 

Name:	Proteus_design.PNG 
Views:	12 
Size:	38.6 KB 
ID:	114348
    Click image for larger version. 

Name:	Proteus_design.PNG 
Views:	12 
Size:	38.6 KB 
ID:	114348



    •   AltAdvertisement

        
       

  5. #5
    Newbie level 4
    Points: 904, Level: 6

    Join Date
    Aug 2013
    Posts
    5
    Helped
    0 / 0
    Points
    904
    Level
    6

    Re: Woking with internal ADC of PIC16f877a

    Quote Originally Posted by amayilsamy View Post
    Check the delay for display LCD, the delay might be low or high in your code. In proteus delay not a problem. What you seen in the display.
    Pls I am using MickroC compiler how do i check the LCD delay of their library because I am using their own library not my own function for LCD.



  6. #6
    Advanced Member level 3
    Points: 5,481, Level: 17

    Join Date
    Apr 2011
    Posts
    926
    Helped
    184 / 184
    Points
    5,481
    Level
    17

    Re: Woking with internal ADC of PIC16f877a

    if you have same connections in real hardware as you posted in the simulation then you need some pot at pin 3 for contrast and VCC for pin 2in the real hardware.

    What is your real hardware output you getting?
    Please marked the thread solved if your problem is answered it will take few seconds of you but saves lot of time for others to get answers for same problems..



  7. #7
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Woking with internal ADC of PIC16f877a

    Fixed code.

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    
    sbit LCD_RS at RB4_bit;
    sbit LCD_EN at RB5_bit;
    sbit LCD_D4 at RB0_bit;
    sbit LCD_D5 at RB1_bit;
    sbit LCD_D6 at RB2_bit;
    sbit LCD_D7 at RB3_bit;
     
    sbit LCD_RS_Direction at TRISB4_bit;
    sbit LCD_EN_Direction at TRISB5_bit;
    sbit LCD_D4_Direction at TRISB0_bit;
    sbit LCD_D5_Direction at TRISB1_bit;
    sbit LCD_D6_Direction at TRISB2_bit;
    sbit LCD_D7_Direction at TRISB3_bit;
     
    int v;
    char volt[17];
     
    void main() {
     
      CMCON = 0x07;
      ADCON0 = 0x40;
      ADCON1 = 0b10000010;
      CVRCON = 0x00;
     
      TRISA = 0x02;
      PORTA = 0x00;
     
      Lcd_Init();
      Lcd_Cmd(_LCD_CURSOR_OFF);
      Lcd_Cmd(_LCD_CLEAR);
      Lcd_Out(1,1,"Voltage = "); 
     
      do {
           v = ADC_Read(2) * 0.2246;       
           IntToStr(v, volt);
           LTrim(volt);       
           Lcd_Out(1,11,volt);
           Lcd_Out(1,16,"V");
      } while(1);
    }


    1 members found this post helpful.

  8. #8
    Newbie level 4
    Points: 904, Level: 6

    Join Date
    Aug 2013
    Posts
    5
    Helped
    0 / 0
    Points
    904
    Level
    6

    Re: Woking with internal ADC of PIC16f877a

    Quote Originally Posted by milan.rajik View Post
    Fixed code.

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    
    sbit LCD_RS at RB4_bit;
    sbit LCD_EN at RB5_bit;
    sbit LCD_D4 at RB0_bit;
    sbit LCD_D5 at RB1_bit;
    sbit LCD_D6 at RB2_bit;
    sbit LCD_D7 at RB3_bit;
     
    sbit LCD_RS_Direction at TRISB4_bit;
    sbit LCD_EN_Direction at TRISB5_bit;
    sbit LCD_D4_Direction at TRISB0_bit;
    sbit LCD_D5_Direction at TRISB1_bit;
    sbit LCD_D6_Direction at TRISB2_bit;
    sbit LCD_D7_Direction at TRISB3_bit;
     
    int v;
    char volt[17];
     
    void main() {
     
      CMCON = 0x07;
      ADCON0 = 0x40;
      ADCON1 = 0b10000010;
      CVRCON = 0x00;
     
      TRISA = 0x02;
      PORTA = 0x00;
     
      Lcd_Init();
      Lcd_Cmd(_LCD_CURSOR_OFF);
      Lcd_Cmd(_LCD_CLEAR);
      Lcd_Out(1,1,"Voltage = "); 
     
      do {
           v = ADC_Read(2) * 0.2246;       
           IntToStr(v, volt);
           LTrim(volt);       
           Lcd_Out(1,11,volt);
           Lcd_Out(1,16,"V");
      } while(1);
    }
    Thanks, the fixed code worked, but i have to change the TRISA = 0x02 to TRISA = 0xff. Please what does CMCON and CVRCON mean?



  9. #9
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: Woking with internal ADC of PIC16f877a

    CMCON = Comparator Control
    CVRCON = Comparator Voltage Reference Control


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  10. #10
    Newbie level 4
    Points: 904, Level: 6

    Join Date
    Aug 2013
    Posts
    5
    Helped
    0 / 0
    Points
    904
    Level
    6

    Re: Woking with internal ADC of PIC16f877a

    Quote Originally Posted by milan.rajik View Post
    CMCON = Comparator Control
    CVRCON = Comparator Voltage Reference Control
    Thank you very much.



--[[ ]]--