Menu

Custom character problem

Help
2014-10-16
2014-10-21
  • Jack Hoffnung

    Jack Hoffnung - 2014-10-16

    I have built a 2-line interface for a 2 x 16 LCD display (based on the old 74LS174), and it works fine, except for custom characters. I wrote the following simple program to create and then display a custom character, based on a program in the help file, but all I get is a blank screen. I have been able to verify that the array elements exist, but do not know why they are either not being copied to the LCD controller, or just not displayed. I am using what I believe is the most recent lcd.h file, dated 8-17-2014. Any help would be appreciated.

        ;Create and display a custom character
    
        #chip 12F683,8             ;PIC12F683 running at 8 MHz
        #config mclr=on            ;reset handled manually
        #config osc=int             ;use internal clock
    
        #define LCD_IO 2
        #define LCD_DB    GPIO.0   ;shift register data on GP0, pin 7
        #define LCD_CB    GPIO.1   ;shift register clock on GP1, pin 6
    
        Dim TempArray(8)
    
        'Set the array to hold the character
    
        TempArray(1) = 0b00011011
        TempArray(2) = 0b00011011
        TempArray(3) = 0b00000000
        TempArray(4) = 0b00000100
        TempArray(5) = 0b00000000
        TempArray(6) = 0b00010001
        TempArray(7) = 0b00010001
        TempArray(8) = 0b00001110
    
        'Copy the character from the array to the LCD
        LCDCreateChar 0, TempArray()
    
        'Draw the custom character
        LCDWriteChar 0
    
     

    Last edit: Anobium 2014-10-16
    • Anobium

      Anobium - 2014-10-17

      @Jack.

      This solution is 'based on the old 74LS174' approach. What is the configuration so I can build something similar?

      :-)

       
  • Anobium

    Anobium - 2014-10-16

    @Jack. A simple question. Can you confirm normal string handling works? I built a 74LS174 LCD solution last week and all was OK, but, I did not try LCDCreateChar. Please confirm normal operations is ok.

     
  • Jack Hoffnung

    Jack Hoffnung - 2014-10-16
      Hi Anobium.  Thanks for the reply.  I added a bit to the code to show string
      handling works, and that I can print elements of the array.  I note however that the
      same code placed after the LCDCreateChar command yields nothing.  In fact, the
      screen won’t even clear after that command.  Is this a clue?
    
    ;Create and display a custom character
    
    #chip 12F683,8             ;PIC12F683 running at 8 MHz
    #config mclr=on            ;reset handled manually
    #config osc=int            ;use internal clock
    
    #define LCD_IO 2
    #define LCD_DB    GPIO.0   ;shift register data on GP0, pin 7
    #define LCD_CB    GPIO.1   ;shift register clock on GP1, pin 6
    
    Dim TempArray(8)
    Dim cnt as byte
    'Set the array to hold the character
    
    TempArray(1) = 0b00011011
    TempArray(2) = 0b00011011
    TempArray(3) = 0b00000000
    TempArray(4) = 0b00000100
    TempArray(5) = 0b00000000
    TempArray(6) = 0b00010001
    TempArray(7) = 0b00010001
    TempArray(8) = 0b00001110
    
    CLS
    Print "A string works"     ;This is seen on the LCD
    Locate 1,0
    wait 2 s
         For cnt = 1 to 8
         Print TempArray(cnt)  ;so are these
         Next
    wait 2 s
    
    'Copy the character from the array to the LCD
    LCDCreateChar 0, TempArray()
    
    CLS
    Print "This one won't"      ;This doesn't show
    Locate 1,0
    wait 2 s
         For cnt = 1 to 8
         Print TempArray(cnt)   ;Nor do these
         Next
    wait 2 s
    CLS
    
    'Draw the custom character
    LCDWriteChar 0              ;Nor does this
    
     
  • Anobium

    Anobium - 2014-10-17

    I have tested on a LCD_IO 4 and all is good.

    Please try this. Let me know the results. Add this to your program. It will redirect the method while we determine the root cause.

    ~~~~

    define LCDCreateChar myLCDCreateChar

    'Create a custom character in CGRAM
    sub myLCDCreateChar (In LCDCharLoc, LCDCharData())

          'Store old location
          #IFDEF LCD_IO 4,8
                    Set LCD_RS Off
                    LCDLoc = LCDReadByte
                    Set LCDLoc.7 On
          #ENDIF
    
          'Select location
          Set LCD_RS Off
          LCDWriteByte (64 + LCDCharLoc * 8)
          wait 5 10us
    
          'Write char
          Set LCD_RS On
          For LCDTemp = 1 to 8
                    LCDWriteByte LCDCharData(LCDTemp)
                    wait 5 10us
          Next
    
          'Restore location
          #IFDEF LCD_IO 4,8
                    Set LCD_RS Off
                    LCDWriteByte (LCDLoc)
                    wait 5 10us
          #ENDIF
    

    end sub

     
  • Jack Hoffnung

    Jack Hoffnung - 2014-10-17
    Hi Anobium,.
    
        I inserted your code into my program, and got the same results; nothing works
        after the LCDCreateChar command is reached.  The hardware was built exactly as
        shown in the article: Build your own "2-Wire LCD Interface" using the PIC16C84
        microcontroller by Myke Predko, which I found on the Internet Archive Wayback
        Machine.
    
    I note that all  of the following commands work:
    lcdcmd1,2,4,5,6,7,8,12,13,14,15,16,20,24,28
    LCDCursor value
    LCDHex value
    LCDSpace value
    Put Line,Column, Character
    Locate line, column,
    Print string (or byte,word,integer)
    
    Thanks for your continued interest.
    
     
  • Jack Hoffnung

    Jack Hoffnung - 2014-10-21

    Hi Anobium,
    I think I may have figured out why custom characters do not work on a 2-wire LCD setup; RW is grounded, thus cannot be used for read/write operations. Am I on the right track?

     
  • Anobium

    Anobium - 2014-10-21

    That is probably the answer!!
    Well done.

    I will add to Help File.

    We learn something new every day.

    :-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.