Maximun Cable Length for PIC to LCD


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 53
  1. #1
    Join Date
    Nov 2005
    Location
    Ontario Canada
    Posts
    30

    Default Maximun Cable Length for PIC to LCD

    Hello all, I have just finished a project which includes displaying on three LCD displays. Thanks to a great method by Darrel Taylor. http://www.pbpgroup.com/files/2_LCDs.gif
    His idea works fantastic. What is the maximum cable length of cable that can be used between Pic and LCD? I have all the three LCD working close to the PIC but 20 feet away I get gibberish. Am I just stuck with a shorter length of cable or is there a work a around.

    Thanks.

  2. #2
    Join Date
    Oct 2007
    Location
    Vancouver, BC, Canada
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    i guess max around 2feet for TTL level. if you require longer length i suggest using serial lcd.

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


    Did you find this post helpful? Yes | No

    Default

    wildbilly,

    Great, glad that's working for you.

    I can't answer the main question, as I've never tried to go more than a couple inches to an LCD.
    But, I'll agree that serial might be a better way.

    However, I think there's two possible sources for the garbled text. And I might be able to do something about one of them if you still want the parallel interface.
    1. PBP sends everything out to the LCD at the MINIMUM pulse widths defined in the HD44780 datasheet. Which means approximately 1 Mhz squarewave signals since the enable pulse only lasts 1 uS. That's going to be tuff to get through 20 feet of ribbon cable.
      <br>
    2. The other source could be inductive pick-up, like an antenna.
      Can't help much if that's the case.

    If the problem is #1? It may be possible to slow down the LCD data to a point that will propagate thru the long ribbon.

    Using the technique described in the LCD_Anypin thread, we could create whatever timing is required to slow it down to a reasonable speed.

    If you want to try, let me know.
    You'll have to do the testing though.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Thank you KVLV. I think you are correct about using serial instead. It would be nice though to be able to use the parallel interface. I do enjoy a challenge and it keeps PicBasic interesting.
    Thanks Darrel, I have read the LCD_Anypin thread and that is very interesting. I am up for the leg work. I am willing to try and I will do all the testing required.

    Thank you.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    ....
    2. PBP sends everything out to the LCD at the MINIMUM pulse widths defined in the HD44780 datasheet. Which means approximately 1 Mhz squarewave signals since the enable pulse only lasts 1 uS. That's going to be tuff to get through 20 feet of ribbon cable.

    ....
    Well in this case, I would suggest to use double the number of flat cable wires and the middle ones connected to the ground point. It won't eliminate the problem but will help for sure.

    Ioannis
    Last edited by Ioannis; - 28th November 2007 at 20:19.

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


    Did you find this post helpful? Yes | No

    Default

    at very least, if you really want to waste that amount of cable, place some cap close of the LCD VDD/GND (47uF (or greater) + 10 uF tantalum and finally 0.1 uF ceramic)

    I don't think there's a real problem with the length of cable so far, my feeling is that you just need to filter the Vdd rail properly at the end and probably play with COMMANDUS & DATAUS DEFINEs.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wildbilly View Post
    I am up for the leg work. I am willing to try and I will do all the testing required.
    Shouldn't take much, but you'll need to install the HighJack routines first.
    And you'll also be using the LCD_Anypin files, so download them too.

    Start with that, and you should be able to get the LCD working on a Short cable first.

    After that, we'll adjust the delays and see what happens on a long one.
    If you have any problems getting LCD_Anypin to work, let me know.
    <br>
    DT

  8. #8
    w7ami's Avatar
    w7ami Guest


    Did you find this post helpful? Yes | No

    Default Maximun Cable Length for PIC to LCD

    wildbilly,

    It should be possible to send data over 20 feet to your display and have it work, but not using ribbon cable. All the conductors are parallel to each other and divided by insulation. In other words you have a bunch of capacitve coupling between the lines. Also the ribbon cable is likely not shielded so any manner of garbage will be picked up from the nearby environment. I have an absolute encoder (10 lines of TTL data) working over a distance of 50 feet in a high RF environment.

    First as stated earlier make sure you have cleaned up the power to the LCD with good bypass capacitors with short lead length. You will need to put the displays in some sort of metal box. Then use a shielded cable with twisted pairs (signal and ground on each pair) between the two units. Then if you are still having problems mess with the pulse widths.

    Terry

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


    Did you find this post helpful? Yes | No

    Default

    Hello all. As W7AMI suggested, I have tried filtering the supply and I have changed the cable to shielded pairs but no luck. Darrel I have installed the Highjack routines and also included the LCD_Anypin.pbp and VirtualPort.bas in the PBP folder. I then added the Include file in my main program just below the define Parameters.

    INCLUDE "LCD_AnyPin.pbp"
    I am using MicroCode Studio and when compile is run I get the error
    Line 87:Bad expression. (LCD-AnyPin.pbp)
    The LCD_AnyPin file is opened and the line LOW LCD_RS : HIGH LCD_E is highlighted causing the error. I have included two images. The green Display is connected on the short cable and the Blue Display is connected to the long cable. As you can see blue is not displaying what the green is and the character on the blue display is constantly changing.
    Attached Images Attached Images   

  10. #10
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I think the problem is that it is just plain too cold where you live!
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    That's a good laugh. I thought someone would have that reply.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wildbilly
    Darrel I have installed the Highjack routines and also included the LCD_Anypin.pbp and VirtualPort.bas in the PBP folder. I then added the Include file in my main program just below the define Parameters.
    Excellent!

    Does your main program have this section (modified for your hardware of course).
    The old lcd DEFINES can be commented out.
    Code:
    ;----[ Change these to match your LCD ]---------------------------------------
    </i></b></font><b>LCD_DB4   </b><font color="#008000"><b>VAR </b></font><b>PORTA</b>.<font color="#800000"><b>0
    </b></font><b>LCD_DB5   </b><font color="#008000"><b>VAR </b></font><b>PORTB</b>.<font color="#800000"><b>3
    </b></font><b>LCD_DB6   </b><font color="#008000"><b>VAR </b></font><b>PORTB</b>.<font color="#800000"><b>7
    </b></font><b>LCD_DB7   </b><font color="#008000"><b>VAR </b></font><b>PORTC</b>.<font color="#800000"><b>1
    </b></font><b>LCD_RS    </b><font color="#008000"><b>VAR </b></font><b>PORTD</b>.<font color="#800000"><b>4
    </b></font><b>LCD_E     </b><font color="#008000"><b>VAR </b></font><b>PORTA</b>.<font color="#800000"><b>1
    </b></font><b>LCD_Lines     </b><font color="#008000"><b>CON </b></font><font color="#800000"><b>2    </b></font><font color="#0000FF"><b><i>' # of Lines on LCD,  1 or 2 (Note: use 2 for 4 lines)
    </i></b></font><b>LCD_DATAUS    </b><font color="#008000"><b>CON </b></font><font color="#800000"><b>50   </b></font><font color="#0000FF"><b><i>' Data delay time in us 
    </i></b></font><b>LCD_COMMANDUS </b><font color="#008000"><b>CON </b></font><font color="#800000"><b>2000 </b></font><font color="#0000FF"><b><i>' Command delay time in us 
    
    </i></b></font><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;LCD_AnyPin.pbp&quot;  </font><font color="#0000FF"><b><i>; *** Include MUST be AFTER LCD Pin assignments ****</i></b></font>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel. I added the list below and no longer have the error but no longer have a display on
    the LCD. I only have two black bars.

    '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_E VAR PORTB.7

    The list below works fine.

    'LCD Parameters
    '============
    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
    DEFINE LCD_COMMANDUS 2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us

    My LCD is connected just like your example " http://www.pbpgroup.com/files/2_LCDs.gif

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


    Did you find this post helpful? Yes | No

    Default

    Bummer,

    OK, let me re-create it here.
    Back at ya soon.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    OK,

    Just to make sure, I went thru the steps again myself.
    Have it working here on a 16F88. One thing I had to add that wasn't mentioned here, although it was in the other thread ...
    Code:
    PAUSE 500 : LCDOUT $FE,1 : PAUSE 250 ; Initialize LCD (You may not need this,
                                         ;  but some displays are picky)
    But so that I can compare Apples to Apples, What PIC are you using?

    I bought 25ft of ribbon today, just to make sure. But haven't hooked it up yet.
    DT

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


    Did you find this post helpful? Yes | No

    Default

    I added the code
    PAUSE 500 : LCDOUT $FE,1 : PAUSE 250 ; Initialize LCD
    with the same result. I am using the 16F877a

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


    Did you find this post helpful? Yes | No

    Default

    Apples it is ..

    Built a 16F877A breadboard. With LCD on the above mentioned ports.
    Still haven't hooked up the ribbon yet, just wanted 1 LCD at this point.

    Here's the Breadboard.

    Click image to enlarge

    And here's the program it's running.
    Code:
    @  __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF
    
    ADCON1 = 7
    CMCON = 7
    
    DEFINE OSC 4
    
    ;----[ 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_E     VAR PORTB.7
    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 ****
    
    PAUSE 500 : LCDOUT $FE,1 : PAUSE 250 ; Initialize LCD (You may not need this,
                                         ;  but some displays are picky)
    
    LCDOUT $FE,1,"Hello wildbilly",$FE,$C0,"Must be something",$FE,$94,"In the Hardware"
    
    Main:
    ;    toggle LED
        pause 1000
    goto Main
    Can you see anything I've done different??
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Your apple must be the Macintosh because yours is working and mine is not.
    Ok, here is what I have found. I have loaded your code to a new main program and could not compile it. I am getting this error: "opcode expected instead of '_config' "
    for this line @ __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF

    and I get these errors for this line : INCLUDE "LCD_AnyPin.pbp"
    "opcode expected instead of 'writeport' "
    "opcode expected instead of 'delayus' "
    "opcode expected instead of 'outputport' "

    I have checked the Hijack code included in the PBPPIC14.lib file and I think it was modified correctly. Any clues?

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    I am getting this error: "opcode expected instead of '_config'
    Ah Ha, You aren't using MPASM as the assembler.

    Almost anything written with ASM mixed in the program, needs to be compiled with MPASM. The assembler that comes with PBP is OK for PBP itself, but it just doesn't have the capabilities needed for ASM, even though sometimes it will compile OK.

    Here's a hex file for mine if you want to try it.
    If yours isn't runnung at 4Mhz, I'll change it to your crystal.
    <br>
    Attached Files Attached Files
    DT

  20. #20
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Apples it is ..

    Built a 16F877A breadboard. With LCD on the above mentioned ports.
    Still haven't hooked up the ribbon yet, just wanted 1 LCD at this point.
    <br>
    I can't add anything more on Darrels suggestions, but have to admit that the breadboard is very tidy good looking! An art in breadboarding!

    The background that seems like a pcb, what is it?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Thanks for noticing Ioannis,

    The first breadboard I ever bought came with a box of 3M pre-cut jumpers.
    I just thought that's the way it's supposed to be done.

    Thanks to my "Glowing Eyed Monsters",
    I also learned to trim the leads off of the parts so they sit flat on the breadboard.
    There's another breadboard of mine in that thread too. Same style.

    I never knew how bad a breadboard could be till I ran across this ...
    http://cs.nyu.edu/~jhan/ledtouch/
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Yeah! He is indeed very neat. I am inspired to do the same. The background looks like a chair seat. Darrel your wildbilly.hex file ran ok. I have never used MPASM. I should try and get it going.

    Thank you.

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


    Did you find this post helpful? Yes | No

    Default

    The background looks like a chair seat.
    DING! Give that man a cigar.
    I forgot to answer it. oops.

    I have never used MPASM. I should try and get it going
    Just go here... at the bottom of the page, install the MPLAB IDE v8.00 Full Release Zipped Installation
    http://www.microchip.com/stellent/id...&part=SW007002

    Are you using MicroCode Studio for the IDE?
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    one of the less neat prototype i've never ever saw ...
    http://www.botmag.com/articles/bionic_stamp.shtml

    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel. I am using Microcode Studio.

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

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

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

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

  30. #30


    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

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

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

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

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

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

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

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

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

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

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

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 : 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