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

    Great. That makes it easy.

    After installing MPLAB ...

    In MCS, go to the View | Compile and Program Options | Assembler Tab

    Click the Find Manually ... button and point it to
    C:\program files\microchip\mpasm suite

    Then check the Use MPASM checkbox.

    You should be good to go.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    OOPs, one more thing to get that to compile.

    In your PBP folder, open the 16F877A.INC file, and comment out the __config line with a semicolon ;

    Now you should be good to go.


    mister_e,

    At least now I know where to go if I need some extra wire.
    Sheesh.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel. I have installed MPLAB IDE v8.00 Full Release and setup was done as mentioned.
    Now when compiled I get the MPASM window showing the process and then shows 18 errors.
    This goes by very fast and starts green and then goes red. The errors are similar to what I had before. Here are a few. I have omitted the path for each error.

    205 : Found label after column 1. (WritePort)
    205 : Illegal opcode(_Char)
    234 : Illegal opcode(_LCD_DATAUS)
    249 : Found label after column 1.(DelayUS)
    267 : Illegal opcode(LCD_COMMANDUS)

    and many more

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


    Did you find this post helpful? Yes | No

    Default

    Arrrrgh!

    Sorry to put you thru all this, it shouldn't be that hard.

    I can't really say what's happening from the errors you showed.
    I could probably see what's wrong if you could send the .LST file.

    It'll be too big to post, but you could email it to
    darrel at pbpgroup.com

    It should've worked
    <br>
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    you all must have cringed when i posted my first blinky on bread board. lol mine are true ratsnests. guess it's time to buy some neato jumpers and stop being a disgrace. sniff lol

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    mister_e,

    At least now I know where to go if I need some extra wire.
    Sheesh.
    <br>
    Have a look at the last lines of the link... About The Author.. i'm afraid
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Have a look at the last lines of the link... About The Author.. i'm afraid
    And to think I did not have to go to school to be that messy
    Dave
    Always wear safety glasses while programming.

  8. #8
    dideco's Avatar
    dideco Guest


    Did you find this post helpful? Yes | No

    Default

    A CMOS chip as a buffer (such as 4050) can be added to the parallel cable to use longer wires. Also some resistors will help to make a kind of current loop by placing 2.2-4.7 Kohms close to inputs of the LCD unit.

    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

    "Data delay time" should be longer, such as 500 microseconds or longer. This will help the commads to reach display safely. Pulse decreases because of cable capacitance and resistance (RC time constant). LCD displays can load data in its register buffers in a very short period but cannot execute it as fast as loading. Thats why command delay time is 40 times longer.

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


    Did you find this post helpful? Yes | No

    Default

    Thanks Dideco for your input, I will carry on with Darrel's method for now as I find it quite interesting and I have been at it for a while. Darrel, here is what I have found so far. I have been able to get your Hijack routines to work without any errors. I am now able to see a perfect display on long lengths of cable. I have tried 20 to 40 ft of 22 awg multi-cable and the display is perfect. I did not need to adjust any delays. I have not been able though, to get the displays to switch properly using the method you described for your 2 LCD's on one pic display method. Have a look at Display_1 and you will see the display is correct using your sample code. On Display_2 you will notice that there are problems on both displays when using the hijack routines.

    Thanks.
    Attached Images Attached Images   

  10. #10
    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

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