+ Post New Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 20 of 42
  1. #1
    Junior Member level 3
    Points: 524, Level: 4

    Join Date
    Jun 2014
    Posts
    26
    Helped
    0 / 0
    Points
    524
    Level
    4

    LCD and pic not comunication

    Hy i have a problem and and don't uderstand why is not work.i connect a pic 16f628A on LCD 16x2 1602A,I use microK to write the code and pickit3 to send code on pic.After i upload the code on PIC the LCD just stay open,the message not apear on it.What i can do?The code is below:
    Please i need help!

    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
    
    sbit LCD_RS at RA0_bit;
     sbit LCD_EN at RA1_bit;
     sbit LCD_D4 at RB4_bit;
     sbit LCD_D5 at RB5_bit;
     sbit LCD_D6 at RB6_bit;
     sbit LCD_D7 at RB7_bit;
     sbit LCD_RS_Direction at TRISA0_bit;
     sbit LCD_EN_Direction at TRISA1_bit;
     sbit LCD_D4_Direction at TRISB4_bit;
     sbit LCD_D5_Direction at TRISB5_bit;
     sbit LCD_D6_Direction at TRISB6_bit;
     sbit LCD_D7_Direction at TRISB7_bit;
    // End LCD module connection definition
    // Define Messages
     char message1[] = "Welcome to";
     char message2[] = "My world";
     void main() {
      //ANSEL = 0b00000000; //All I/O pins are configured as digital
      CMCON = 0x07 ; // Disbale comparators
      TRISB = 0b00000000; // PORTC All Outputs
      TRISA = 0b00000000; // PORTA All Outputs, Except RA3
      Lcd_Init();                      // Initialize LCD
      do {
       Lcd_Cmd(_LCD_CLEAR);             // CLEAR display
       Lcd_Cmd(_LCD_CURSOR_OFF);        // Cursor off
       Lcd_Out(1,4,message1);            // Write message1 in 1st row
       Lcd_Out(2,1,message2);           // Write message2 in 2nd row
       Delay_ms(1000);                       // Wait for 1 sec
       Lcd_Cmd(_LCD_CLEAR);     // Clear display
       Delay_ms(1000); // Wait for 1 sec
      } while(1);             // Infinite Loop
     }
    Last edited by andre_teprom; 2nd December 2016 at 11:02. Reason: added syntax formatting

  2. #2
    Super Moderator
    Points: 28,512, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,476
    Helped
    1078 / 1078
    Points
    28,512
    Level
    41
    Blog Entries
    6

    Re: LCD and pic not comunication

    Do you mean, it is not working on simulation, or real world ?
    Where is the schematic, are you sure proper connections were made ?
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  3. #3
    Super Moderator
    Points: 76,769, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,552
    Helped
    4186 / 4186
    Points
    76,769
    Level
    67

    Re: LCD and pic not comunication

    The code looks reasonable assuming LCD_init() does actually initialize it.
    Are you seeing anything at all on the LCD and if not, do you have the bias control (aka "contrast") pin connected ?

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisment

        
       

  4. #4
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    126 / 126
    Points
    5,417
    Level
    17

    Re: LCD and pic not comunication

    I know why it is not working. He either doesn't have a Crystal Oscillator or if he has one say 4 MHz then in project settings it is set to HS instead of XT.



  5. #5
    Super Moderator
    Points: 76,769, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,552
    Helped
    4186 / 4186
    Points
    76,769
    Level
    67

    Re: LCD and pic not comunication

    I know why it is not working. He either doesn't have a Crystal Oscillator or if he has one say 4 MHz then in project settings it is set to HS instead of XT.
    That is one of many possible reasons. Lets wait for Alberto Dan to report back before jumping to conclusions.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  6. #6
    Junior Member level 3
    Points: 524, Level: 4

    Join Date
    Jun 2014
    Posts
    26
    Helped
    0 / 0
    Points
    524
    Level
    4

    Re: LCD and pic not comunication

    I atache a schematic.The only differences from real schematic is that the LCD have an Anode who it's connect from a resistor at VDD an an Cathode connected on VSS(pin 15 and 16).In proteus simulation it's work but in real implementation it's not work.I selected on mikroc tool "XT" and "HS" and still not worked.Just stay LCD lights.I don't know what to do !I need help!Click image for larger version. 

