Making Code Smaller for a Multiplexed LCD Display


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637

    Default Making Code Smaller for a Multiplexed LCD Display

    Hi,

    I have some code for a multiplexed LCD display that's taking a lot of memory space. The LCDDATA registers need to be updated frequently, so the display can work. There's got to be a clever way to do this using very little memory program space. I just can't figure it out yet. Can I use the SYMBOL command at the beginning of the program to define the PATTERN byte and save code memory space? Any hints, clues, or ideas are greatly appreciated.

    Code:
    '********** LOAD LCD REGISTERS **************
    
    IF DIGIT = 0 THEN
        LCDDATA0.7 = PATTERN.0      'DIGIT 0A = SEGMENT 7, COMMON 0
        LCDDATA3.7 = PATTERN.1      'DIGIT 0B = SEGMENT 7, COMMON 1    
        LCDDATA6.7 = PATTERN.2      'DIGIT 0C = SEGMENT 7, COMMON 2
        LCDDATA10.4 = PATTERN.3      'DIGIT 0D = SEGMENT 12, COMMON 3
        LCDDATA7.4 = PATTERN.4      'DIGIT 0E = SEGMENT 12, COMMON 2
        LCDDATA1.4 = PATTERN.5      'DIGIT 0F = SEGMENT 12, COMMON 0
        LCDDATA4.4 = PATTERN.6      'DIGIT 0G = SEGMENT 12, COMMON 1
        LCDDATA9.7 = PATTERN.7      'DIGIT 0P = SEGMENT 7, COMMON 3
    ENDIF
    IF DIGIT = 1 THEN
        LCDDATA0.4 = PATTERN.0      'DIGIT 1A = SEGMENT 4, COMMON 0
        LCDDATA3.4 = PATTERN.1      'DIGIT 1B = SEGMENT 4, COMMON 1    
        LCDDATA6.4 = PATTERN.2      'DIGIT 1C = SEGMENT 4, COMMON 2
        LCDDATA10.7 = PATTERN.3      'DIGIT 1D = SEGMENT 15, COMMON 3
        LCDDATA7.7 = PATTERN.4      'DIGIT 1E = SEGMENT 15, COMMON 2
        LCDDATA1.7 = PATTERN.5      'DIGIT 1F = SEGMENT 15, COMMON 0
        LCDDATA4.7 = PATTERN.6      'DIGIT 1G = SEGMENT 15, COMMON 1
        LCDDATA9.4 = PATTERN.7      'DIGIT 1P = SEGMENT 4, COMMON 3
    ENDIF
    IF DIGIT = 2 THEN
        LCDDATA0.1 = PATTERN.0      'DIGIT 2A = SEGMENT 1, COMMON 0
        LCDDATA3.1 = PATTERN.1      'DIGIT 2B = SEGMENT 1, COMMON 1    
        LCDDATA6.1 = PATTERN.2      'DIGIT 2C = SEGMENT 1, COMMON 2
        LCDDATA9.5 = PATTERN.3      'DIGIT 2D = SEGMENT 5, COMMON 3
        LCDDATA6.5 = PATTERN.4      'DIGIT 2E = SEGMENT 5, COMMON 2
        LCDDATA0.5 = PATTERN.5      'DIGIT 2F = SEGMENT 5, COMMON 0
        LCDDATA3.5 = PATTERN.6      'DIGIT 2G = SEGMENT 5, COMMON 1
        LCDDATA9.1 = PATTERN.7      'DIGIT 2P = SEGMENT 1, COMMON 3
    ENDIF
    IF DIGIT = 3 THEN
        LCDDATA1.2 = PATTERN.0      'DIGIT 3A = SEGMENT 10, COMMON 0
        LCDDATA4.2 = PATTERN.1      'DIGIT 3B = SEGMENT 10, COMMON 1    
        LCDDATA7.2 = PATTERN.2      'DIGIT 3C = SEGMENT 10, COMMON 2
        LCDDATA9.2 = PATTERN.3      'DIGIT 3D = SEGMENT 2, COMMON 3
        LCDDATA6.2 = PATTERN.4      'DIGIT 3E = SEGMENT 2, COMMON 2
        LCDDATA0.2 = PATTERN.5      'DIGIT 3F = SEGMENT 2, COMMON 0
        LCDDATA3.2 = PATTERN.6      'DIGIT 3G = SEGMENT 2, COMMON 1
        LCDDATA10.2 = PATTERN.7      'DIGIT 3P = SEGMENT 10, COMMON 3
    ENDIF
    IF DIGIT = 4 THEN
        LCDDATA2.1 = PATTERN.0      'DIGIT 4A = SEGMENT 17, COMMON 0
        LCDDATA5.1 = PATTERN.1      'DIGIT 4B = SEGMENT 17, COMMON 1    
        LCDDATA8.1 = PATTERN.2      'DIGIT 4C = SEGMENT 17, COMMON 2
        LCDDATA11.0 = PATTERN.3      'DIGIT 4D = SEGMENT 16, COMMON 3
        LCDDATA8.0 = PATTERN.4      'DIGIT 4E = SEGMENT 16, COMMON 2
        LCDDATA2.0 = PATTERN.5      'DIGIT 4F = SEGMENT 16, COMMON 0
        LCDDATA5.0 = PATTERN.6      'DIGIT 4G = SEGMENT 16, COMMON 1
        LCDDATA11.1 = PATTERN.7      'DIGIT 4P = SEGMENT 17, COMMON 3
    ENDIF
    IF DIGIT = 5 THEN
        LCDDATA2.3 = PATTERN.0      'DIGIT 5A = SEGMENT 19, COMMON 0
        LCDDATA5.3 = PATTERN.1      'DIGIT 5B = SEGMENT 19, COMMON 1    
        LCDDATA8.3 = PATTERN.2      'DIGIT 5C = SEGMENT 19, COMMON 2
        LCDDATA11.2 = PATTERN.3      'DIGIT 5D = SEGMENT 18, COMMON 3
        LCDDATA8.2 = PATTERN.4      'DIGIT 5E = SEGMENT 18, COMMON 2
        LCDDATA2.2 = PATTERN.5      'DIGIT 5F = SEGMENT 18, COMMON 0
        LCDDATA5.2 = PATTERN.6      'DIGIT 5G = SEGMENT 18, COMMON 1
        LCDDATA11.3 = PATTERN.7      'DIGIT 5P = SEGMENT 19, COMMON 3
    ENDIF
    IF DIGIT = 6 THEN
        LCDDATA2.5 = PATTERN.0      'DIGIT 6A = SEGMENT 21, COMMON 0
        LCDDATA5.5 = PATTERN.1      'DIGIT 6B = SEGMENT 21, COMMON 1    
        LCDDATA8.5 = PATTERN.2      'DIGIT 6C = SEGMENT 21, COMMON 2
        LCDDATA11.4 = PATTERN.3      'DIGIT 6D = SEGMENT 20, COMMON 3
        LCDDATA8.4 = PATTERN.4      'DIGIT 6E = SEGMENT 20, COMMON 2
        LCDDATA2.4 = PATTERN.5      'DIGIT 6F = SEGMENT 20, COMMON 0
        LCDDATA5.4 = PATTERN.6      'DIGIT 6G = SEGMENT 20, COMMON 1
        LCDDATA11.5 = PATTERN.7      'DIGIT 6P = SEGMENT 21, COMMON 3
    ENDIF
    IF DIGIT = 7 THEN
        LCDDATA2.7 = PATTERN.0      'DIGIT 7A = SEGMENT 23, COMMON 0
        LCDDATA5.7 = PATTERN.1      'DIGIT 7B = SEGMENT 23, COMMON 1    
        LCDDATA8.7 = PATTERN.2      'DIGIT 7C = SEGMENT 23, COMMON 2
        LCDDATA11.6 = PATTERN.3      'DIGIT 7D = SEGMENT 22, COMMON 3
        LCDDATA8.6 = PATTERN.4      'DIGIT 7E = SEGMENT 22, COMMON 2
        LCDDATA2.6 = PATTERN.5      'DIGIT 7F = SEGMENT 22, COMMON 0
        LCDDATA5.6 = PATTERN.6      'DIGIT 7G = SEGMENT 22, COMMON 1
        LCDDATA11.7 = PATTERN.7      'DIGIT 7P = SEGMENT 23, COMMON 3
    ENDIF
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Is this display a 7 segment?
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Quote Originally Posted by Dave View Post
    Is this display a 7 segment?
    Yes, it is.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    rsocor01, This may be a starting point:
    Attached Files Attached Files
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Actually, I have run into a similar LCD design very recently and have to eventually work on it. What he has is a segmented LCD glass with a controller. The various segments are scattered around the face of the lcd and not similar to a 7 segment LEDs grouping. Look carefully and you will find bits of each pattern are scattered around the lcddata bytes. To my mind, what rsocor01 has got now seems suitable if not ideal.

  6. #6
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Dave,

    This LCD is actually a 7-segments, 4 commons, multiplexed display. That code is more for an LED display type.

    Jerson,

    Thanks for your comment. So, you know that this displays are a pain in the neck to work with . The code that I posted works perfectly fine, and it can serve as a reference for somebody working with these displays in the future. However, it takes a lot of code space. I was hoping PBP could do something like

    Code:
    DIGIT_0.0   VAR   LCDDATA0.7
    DIGIT_0.1   VAR   LCDDATA3.7
    DIGIT_0.2   VAR   LCDDATA6.7
    ......... And so on
    But, I don't think that it can do it. Any ideas?
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  7. #7
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Even if it could, the underlying code will still have to do the same hard work of juggling bits around. So, eventually, there may only be syntactic sugar, but the bitterness will remain(code size).

  8. #8
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Quote Originally Posted by Jerson View Post
    Even if it could, the underlying code will still have to do the same hard work of juggling bits around.
    Yeap, you are right. I was hoping that somebody knew of a clever way of doing this.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Hello

    Which pic are you using? There are some newer chips like the 16f1939 with 1k ram and 16K of program space. There are 18f with double.

  10. #10
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Quote Originally Posted by mark_s View Post
    Hello

    Which pic are you using? There are some newer chips like the 16f1939 with 1k ram and 16K of program space. There are 18f with double.
    Actually, I'm using the 16F1939. I'm going to check for the 18F that you mentioned.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  11. #11
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    I think it’s tough, but a curiosity now,
    Code:
        LCDDATA11.1 = PATTERN.7
    How did you define these?
    Is PATTERN a single byte you are looking at bits 0-7,
    and LCDDATA, there are 11 bytes, and you look at bits 0-7 of all 11 bytes?

    I’ve not used that syntax before, but PATTERN.bit7 (to address a bit), or PATTERN[7] (to address a byte).

  12. #12
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: Making Code Smaller for a Multiplexed LCD Display

    Art, in this example there is a multiplexed 7-segment LCD, 4 commons, display that I am running directly from the PIC. The advantage of the 4 commons is that you only need one pin in the PIC for every 4 segments of the display, so you minimize the number of needed pins.

    The byte PATTERN changes its value for everyone of the 8 digits of the display. After enabling the LCD feature in the PIC, you need to load LCDDATA the registers for it to work.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

Similar Threads

  1. LCD display without firmware, problem with code
    By tomadarpel in forum mel PIC BASIC
    Replies: 1
    Last Post: - 30th May 2013, 12:20
  2. Making code more efficient, any ideas please?
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 26th July 2011, 14:28
  3. Trying to make code smaller
    By plyrathrt in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 5th January 2009, 18:20
  4. Making PBP code more modular
    By forgie in forum General
    Replies: 30
    Last Post: - 25th October 2005, 17:24
  5. Help Quick Need to make code smaller
    By Programmednew in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th January 2005, 04:46

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