Charlie-plexing


Closed Thread
Results 1 to 40 of 61

Thread: Charlie-plexing

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    I copied and pasted your code into MicroCode Studio but it would not compile with Sintax errors for , OSCON $70, ANSELA = 0, ANSELC = 0, TRISC = $f0.
    NOT ALL PICS ARE EQUAL , some study of the data sheet is always reccomended

    your code is posted in Quote tags not code tags [#]


    try this for a 16f84a

    Code:
    '****************************************************************
    '*  Name    : charlieplex.pbp                                        *
    '*  Author  : richard                                   *
    '*  Notice  :                                *
    '*          :                                *
    '*  Date    :                                          *
    '*  Version :    16f84A                                   *
    '*  Notes   :       *
    '*          :              *
    '*            
    '****************************************************************
    #CONFIG
    cfg = _XT_OSC
    cfg&= _WDT_ON
    cfg&= _PWRTE_OFF
    cfg&= _CP_OFF
      __CONFIG cfg
    #ENDCONFIG
     define osc 10
    led var byte
    tmp var byte
    
      
    ' tris     port     t,p
    '1 1100 0010    12,2
    '2 1100 0001    12,1
    '3 1001 0100    9,4 
    '4 1001 0010    9,2
    '5 0011 1000    3,8
    '6 0011 0100    3,4
    '7 1010 0100    10,4
    '8 1010 0001    10,1
    '9 0101 1000    5,8
    '10 0101 0010    5,2
    '11 0110 1000    6,6
    '12 0110 0001    6,1
     
       
    mainloop:
        
        for led=0 to 11
            lookup led,[12,12,9,9,3,3,10,10,5,5,6,6],tmp
            TRISA = $f0|tmp
            lookup led,[ 2, 1,4,2,8,4, 4, 1,8,2,6,1],tmp
            PORTA = tmp
            pause 200
        next 
    goto mainloop
    Warning I'm not a teacher

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    i see the problem
    TRISA = %11110100 'Enable Pins A.0, A.1, A.3
    PORTA = %00001001 'Turn on Pins A.0, A.3 (Led 2 and 9)
    TRISA = %11110100 == bad
    you can only light 1 led at a time , only two pins can be outputs at any one time (one high one low) the others need to be in a high impedence state [not high - high impedence ie input]

    to simulate multiple lit leds the the charlieplex needs to be driven multiplex style
    Code:
    '****************************************************************
    '*  Name    : charlieplex.pbp                                        *
    '*  Author  : richard                                   *
    '*  Notice  :                                *
    '*          :                                *
    '*  Date    :                                          *
    '*  Version :    16f84A                                   *
    '*  Notes   :       *
    '*          :              *
    '*            
    '****************************************************************
    #CONFIG
    cfg = _XT_OSC
    cfg&= _WDT_ON
    cfg&= _PWRTE_OFF
    cfg&= _CP_OFF
      __CONFIG cfg
    #ENDCONFIG
     define osc 10
    led var byte
    tmp var byte
    
      
    ' tris port
    '1 1100 0010    12,2
    '2 1100 0001    12,1
    '3 1001 0100    9,4 
    '4 1001 0010    9,2
    '5 0011 1000    3,8
    '6 0011 0100    3,4
    '7 1010 0100    10,4
    '8 1010 0001    10,1
    '9 0101 1000    5,8
    '10 0101 0010    5,2
    '11 0110 1000    6,6
    '12 0110 0001    6,1
     
       
    mainloop:
        
        for led=0 to 11
            lookup led,[12,12,9,9,3,3,10,10,5,5,6,6],tmp
            TRISA = $f0|tmp
            lookup led,[ 2, 1,4,2,8,4, 4, 1,8,2,6,1],tmp
            PORTA = tmp
            pause 200
        next 
        
    ;leds 2,9
       tmp=255
    while tmp
        TRISC = $f0|12
        latC = 1
        pause 10
        TRISC = $f0|5
        latC = 8
        pause 10
        tmp=tmp-1
     wend
     
    ;leds 10,12 
        tmp=255
    while tmp
        TRISC = $f0|5
        latC = 2
        pause 10
        TRISC = $f0|1
       latC = 1
        pause 10
        tmp=tmp-1
     wend
     
    ;leds 4,8
       tmp=255
    while tmp
        TRISC = $f0|9
        latC = 2
        pause 10
        TRISC = $f0|10
        latC = 1
        pause 10
        tmp=tmp-1
     wend
     
    ;leds 7,11 
        tmp=255
    while tmp
        TRISC = $f0|10
        latC = 4
        pause 10
        TRISC = $f0|6
        latC = 6
        pause 10
        tmp=tmp-1
     wend 
     
         
        
    goto mainloop
    Warning I'm not a teacher

  3. #3
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hi Richard
    Thanks for the information. Your first program works just fine except that Led 11 does not light. I ran my 12 Led running program and all leds lit up. In your second one you only appear to light 4 pairs out of the 6 available,the same 4 pairs that I can light up so is it not possible to light 6 pairs?
    My program does work but I could not find a way to light all six pairs in that 12 led set up.
    I think the reason I can't compile your original program is because my PBP3 Silver only does Mid range PICS, so I need to upgrade to Gold.
    Sorry I sent two drawings, slip of the mouse finger.
    I will try and run this last program you sent and see what happens.
    Not able to understand your first program fully, the small one, but I'm trying.
    Regards
    Jim

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    In your second one you only appear to light 4 pairs out of the 6 available,the same 4 pairs that I can light up so is it not possible to light 6 pairs?
    by using multiplexing you can " light' any or even all the leds its all about persistence of vision

    to light them all

    mainloop:

    for led=0 to 11
    lookup led,[12,12,9,9,3,3,10,10,5,5,6,6],tmp
    TRISA = $f0|tmp
    lookup led,[ 2, 1,4,2,8,4, 4, 1,8,2,6,1],tmp
    PORTA = tmp
    pauseus 1200
    next
    goto mainloop
    Warning I'm not a teacher

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    led 11 failed cause i had a typo and did not convert from my setup to yours properly , sorry



    Code:
    '****************************************************************
    '*  Name    : charlieplex.pbp                                        *
    '*  Author  : richard                                   *
    '*  Notice  :                                *
    '*          :                                *
    '*  Date    :                                          *
    '*  Version :    16f84A                                   *
    '*  Notes   :       *
    '*          :              *
    '*            
    '****************************************************************
    #CONFIG
    cfg = _XT_OSC
    cfg&= _WDT_ON
    cfg&= _PWRTE_OFF
    cfg&= _CP_OFF
      __CONFIG cfg
    #ENDCONFIG
     define osc 10
    led var byte
    tmp var byte
    
      
    ' tris port
    '1 1100 0010    12,2
    '2 1100 0001    12,1
    '3 1001 0100    9,4 
    '4 1001 0010    9,2
    '5 0011 1000    3,8
    '6 0011 0100    3,4
    '7 1010 0100    10,4
    '8 1010 0001    10,1
    '9 0101 1000    5,8
    '10 0101 0010    5,2
    '11 0110 1000    6,4   '   typo here
    '12 0110 0001    6,1
     
       
    mainloop:
        
        for led=0 to 11
            lookup led,[12,12,9,9,3,3,10,10,5,5,6,6],tmp
            TRISA = $f0|tmp
            lookup led,[ 2, 1,4,2,8,4, 4, 1,8,2,4,1],tmp   ;  and here
            PORTA = tmp
            pause 200
        next 
        
    ;leds 2,9
       tmp=255
    while tmp
        TRISA = $f0|12    ;  and here
        porta = 1    ;  and here
        pause 10
        TRISA = $f0|5    ;  and here
        porta = 8    ;  and here
        pause 10
        tmp=tmp-1
     wend
     
    ;leds 10,12 
        tmp=255
    while tmp
        TRISa = $f0|5    ;  and here
        porta = 2    ;  and here
        pause 10
        TRISa= $f0|1    ;  and here
       porta = 1    ;  and here
        pause 10
        tmp=tmp-1
     wend
     
    ;leds 4,8
       tmp=255
    while tmp
        TRISa= $f0|9    ;  and here
        porta = 2    ;  and here
        pause 10
        TRISa = $f0|10    ;  and here
        porta = 1    ;  and here
        pause 10
        tmp=tmp-1
     wend
     
    ;leds 7,11 
        tmp=255
    while tmp
        TRISa= $f0|10    ;  and here
        porta = 4    ;  and here
        pause 10
        TRISa = $f0|6    ;  and here
        porta = 4    ;  and here
        pause 10
        tmp=tmp-1
     wend 
     
         
        
    goto mainloop
    Last edited by richard; - 21st June 2016 at 06:21.
    Warning I'm not a teacher

Members who have read this thread : 3

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