how to "shift" a data into led matrix display ?


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: how to "shift" a data into led matrix display ?

    Wow, yeah, that's some pretty ineffecient code - no offense.

    * Try and never write the same snippet of code more than once, if more than a very simple command and it's needed more than a single time make it a subroutine. You have a VERY long piece of code copy/pasted twice (as far as I can see).
    * Avoid using HIGH/LOW, set the TRIS registers to the correct value and write directly to the PORT register (or LAT register on 18F parts). Doing that single thing saves 540 words in your program.
    * Instead of the IF/THEN thing for each bit just do C1 = LINE1[0+SVLA] etc.

    Something like:
    Code:
    ' Variables etc as before but make sure to set TRIS registers properly!
    
    DRO=2   'time refresh set
    
    'turn off display
    L1 = 1
    L2 = 1
    L3 = 1
    L4 = 1
    L5 = 1
    L6 = 1
    L7 = 1
    C1 = 0
    C2 = 0
    C3 = 0
    C4 = 0
    C5 = 0
    
    cikleri:
    FOR SVLA=0 TO 6 'scroll through the array
        GOSUB ScanIt
        PAUSE 5
    NEXT
    
    'ROTATE BACK
    FOR SVLA=6 TO 0 STEP -1
        GOSUB ScanIt
        PAUSE 5
    NEXT
    
    GOTO CIKLERI
    
    ScanIt:
        FOR TRIALI = 0 TO 29  'time to show individual char
            L1 = 0 'ENABLE LINE 1
            C1 = LINE1[0+SVLA]
            C2 = LINE1[1+SVLA]
            C3 = line1[2+SVLA]
            C4 = line1[3+SVLA]
            C5 = line1[4+SVLA]
            PAUSE DRO
    
            L1 = 1
            L2 = 0 'ENABLE LINE 2
    
            C1 = LINE2[0+SVLA]
            C2 = LINE2[1+SVLA]
            C3 = line2[2+SVLA]
            C4 = line2[3+SVLA]
            C5 = line2[4+SVLA]
            PAUSE DRO
    
            L2 = 1
            L3 = 0 'ENABLE LINE 3
    
            C1 = LINE3[0+SVLA]
            C2 = LINE3[1+SVLA]
            C3 = line3[2+SVLA]
            C4 = line3[3+SVLA]
            C5 = line3[4+SVLA]
            PAUSE DRO
    
            L3 = 1
            L4 = 0 'ENABLE LINE 4
    
            C1 = LINE4[0+SVLA]
            C2 = LINE4[1+SVLA]
            C3 = line4[2+SVLA]
            C4 = line4[3+SVLA]
            C5 = line4[4+SVLA]
            PAUSE DRO
    
            L4 = 1
            L5 = 0 'ENABLE LINE 5
    
            C1 = LINE5[0+SVLA]
            C2 = LINE5[1+SVLA]
            C3 = line5[2+SVLA]
            C4 = line5[3+SVLA]
            C5 = line5[4+SVLA]
            PAUSE DRO
    
            L5 = 1
            L6 = 0 'ENABLE LINE 6
    
            C1 = LINE6[0+SVLA]
            C2 = LINE6[1+SVLA]
            C3 = line6[2+SVLA]
            C4 = line6[3+SVLA]
            C5 = line6[4+SVLA]
            PAUSE DRO
    
            L6 = 1
            L7 = 0 'ENABLE LINE 7
    
            C1 = LINE7[0+SVLA]
            C2 = LINE7[1+SVLA]
            C3 = line7[2+SVLA]
            C4 = line7[3+SVLA]
            C5 = line7[4+SVLA]
            PAUSE DRO
            L7 = 1
        NEXT
    RETURN
    Went from 3161 to 775 words and that's just a first go.
    I'm sure the rest can be handled with some array manipulation and indexing to reduce the size even further but I don't have time right now.

    /Henrik.

  2. #2
    Join Date
    Feb 2013
    Posts
    1,154


    Did you find this post helpful? Yes | No

    Default Re: how to "shift" a data into led matrix display ?

    It is not twice, it just scrolls right to left and left to right. Thanks a lot, will have a look!

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: how to "shift" a data into led matrix display ?

    Hi,
    As far as I can see the FOR TRIALI=1 TO 30 / NEXT loop (which is the bulk of the code) is repeated twice. One time for right-to-left and one time for left-to-right.
    /Henrik.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,154


    Did you find this post helpful? Yes | No

    Default Re: how to "shift" a data into led matrix display ?

    Fitted your code, you're genius!

    now even with double amount of bitmap data added, whole code is only 920 bytes!

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: how to "shift" a data into led matrix display ?

    No I'm definitely not but thanks anyway :-)
    Might be interesting to put the bitmap data in FLASH instead of RAM (well, you're already putting it in FLASH but then loading it to RAM....). It probably won't be as straight forward but should be doable, perhaps using READCODE. Then again, if it works and does what it needs to there no need to bother....

    /Henrik.

  6. #6
    Join Date
    Feb 2013
    Posts
    1,154


    Did you find this post helpful? Yes | No

    Default Re: how to "shift" a data into led matrix display ?

    Yes I will have to read data from EEPROM, since this is just short demo and I need a lot of data, speaking in pixels, it will be 200*5*7, quite much for solely PIC to handle.

    Here's the sample video how it works:



    But have no idea how to handle these parasitic lights, if I increase DRO variable, then these half lit segments go away, but then flicker is noticeable.

  7. #7
    Join Date
    Feb 2013
    Posts
    1,154


    Did you find this post helpful? Yes | No

    Default Re: how to "shift" a data into led matrix display ?

    Checked in details, these parasitic lit segments are on even with larger DRO values. Tried to disable internal pull-up resistors - no change. Even tried to interlace update, do a 1,3,5,7,2,4,6 row sequence - no difference.

  8. #8
    Join Date
    Feb 2013
    Posts
    1,154


    Did you find this post helpful? Yes | No

    Default Re: how to "shift" a data into led matrix display ?

    Solved, just added this to each line draw end routine:

    c1=0
    c2=0
    c3=0
    c4=0
    c5=0

Similar Threads

  1. Replies: 0
    Last Post: - 14th November 2013, 04:32
  2. Replies: 3
    Last Post: - 15th October 2012, 09:06
  3. Adding data to an "array" in ASM
    By The Master in forum Off Topic
    Replies: 11
    Last Post: - 22nd November 2009, 04:21
  4. Replies: 2
    Last Post: - 22nd January 2008, 15:25
  5. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 21:31

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