Name:	PIC16f628A.PNG 
Views:	19 
Size:	43.5 KB 
ID:	134086



    •   AltAdvertisment

        
       

  7. #7
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    126 / 126
    Points
    5,417
    Level
    17

    Re: LCD and pic not comunication

    Try another display. Maybe display is defective.



  8. #8
    Super Moderator
    Points: 28,512, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,476
    Helped
    1078 / 1078
    Points
    28,512
    Level
    41
    Blog Entries
    6

    Re: LCD and pic not comunication

    Quote Originally Posted by Alberto Dan View Post
    In proteus simulation it's work but in real implementation it's not work.
    Are you sure that the display that you're using on "real world" has the same controller IC of the module used on simulation ? There are variants from distinct manufacturers ( Samsung, Hitashi, ... ) for which the bit banging 'protocol' varies.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  9. #9
    Junior Member level 3
    Points: 524, Level: 4

    Join Date
    Jun 2014
    Posts
    26
    Helped
    0 / 0
    Points
    524
    Level
    4

    Re: LCD and pic not comunication

    The LCD model is RG1602A by from aliexpress.Model RG1602A.link is below https://www.aliexpress.com/item/Free...1bedec06&tpp=1



  10. #10
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    126 / 126
    Points
    5,417
    Level
    17

    Re: LCD and pic not comunication

    Check (See edited to Check) if you shorted any pins of the LCD while soldering.
    Last edited by Okada; 3rd December 2016 at 09:26.



    •   AltAdvertisment

        
       

  11. #11
    Junior Member level 3
    Points: 524, Level: 4

    Join Date
    Jun 2014
    Posts
    26
    Helped
    0 / 0
    Points
    524
    Level
    4

    Re: LCD and pic not comunication

    I checked and everything it is OK :(



  12. #12
    Banned
    Points: 5,417, Level: 17

    Join Date
    Jun 2016
    Posts
    1,159
    Helped
    126 / 126
    Points
    5,417
    Level
    17

    Re: LCD and pic not comunication

    Post datasheet of LCD.

    - - - Updated - - -

    Use code from post #14 here.

    https://www.edaboard.com/thread361841.html

    Maybe your display needs a longer strobe like the OLED display mentioned in above thread.

    If it works then post hardware working pictures.



  13. #13
    Junior Member level 3
    Points: 524, Level: 4

    Join Date
    Jun 2014
    Posts
    26
    Helped
    0 / 0
    Points
    524
    Level
    4

    Re: LCD and pic not comunication

    Hy can anyone help me?Please!!I try another display,i try with another PIC and is the same.No see nothing on display,just lights :((.I don't what to do!What i'm doing wrong?Can anybode help me!!



  14. #14
    Super Moderator
    Points: 76,769, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,552
    Helped
    4186 / 4186
    Points
    76,769
    Level
    67

    Re: LCD and pic not comunication

    Start with basics.

    If you angle the LCD slightly downwards from a direct line to your eyes, then turn the contrast control from end to end, do you see a 'shadow' of the character pixels? When the control is near the ground end of the adjustment you should see 'boxes' of all the 40 pixels in each character and they should disappear as you turn the control.

    If you can't see them - either you have the LCD wired wrongly or the 'contrast' control is not working.

    If you can see them and the control works, leave it set so the pixels are at about half contrast.

    Now remove the direct connection between -MCLR and wire a 10K resistor in it's place. This will not stop the reset working but it will let you ground the -MCLR pin without shorting out the power rails. While looking at the LCD, try grounding -MCLR with a wire link and note if there is any change on the LCD. This will give some idea if the PIC and LCD are communicating. Let us know the results.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  15. #15
    Advanced Member level 4
    Points: 7,187, Level: 20

    Join Date
    Jan 2015
    Posts
    1,004
    Helped
    320 / 320
    Points
    7,187
    Level
    20

    Re: LCD and pic not comunication

    I would start even further back...
    Do you have bypass capacitors on the Vdd pin?
    Can you 'flash a LED' on the device? This will show if the programming is working, the config settings are at least 'workable' and the oscillator is at the correct frequency. (Timing can be critical in getting the LCD to intialise.)
    Can you run the code in 'debug' mode (this may require using different pins as the debugger will need RB6 and RB7)? This will also show that the oscillator is running and the code is actually executing.
    Susan



  16. #16
    Super Moderator
    Points: 28,512, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,476
    Helped
    1078 / 1078
    Points
    28,512
    Level
    41
    Blog Entries
    6

    Re: LCD and pic not comunication

    I try another display
    Another display of the same model ?
    Review post #8
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisment

        
       

  17. #17
    Junior Member level 3
    Points: 524, Level: 4

    Join Date
    Jun 2014
    Posts
    26
    Helped
    0 / 0
    Points
    524
    Level
    4

    Re: LCD and pic not comunication

    If i reset PIC from MCLR nothing happend with LCD :(.What should be happened?If i adjust the contrast of LCD i see the pixels.I make the connection from LCD to PIC like in proteus schematics directly and i check this with a multimeter continuity and averything wa OK :(

    - - - Updated - - -

    No another display with other model and the result was the same :(



  18. #18
    Super Moderator
    Points: 76,769, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,552
    Helped
    4186 / 4186
    Points
    76,769
    Level
    67

    Re: LCD and pic not comunication

    What should be happened?
    What I was checking was the delay between the PIC powering up and the LCD powering up. When the supply is turned on, the LCD internal processor takes about 0.1 second to initialize before it will accept any commands. In your schematic, the -MCLR pin was conected directly to VDD so the PIC would inmnitialize immediately. There was a danger that the PIC sent commands to the LCD before it was ready to accept them. The very first commands to the LCD are to configure it and if those are missed, the LCD will never display anything. By resetting the PIC (pulling -MCL to VSS) after the LCD has powered up you would ensure the LCD was ready to operate.

    As you are noticing, simulations make assumptions about other things being right, thats why many of us don't use them!

    It appears that the problem you have is to do with the timing of commands to the LCD rather than the commands themselves or data connections. Those LCDs have critical timing requirements but the compiler should be able to take those into account for you. I suspect therefore that you have a configuration error in the compiler settings and the PIC isn't running at all or is running at the wrong speed. Make sure the settings for the clock frequency is the same as the crystal you are using and the clock type is set to XT for a crystal less than 4MHz and HS for a crystal of 4MHz or higher. Also disable the WDT (Watchdog timer) and enable the start-up timer.

    Electrically, make sure the crystal and it's loading capacitors are close to the PIC and have short wires and ensure you have decoupling capacitors across the VSS and VDD pins, close to the PIC.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  19. #19
    Junior Member level 3
    Points: 524, Level: 4

    Join Date
    Jun 2014
    Posts
    26
    Helped
    0 / 0
    Points
    524
    Level
    4

    Re: LCD and pic not comunication

    I don't have bypass cap on the VDD.How run in the debag mode in mikroc?I try to flash a led and is OK.I try to put a bypass cap,but how can i make debag on mikroc tool?



  20. #20
    Super Moderator
    Points: 76,769, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,552
    Helped
    4186 / 4186
    Points
    76,769
    Level
    67

    Re: LCD and pic not comunication

    It probably will not work without the decoupling capacitors. Connect a 10uF and 100nF capacitor in parallel and wire then across VSS and VDD as close to the PIC pins as you can manage.

    In my opinion, MikroC debugging is next to useless. I doubt it will prove anything.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



--[[ ]]--