Two LCDs on one PIC


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762

    Default Two LCDs on one PIC

    As this has been asked several times:
    Here is an example how to connect two LCDs (or one LCD with two controllers) to the PIC.

    You need just one additional Port Bit to toggle between the two controllers.

    As only one Controller is enabled at a time
    and the LCD is initialized when the first LCDout command is issued
    you will need to reset the "INIT Flag" after the first LCD has been initialized.
    Then select the second LCD and send a "CLEAR" to initialize the second LCD.

    See PBP Manual Section 5.37

    Example:
    (assuming LCD-Select is connected to PortB.1)

    Add to the beginning of your code:

    ------------------------------
    LOW PortB.1 ' Select LCD 1
    LCDout $Fe,1 ' initialize and Clear LCD 1
    Flags=0 ' Reset "INIT-Flag"
    HIGH PortB.1 ' Select LCD 2
    LCDout $Fe,1 ' initialize and Clear LCD 2
    ------------------------------

    See the schematic:
    Attached Images Attached Images  

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Here's another example of 2 LCD's on 1 PIC

    With this method, you can send to either LCD independantly, or to both LCD's at the same time. The only additional parts required are 2 resistors.

    By taking the LCD?_Disable pins LOW, it prevents the Enable signal from getting to that particular display. So, just disable the one you don't want to send to, and it sends the data to the one you want.

    This method can have more than 2 displays attached to the same pic. The only limitation is the number of pins that are available.

    DO NOT attempt to use the R/W pin on the LCD's! The displays will be damaged when more than 1 display is enabled at the same time.

    Here's a simple program:
    Code:
    DEFINE LCD_DREG PORTB   ' LCD Data port
    DEFINE LCD_DBIT 0       ' starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB  ' LCD Register Select port
    DEFINE LCD_RSBIT 4      ' LCD Register Select bit
    DEFINE LCD_EREG PORTB   ' LCD Enable port
    DEFINE LCD_EBIT 7       ' LCD Enable bit
    DEFINE LCD_BITS 4       ' LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 4      ' Number of lines on LCD
    
    LCD1_Disable  VAR  PORTB.5
    LCD2_Disable  VAR  PORTB.6
    
    LCDOUT  $FE,1   ' Initialize both LCD's
    PAUSE   200
    
    GOSUB  USE_LCD1
    LCDOUT "This is LCD 1"
    
    GOSUB  USE_LCD2
    LCDOUT "This is LCD 2"
    
    GOSUB  USE_BothLCD
    LCDOUT $FE,$C0,"Both LCD's"
    
    END
    
    USE_LCD1:
        INPUT LCD1_Disable
        LOW   LDC2_Disable
    RETURN
    
    USE_LCD2:
        LOW   LCD1_Disable
        INPUT LDC2_Disable
    RETURN
    
    USE_BothLCD:
        INPUT LCD1_Disable
        INPUT LDC2_Disable
    RETURN
    Best regards,
       Darrel
    Attached Images Attached Images

  3. #3
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Darryl,

    have you really tried this setup?

    I think the LCD1_Disable and LCD2_Disable Pins on the PIC would have to OpenDrain to allow this to work properly.

    Setting LCDx_Disable High will set the E Input of tha attached LCD High and it will stay High, regardless of the state of the E Output of the PIC.
    So the LCD will never "see" a falling edge on E.

    regards

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You are correct. If the Disables are set HIGH it won't work.

    That's why it only gets set either LOW or INPUT (Tri-State, open-drain, etc.).

    You can see in the USE_LCD?: subroutines how they are switched.

    Regards,
       Darrel

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Sorry Darrel,

    I should have had a look at your code example before posting.

    regards
    Last edited by NavMicroSystems; - 10th August 2004 at 21:45.

  6. #6
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Two LCDs on one PIC

    Thanks for the assistance on the matter.
    Regards,
    Ambrogio
    i2w2fvo

  7. #7
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Two LCDs on one PIC

    Thanks a lot Darrel for the very simple solution to my problem: that is great !
    I have also seen that the INPUT command puts the pin to a three state condition: it is very good.
    Regards,
    Ambrogio
    IW2FVO
    North Italy

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 11:00
  2. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 22:01
  3. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14
  4. Two LCDs on one PIC
    By lester in forum FAQ - Frequently Asked Questions
    Replies: 3
    Last Post: - 22nd February 2005, 03:28
  5. how to connect 2 LCDs on a PIC
    By f1fco in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th April 2004, 18:59

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts