Maximun Cable Length for PIC to LCD


Closed Thread
Results 1 to 40 of 53

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,175


    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

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


    Did you find this post helpful? Yes | No

    Default

    25 Ft.

    I think wildbilly's going to run it at 40 Ft.
    <br>
    DT

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,175


    Did you find this post helpful? Yes | No

    Default

    That's impressive! About 8,5 meters! Lets see what wildbilly will do on the 40ft.
    Great code Darrel.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Smile

    Merry Christmas to all and a happy new year. Hi Darrel. I have not been able to do much since you gave me the "Hex". Remember those two fingers? OK, seriously your code works flawlessly. I have been able to run both LCD's on 40ft of cable. Thanks very much for your time and code. I learned a lot this year from this forum, thanks to all especially Darrel.
    Hopefully much more projects in the new year.

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


    Did you find this post helpful? Yes | No

    Default

    That's Great wildbilly.
    And Happy New Year to you too.

    I was hoping it would go the 40ft. but wasn't sure.

    Don't want to ruin it for you if you're still trying to do 3 LCD's, but I can show you how, if you give up.

    regards,
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel. I would like to know how to do 3 LCD's. I won't turn down a chance of learning more. Thanks

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


    Did you find this post helpful? Yes | No

    Default

    OK, let's go with the learning ... idea ...

    Here's the changes to add 1 more display to what we already have.
    Mostly, it's just "more of the same".

    These are the same 3 sections that were modified the last time.
    New changes are in red ...

    Main Program
    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
    LCD_E3    VAR PORTD.0   
    
    LCDEN     VAR BYTE BANK0  ; Enable bits for each LCD
      LCD1EN  VAR LCDEN.0
      LCD2EN  VAR LCDEN.1
      LCD3EN  VAR LCDEN.2
    
    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
    LOW LCD_E3
    LCD_AnyPin.pbp
    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
        btfsc    _LCD3EN
        bsf      _LCD_E3
        DelayUS  5                 ; hold for 5us
        bcf      _LCD_E1           ; Enable(s) Low - Clocks data
        bcf      _LCD_E2
        bcf      _LCD_E3
      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
        btfsc    _LCD3EN
        bsf      _LCD_E3
        DelayUS  5                 ; hold for 5us
        bcf      _LCD_E1           ; Enable(s) Low - Clocks data
        bcf      _LCD_E2
        bcf      _LCD_E3
      endm
    ENDASM

    LCD_AnyPin.pbp
    Code:
    ;----[Initialize the LCD]-------------------(DO NOT Change)-------------------
    LCD_Init:
    @   OutputPort  LCD_Port_HNIB    ; Set LCD bus to OUTPUT
        LCDEN = %111                 ; Initialize all LCD's at the same time
        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
    And then, to use it.
    It still works the same as before.
    But now it's easier to treat the Enable bits like a binary number.
    With each bit representing a different display ...
    Code:
        LCDEN = %001
        LCDOUT $FE,$80, "Display 1"
        
        LCDEN = %010
        LCDOUT $FE,$80, "Display 2"
    
        LCDEN = %100
        LCDOUT $FE,$80, "Display 3"
        
        LCDEN = %111
        LCDOUT $FE,$C0, "ALL Displays"
    And that should be it.<hr>
    Now, Even though this all works fine ...
    I don't like it.

    After making all the changes to get 3 LCD's to work.
    It's still limited to 3 LCD's.
    If you want 4, then you have to go modify it again.
    Then if you want to use 2 LCD's on another project. It'll throw a bunch of errors, that won't make sense 6 months from now.

    Then there's the Timing options.
    What if the cable is longer? Or shorter? How do you adjust the delays?

    So what I've done, is create a new module that should incorporate everything learned here, and allow everyone to have up to 8 LCD's on long or short cables without to much hassle.

    But it takes longer to post the thread, than it does to write the program.
    And I Gotta work tomorrow too.

    Feel free to use the code I just posted (it should work)
    Or you may want to wait for my next post in the PBP Extensions forum. (day or two)<hr>
    P.S. It's unfortunate that we still won't know the answer to your first question.
    Quote Originally Posted by wildbilly
    What is the maximum cable length of cable that can be used between Pic and LCD?
    Uhhh, 40 ft, as far as we can say.
    But who knows?
    <br>
    DT

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, 20:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 17:56
  3. DS1820 Max Cable length ?
    By dccch in forum General
    Replies: 2
    Last Post: - 24th January 2008, 08:44
  4. Measure cable length with a PIC?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th July 2007, 19:45
  5. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 27th June 2007, 00: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