LCD cable length?


Closed Thread
Results 1 to 28 of 28
  1. #1
    Join Date
    Aug 2003
    Posts
    985

    Default LCD cable length?

    Hi,
    Just wondering if anyone has tried wiring an LCD (4 bit interface) remotely from the microcontroller, and how long the ribbon cable can be?
    I know I could try this, but someone might have done it and could save me the hassle.
    I want a ribbon cable from the back of my 4wd to the front of the vehicle.
    Cheers, Art.

  2. #2
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    I have done it with a cat5 wire about 10' and had no problems.
    Shawn

  3. #3
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    Here's Darrel with 25 feet of ribbon cable connected to his: http://www.picbasic.co.uk/forum/show...7417#post47417

    Edit: Wildbilly ran it with 40 feet. A few posts later.
    Last edited by ScaleRobotics; - 16th January 2012 at 01:54.
    http://www.scalerobotics.com

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    Thanks guys
    Didn't want to do the wiring, but should have at least searched!

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    It's a VFD display with the standard LCD controller.



    It's working with one metre of cable, but a bit hit & miss.
    No garbled text, but sometimes it doesn't come on at all.
    Maybe it just needed a longer startup time than the usual PAUSE 1000.
    Ideally, I want about five metres of cable length, so I'll keep reading!

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


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    In the thread where we ran them on 25/40ft cables, the LCDOUT library routines were over-ridden so the timing could be changed.

    Normally, the LCDOUT command gives a 1uS pulse on the enable line.
    But as the cable gets longer, 1uS isn't enough.
    I used 5uS for the 25 ft length, which seemed to overcome the rounding off of the waveform on a scope.

    You might try using the routines from that thread with the modified timing.
    Essentially, it's the LCD_AnyPin routines with a few modifications.
    DT

  7. #7
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    Will do, thanks
    I think I'll have to.

  8. #8
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    A little problem...
    Installed the hijack routines and the two files in PBP directory.
    When I use the include file for lcdanypin, I get an error (using MPASM)
    for line 87 which is this line:
    LOW LCD_RS : HIGH LCD_E

    If I comment that out I then get a lot of errors

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


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    LCD_RS and LCD_E should be declared in your program, along with the other LCD pins.
    Something like ...
    Code:
    ;----[ Change these to match your LCD ]--------------------------------------- 
    LCD_DB4    VAR PORTA.0 
    LCD_DB5    VAR PORTB.3 
    LCD_DB6    VAR PORTB.7 
    LCD_DB7    VAR PORTC.1 
    LCD_RS     VAR PORTD.4 
    LCD_E      VAR PORTA.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 ****
    
    DT

  10. #10
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    Oops!

  11. #11
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length? > 40 feet.

    Bah! Still not having much luck here,
    I have the LCD routines working, and changed the LCD_anypin file as follows:
    Code:
    ;===============( DO NOT Change anything below this line )====================
    ;----[Virtual LCD Port --- 4bit mode]-----------------------------------------
    ASM
    LCD_Port_HNIB  macro           ; Port definition for LCD High Nibble
        Vbit   LCDCDFLAG, _LCD_RS  ; Select Command/Data register
        Vpin   4, _LCD_DB4         ; Put the High Nibble on the bus
        Vpin   5, _LCD_DB5
        Vpin   6, _LCD_DB6
        Vpin   7, _LCD_DB7
        PulseLow  _LCD_E, 5        ; pulse the Enable Pin for 2 us
      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
        PulseLow  _LCD_E, 5        ; pulse the Enable Pin for 2 us
      endm
    ENDASM
    Since I'm only using a single display, hopefully that's all that is needed to enable the E pin for 5us.
    Still the display coming on at all after startup is hit & miss.
    It seems to come on straight after programming with the pickit2 (when powered by the pickit2,
    but doesn't want to come on when powered by any other means (or even by the pickit2 when not being programmed).

  12. #12
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Seems the problem is hardware Darrel!

    I wanted the pic to be able to switch on & off power to the LCD, so I used a BD649 transistor to switch the ground pin of the LCD display.

    The base is connected via 2.2K resistor to a spare pic pin, collector to the LCD ground, and emitter connected to the circuit ground.
    Then the idea was to set the pic pin connected to base high, and then wait the "PAUSE 1000" delay time for the LCD to be ready each time I used it.
    If I now short the emitter and collector of the BD649 while powering up, the display works every time (with LCD_anypin).

    I can then release the short between the transistor pins, and the display stays on! What's happening there?

    It's probably become obvious it's for a car circuit.
    The idea is to have the LCD (VFD) powered only when the car is started, but the pic circuit should be running all the time.

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


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Maybe ...

    If the data/RS/E pins are not tri-stated while the power to the VFD is OFF, it could be trying to power it from those pins.
    Then when the transistor turns on, it doesn't activate the power-on reset in the display.

    When programming with the PICkit, those pins will always tri-state during programming.

    Just turning off the transistor without tri-stating all the pins first may not be enough.
    Then remember to clear the FLAGS variable, so PBP will re-initialize the display.
    DT

  14. #14
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Probably not your problem, but I spent several hours trying to figure out why my one project would work fine after programming (using USB with a bootloader to program) but after a power cycle it wouldn't work. Program it again and it worked fine until I would do a power cycle again. Turns out when I programmed the bootloader into the PIC I had the extended instruction set enabled. Just a thought.
    Shawn

  15. #15
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Being the self-educated hack-git that I am, I don't know what either of those suggestions actually are.
    BUT, being the self-educated hack-git that I am I figured out you can:
    Defeat the 24hr Wikipedia blackout by hitting Ctrl-A followed by Ctrl-C
    quickly before the blackout screen appears, then you can paste the entire page to Windows Notepad!


    I tried to find out what tri state means... Do I need to use transistors to isolate all of the LCD control pins?
    How do you reset the FLAGS var? it is an internal asm variable yes?
    Will that ruin my program during execution if my own flags have critical states?

    @ spcw1234, I'm not using a bootloader, just plain vanilla PBP hex loaded straight to the pic.

  16. #16
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Disable java scripting on your browser to use Wikipedia.

    http://meta.wikimedia.org/wiki/Engli...ad_blackout.3F
    Shawn

  17. #17
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    It "Appears" I've had some luck by inserting this code:
    Code:
    @   OutputPort  LCD_Port_HNIB    ; Set LCD bus to OUTPUT
        LOW LCD_RS
        HIGH LCD_E
        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
    after turning the transistor on.

    This maybe just rubbish... I'll have to try to get the pic to turn the LCD off and back on again to be sure of anything.

  18. #18
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Ok, that IS working, I can use the pic to cycle the power to the VFD display ie. turn off, wait three secs,
    turn on again and print. I will try to follow any other suggestions to clean it up.

    Maybe the LCD controller is recieving power from other lines to keep it running... not sure.

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


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    That initialization code is already in the LCD_AnyPin file.

    To invoke it, simply use this after turning it on.
    Code:
    FLAGS = 0
    That tells PBP that the LCD hasn't been initialized yet, and it will do so on the next LCDOUT.
    DT

  20. #20
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Seems you can ignore the last few posts.. I had the transistor shorted the whole time I was supposed to be turning it on & off!

  21. #21
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    A quick thought - rather than try to run ribbon cable around a vehicle, where noise will certainly be an issue, why not simply put a small PIC co-located with the display to communicate with your main device using an (RS232ish) serial link and display it on your display? You only need to run a single wire (or 3 wires if you also want to include power for the device) and it should be cheaper and more robust. You won't need driver devices; simply connect the output pin you choose to use on your main PIC to the input pin you choose to use on the display driver PIC. I've done this for over 30 feet without issues.

  22. #22
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Couple of reasons, but most importantly, to keep the program cycling fast.
    A hardware serial port might overcome the speed issue,
    But would make it more difficult to do fancy things with the display.

  23. #23
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Problem Solved!!!

    Here's the current circuit I was describing with the LCD data bus obviously omitted:



    It does drive a 12 Volt relay this way if the other end of the relay coil is connected to a 12 Volt source.



    .................................................. ...............................


    I used the same transistor to switch the positive line to the LCD this way:



    I could always use the first circuit to drive a relay that in turn switches the LCD,
    but that wouldn't be very solid state would it?

    Q for Darrel, Does resetting the FLAGS var affect any other PBP related stuff?
    I have my own flags set and variables stored in RAM while I'm turning the VFD on & off.
    It's working perfectly, but I don't want it to break anything else software-wise.
    Cheers, Brek.

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


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Clearing the FLAGS variable will not affect anything else.
    There are some I2C bits in there, but they are only used during an I2CREAD/I2CWRITE command.

    The only time it could be bad is from within an interrupt handler, since an I2C command may have been interrupted.
    DT

  25. #25
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Great, no plans for I2C for this project Thanks for all your help too.

    Oh, and before I forget.... This:

    For old time sake!!

    Still waiting for a sine wave version in that old odometer thread.
    I used a pseudo sine lookup table to get the next vertical offset when I did it on my LED scroller.
    Code:
    LOOKUP si,[0,0,1,1,2,2,2,3,3,4,4,3,3,2,2,2,1,1,0,0],offset
    Anyways, the rolling clock gets to stay it isn't blocking execution.

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


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Cool, I'm glad the odometer display got some use.

    I tried the wavey one, but never did figure out a good way to do it.
    DT

  27. #27
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Tried it, it looked silly.
    You just add something like this:
    Code:
    LOOKUP si,[0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,6,5,5,5,4,4,4,3,3,3,2,2,2,1,1,1,0,0,0],offset'
    si = si + 1
    IF si = 41 THEN si = 0
    before you lookup the eeprom address where the character tables are on eeprom.
    add offset to the address you're reading from. Not worth it for LCD though I think.

  28. #28
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LCD cable length?

    Greater than 5 metres of 10 conductor shielded computer cable wired across
    a dashboard, to a compartment in the back of a large vehicle

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