Maximun Cable Length for PIC to LCD


Closed Thread
Results 1 to 40 of 53

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    HI wildbilly,

    Sounds like your up to speed with me now.

    I've been bogged down all week with work, so I'm kind of glad you had problems.
    I'm sure it's not the same from your point of view.

    So anyhow, I've found that the resistors used to select each display seem to act as a filter with the extra capacitance of the ribbon. The enable line gets rounded off pretty bad.

    Fortunately, with "HighJack", we're not limited to just one Enable pin anymore.
    We can have as many as needed. And that's the next step.

    We'll use the previous "Disable" pins as the "Enable" line for each LCD. The resistors are no longer needed. Then instead of Disabling the display you don't want to write to, you'll Enable the one's you do want.

    This takes a few modifications, but it's not too bad.

    First, in the main program, change the LCD definitions to this ...
    Code:
    ;----[ Change these to match your LCD ]---------------------------------------
    LCD_DB4   VAR PORTB.0
    LCD_DB5   VAR PORTB.1
    LCD_DB6   VAR PORTB.2
    LCD_DB7   VAR PORTB.3
    LCD_RS    VAR PORTB.4
    
    LCD_E1    VAR PORTB.5
    LCD_E2    VAR PORTB.6
    LCDEN     VAR BYTE BANK0  ; Enable bits for each LCD
      LCD1EN  VAR LCDEN.0
      LCD2EN  VAR LCDEN.1
       
    LCD_Lines     CON 2     ; # of Lines on LCD,  1 or 2 (Note: use 2 for 4 lines)
    LCD_DATAUS    CON 50    ; Data delay time in us 
    LCD_COMMANDUS CON 2000  ; Command delay time in us 
    
    INCLUDE "LCD_AnyPin.pbp"  ; *** Include MUST be AFTER LCD Pin assignments ****
    
    LOW LCD_E1         ; Start with Enables OUTPUT LOW
    LOW LCD_E2
    Next, in the LCD_AnyPin file, there's a section that says "DO NOT Change anything below this line".
    Change it to this ...
    Code:
    ASM
    LCD_Port_HNIB  macro           ; Port definition for LCD High Nibble
        Vbit   LCDCDFLAG, _LCD_RS  ; Select Command/Data register
        DelayUS  2
        NOP
        Vpin   4, _LCD_DB4         ; Put the High Nibble on the bus
        Vpin   5, _LCD_DB5
        Vpin   6, _LCD_DB6
        Vpin   7, _LCD_DB7
        DelayUS  2
    
        btfsc    _LCD1EN           ; Set enable(s) High
        bsf      _LCD_E1
        btfsc    _LCD2EN
        bsf      _LCD_E2
        DelayUS  5                 ; hold for 5us
        bcf      _LCD_E1           ; Enable(s) Low - Clocks data
        bcf      _LCD_E2
      endm
    ;-----------------------    
    LCD_Port_LNIB  macro           ; Port definition for LCD Low Nibble 
        Vpin   0, _LCD_DB4         ; Put the Low Nibble on the bus
        Vpin   1, _LCD_DB5
        Vpin   2, _LCD_DB6
        Vpin   3, _LCD_DB7
        DelayUS  2
    
        btfsc    _LCD1EN           ; Set enable(s) High
        bsf      _LCD_E1
        btfsc    _LCD2EN
        bsf      _LCD_E2
        DelayUS  5                 ; hold for 5us
        bcf      _LCD_E1           ; Enable(s) Low - Clocks data
        bcf      _LCD_E2
      endm
    ENDASM
    And finally, also in the LCD_AnyPin file, change LCD_Init to this ...
    Code:
    ;----[Initialize the LCD]-------------------(DO NOT Change)-------------------
    LCD_Init:
    @   OutputPort  LCD_Port_HNIB    ; Set LCD bus to OUTPUT
        LCDEN = 1 + 2
        LOW LCD_RS                   ; Start with RS LOW
        Char = 3   : gosub  LCDsendShortCOM : @  DelayUS 6000
                     gosub  LCDsendShortCOM : @  DelayUS 1000
                     gosub  LCDsendShortCOM : @  DelayUS 1000
        Char = 2   : gosub  LCDsendShortCOM : @  DelayUS 1000  ; Start 4-bit mode
        Char = $28 : gosub  LCDsendCOM  ; Function Set, 4-bit, 2-line, 5x7
        Char = $0C : gosub  LCDsendCOM  ; Display ON
        Char = $01 : gosub  LCDsendCOM  ; Clear Screen
        Char = $06 : gosub  LCDsendCOM  ; Entry Mode
        LCD_Initialized = 1             ; LCD has been Initialized
    goto LCDAfterInit

    Click image to enlarge.

    P.S. Until now I thought that 6 inches was the limit for LCD's. Just because somebody told me that once.
    This is really cool. Thanks for the interesting things to play with.<hr>

    ADDED: Oops, forgot to show you how to use it..
    Code:
    LCDEN = 1
    LCDOUT $FE,1, "Display 1"
    
    LCDEN = 2
    LCDOUT $FE,1, "Display 2"
    
    LCDEN = 1 + 2
    LCDOUT $FE,$C0, "Both Displays"
    DT

  2. #2
    Join Date
    Nov 2005
    Location
    Ontario Canada
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel. I have it working. I just need to check it again on the long cable. The displays are flashing. How do I stop that? I suppose that is something in the "LCD_AnyPin" file.

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


    Did you find this post helpful? Yes | No

    Default

    If it's a Fast Flash?
    Are the LCDOUT statements running in a loop?

    If so, try using $FE,$80 instead of $FE,1
    <br>
    DT

  4. #4
    Join Date
    Nov 2005
    Location
    Ontario Canada
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel. That did it. I will check the long cable in the morning. Thank you for your help.

  5. #5
    Join Date
    Nov 2005
    Location
    Ontario Canada
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    I am going to try and add a third display. I will let you know how I make out. In your original sample code I had modofied it for three displays and it worked ok. I will give it a try.

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


    Did you find this post helpful? Yes | No

    Default 3 LCD's

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2185&stc=1&d=119719494 4" />
    Attached Images Attached Images  
    DT

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel!

    How long is that flat cable on the second LCD? It seems really long!

    Ioannis

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. DS1820 Max Cable length ?
    By dccch in forum General
    Replies: 2
    Last Post: - 24th January 2008, 07:44
  4. Measure cable length with a PIC?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th July 2007, 18:45
  5. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07

Members who have read this thread : 0

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