+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Newbie level 3
    Points: 23, Level: 1

    Join Date
    Jul 2017
    Posts
    3
    Helped
    0 / 0
    Points
    23
    Level
    1

    [Moved]: Volt Meter with PIC 16F877A

    Dear All,

    Good day,

    I am trying to make a test board in order to make a voltmeter with PIC 16F877A. Iam using a JDM Programmer in order to program pic and MIcro C Pro in order to make my hex file. Regret without results. This is the code i am trying to use without result.

    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
    
    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 Adread;
    float voltage;
    char volt[4];
    void main() {
     
    PORTA = 0;
    TRISA = 0X01;
    PORTB = 0;
    TRISB = 0;
    LCD_Init();
    ADC_Init();
    LCD_Cmd(_LCD_CURSOR_OFF);
    LCD_Cmd(_LCD_CLEAR);
    LCD_Out(1, 1, "Stamatis P");
    delay_ms(1000);
    while (1)
    {
    voltage = ADC_Read(0);
    voltage = (voltage * 5 * 10)/ (1024);
    inttostr(voltage,volt); // it converts integer value into string
    Lcd_Out(2,1,"Voltage = ");
    Lcd_Out(2,11,Ltrim(volt));
    Lcd_Out(2,13,"Volt");
    }
    }

    There is no problem with my programmer because i have tried with other hex files and projects. I am using also an oscillator 8 MHz at 13-14 pins with 22pf.

    Your assistance is much appreciate on this matter.

    Many thanks,
    Stamatis
    Last edited by andre_teprom; 5th July 2017 at 23:21. Reason: added SYNTAX tags

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 29,631, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,861
    Helped
    1114 / 1114
    Points
    29,631
    Level
    41
    Blog Entries
    9

    Re: Volt Meter with PIC 16F877A

    Regret without results. This is the code i am trying to use without result.
    You did not specify what exactly is or is not working. Isn't there anything being shown at display ? Is something shown at display, but with wrong result ?
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  3. #3
    Newbie level 3
    Points: 23, Level: 1

    Join Date
    Jul 2017
    Posts
    3
    Helped
    0 / 0
    Points
    23
    Level
    1

    Re: Volt Meter with PIC 16F877A

    Dear Andre,

    Thank you for your reply. There is nothing on my display at my LCD (16X2).

    Many thanks and Best Regards,



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 77,731, Level: 67
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,750
    Helped
    3587 / 3587
    Points
    77,731
    Level
    67

    Re: Volt Meter with PIC 16F877A

    Hi,

    If you don´t see "Stamatis P" on your display, then there is a basic issue.
    Hardware error, power supply error, code error, microcontroller doesn´t run at all, code is not loaded in the microcontroller...

    Klaus



  5. #5
    Newbie level 3
    Points: 23, Level: 1

    Join Date
    Jul 2017
    Posts
    3
    Helped
    0 / 0
    Points
    23
    Level
    1

    Re: Volt Meter with PIC 16F877A

    Dear Claus,

    Thank you for your prompt reply. I have tested the code (.hex file) at Proteus simulation Program and working satisfactory. Also, i have loaded another hex on the same PIC and also works properly (to another project i have made some months before). LCD tested to another board and working also satisfactory. Because its my first time that i am using Micro C, could you please if there is any error at my code?

    Many thanks and Best Regards,



--[[ ]]--