LCD via 74HC595


Closed Thread
Results 1 to 8 of 8

Thread: LCD via 74HC595

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Lightbulb

    Quote Originally Posted by Darrel Taylor View Post
    You were getting close, but it did need a bit more.
    The pins I used are probably different than yours.

    Code:
    INCLUDE "ModeDefs.bas"
    INCLUDE "AllDigital.pbp"
    
    datapin    VAR PORTB.1
    clockpin   VAR PORTB.0
    latchpin   VAR PORTB.2
    led        VAR PORTA.5
    
    Tosend     VAR BYTE
    char       VAR BYTE
    RS_state   VAR BIT
    
    
    
    GOSUB InitLCD
    
    main:      ' 74HC595 : 5=6(E), 4=4(RS), 3=14(DB7), 2=13(DB6), 1=12(DB5), 0=11(DB4)
    
        for char = 32 to 90
            gosub SendData
            pause 500
            toggle led
        next char
    
    goto main
    
    ;----[Initialize LCD]----------------------------------------------------------
    InitLCD:
        RS_state = 0
        char = $30
        GOSUB sendHalfnibble
        PAUSE 6
        GOSUB sendHalfnibble
        PAUSE 1
        GOSUB sendHalfnibble
        PAUSE 1
        char = $20               ; Start 4-bit mode
        GOSUB sendHalfnibble
        char = $28               ; Function Set, 4-bit, 2-line, 5x7
        GOSUB SendCommand
        char = $0C               ; Display ON
        GOSUB SendCommand
        char = $01               ; Clear Screen
        GOSUB SendCommand
        char = $06               ; Entry Mode
        GOSUB SendCommand
    RETURN
    
    ;----[Send the Upper nibble to the LCD]----------------------------------------
    sendHalfnibble:
        Tosend = char >> 4  ' High Nibble only, needed for the initialisation routine, move Char 4 bits to the right
        GOTO sendtolcd
    return
    
    SendCommand:
        RS_state = 0
        GOSUB ToLCD
        PAUSE 2
    RETURN
    
    SendData:
        RS_state = 1
    
    ToLCD:
        Tosend = char >> 4                           ' High Nibble, move Char 4 digits to the right
        gosub sendtolcd
        tosend = char & $0F                               ' Low nibble = char, the other bit's won't matter
        gosub sendtolcd
    return
    
    SendToLCD:
        tosend.4 = RS_state                         ' RS state setzen "0" = command für LCD, "1" = Zeichen an LCD
        tosend.5 = 0                                ' Enable Bit OFF
        shiftout datapin,clockpin,msbfirst,[tosend]   ' send data to HC595
        high latchpin                               ' write into paralell buffer
        low latchpin
    
        tosend.5 = 1                                ' enable bit ON
        shiftout datapin,clockpin,msbfirst,[tosend]   ' data to HC595
        high latchpin                               ' sent to paralell buffer
        low latchpin
    
        tosend.5 = 0                                ' Enable OFF
        shiftout datapin,clockpin,msbfirst,[tosend]   ' send data to HC595
        high latchpin                               ' write to paralell
        low latchpin
        pauseus 50
    return
    Attachment 4867

    Darrel,

    Would that be possible to use 595_LCD routine (above) with a Hijacked LCDOUT command?

    Something like your LCDAnypin hijacking.

    ________
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Would that be possible to use 595_LCD routine (above) with a Hijacked LCDOUT command?
    Something like your LCDAnypin hijacking.
    Yes it would ... with some modification.

    But you may want to check out this post from Guido which uses a 74xx164 shift register and only uses 2 pins on the PIC with the HighJack routines.

    http://www.picbasic.co.uk/forum/show...5344#post95344
    DT

  3. #3
    Join Date
    Feb 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Hi coders,
    yepp, it was the darn LC display. I tried the 1602, and the code works. *grnnpgf* I spent 5 days of trying for nothing...

    Anyway, the next goal is to store strings in PICs memory, and shift them out to the LCD. Darryls "STRINGS.PBP" looks very interesting. I think I use his routines again...

    I'll write again.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Yes it would ... with some modification.

    But you may want to check out this post from Guido which uses a 74xx164 shift register and only uses 2 pins on the PIC with the HighJack routines.

    http://www.picbasic.co.uk/forum/show...5344#post95344
    Thank you Darrel.
    Guido's way did not work in my simulator. I will make the real circuit assuming that the simulator could not simulate it.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Feb 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    The circuit and the program work now. It's easily possible to drive up to three LCDs with only three I/O pins of the µC. Darryls "strings.pbp" work with only minor changes for my program. Thanks again, Darryl.


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