Driving a 2x16 LCD with only One Pin and 74HC595


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jan 2014
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Driving a 2x16 LCD with only One Pin and 74HC595

    Hello Darrel,

    yes your are right, very scary!

    And yes I use the scope, because of controlling the puls length (µs).


    What I have done again:

    I reduce the code a little bit and I change/simplified some parts.

    Code:
    I replace this:
    
    Char_Temp = Char << 1                                 ; Shift Up Lower 4 Bits  
    Char_Temp = Char_Temp << 1
    Char_Temp = Char_Temp << 1
    Char_Temp = Char_Temp << 1 
    
    with this:
    
    Char_Temp = Char & %00001111                     ; Shift Up Lower4 Bits
    @ swapf _Char_Temp ,F

    Also I reduce the Upper an Lower Nibbel Part from 6 to only 4 Steps.

    Code:
    SELECT CASE Count_ShiftOut_Steps
     CASE 0
        Char_Temp = Char & %11110000                         ; Isolate Upper 4 Bits 
        If RSS = 1 Then : Char_Temp = Char_Temp | %00000100  ; Set RS Bit          
     CASE 1, 3
        Char_Temp = Char_Temp | %00001000                    ; Set Enable Bit 
     Case 2
        Char_Temp = Char & %00001111                         ; Shift Up Lower4 Bits
        @ swapf _Char_Temp ,F
        If RSS = 1 Then : Char_Temp = Char_Temp | %00000100  ; Set RS Bit            
    END SELECT
    Because Toggle the Enable Bit again is not necessary.


    Further, I change (Post 6, Point 2...."Although I have a feeling it can be reduced somehow")

    Code:
    This:
    
    ;----[Shift_Routine_74HC595 ]---------------(DO NOT Change)-------------------
    ShiftLoop_Steps = 7
    
    ShiftLoop:
    Readout_Bit = Bit_Shift.7
    SELECT CASE Readout_Bit
    CASE 1 
      Serial_Pin = 0 : @  DelayUS 1          ; min 1 µs for 1
      Serial_Pin = 1 : @  DelayUS 15         ; min 15 µs 
    Case 0
      Serial_Pin = 0 : @  DelayUS 15         ; min 15 µs for 0
      Serial_Pin = 1 : @  DelayUS 30         ; min 30 µs 
    END SELECT
    
    Bit_Shift = Bit_Shift << 1
    ShiftLoop_Steps = ShiftLoop_Steps - 1
    IF ShiftLoop_Steps != 0 THEN : Goto ShiftLoop
    
    ;Latch
    Serial_Pin = 0 : @  DelayUS 200        ; min 200 µs for Latch 
    Serial_Pin = 1 : @  DelayUS 300        ; min 300 µs
    Next  
    
    To This:                                     
    
    ;----[Shift_Routine_74HC595 ]---------------(DO NOT Change)-------------------
    ShiftLoop: 
    For ShiftLoop_Steps = 0 to 6
     @ rlf _Bit_Shift, F                     ; Shift 1.Pos left
    If STATUS.0 = 1 Then                     ; Carry Flag
       Serial_Pin = 0 : @  DelayUS 1         ; min 1 µs for 1
       Serial_Pin = 1 : @  DelayUS 15        ; min 15 µs
    else
       Serial_Pin = 0 : @  DelayUS 15        ; min 15 µs for 0
       Serial_Pin = 1 : @  DelayUS 30        ; min 30 µs 
    endif
    next
    
    ;Latch
    Serial_Pin = 0 : @  DelayUS 200         ; min 200 µs for Latch 
    Serial_Pin = 1 : @  DelayUS 300         ; min 300 µs
    Next
    Up to now, the code runs very good. (I Think a little bit better then before.)
    But sometimes when I simulate it on the PC, after some time, the LCD shows only cryptic characters.
    Then I have to restart the simulation again an all works fine.

    What du you think, is there something one can improve?

    Thanks in advance!

  2. #2
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Driving a 2x16 LCD with only One Pin and 74HC595

    Note also there will be a wide variation of timings across components, a wide variation of chip sensitivity, and a sensitivity to clock speed, temperature, power supply voltage, data rates, etc. etc. This approach is "O.K." for a hobby project, but it would be a very bad idea to try to use it in a commercial project, especially anything that might see volume.

    Not to rain on your parade, but given you can get PIC devices with fewer pins and at lower cost than a 74HC595, you would be further ahead to create a dedicated display driver PIC that you can send data to by 1 pin serial. Fewer components too, and rock solid communications.

Similar Threads

  1. 2x16 LCD Graphics :)
    By Art in forum General
    Replies: 51
    Last Post: - 13th June 2015, 12:02
  2. Need advice with LCD 2x16
    By fratello in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th April 2011, 07:58
  3. LCD via 74HC595
    By helloo in forum General
    Replies: 7
    Last Post: - 31st October 2010, 21:49
  4. 2x16 lcd problem
    By k3v1nP in forum mel PIC BASIC
    Replies: 11
    Last Post: - 30th October 2008, 05:46
  5. small 2X16 LCD
    By Ron Marcus in forum Off Topic
    Replies: 2
    Last Post: - 26th October 2007, 21:37

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