Charlie-plexing


Closed Thread
Results 1 to 40 of 61

Thread: Charlie-plexing

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Did this a while ago. Don't know if it will help. http://www.picbasic.co.uk/forum/showthread.php?t=14220

    If you use the above program you'll need to change you define osc line.

    Good luck.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    I used the wiring above for pins D.1, D.2 and D.3 on a 16F877 and it didn't work as expected.

    I get 3 LEDs blinking faintly instead of a single one. It seems as if the current loops over to the unused pin and comes back.

    I'll have to check out your thread. I must be missing something.

    Code:
    ' Blink 6 LEDs connected to Port D.1, D.2 and D.3 in charlie-plex manner
    
    '   PIC             16F877      ext osc 20MHz
    '   PBP             v2.60c
    '   MPASM           v5.49
    '   MCS+            v2.1.0.7
    '   U2 programmer   v4.32
    
    asm
     __config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _BODEN_ON & _LVP_OFF & _CPD_OFF & _WRT_OFF & _DEBUG_OFF & _CP_OFF
    endasm
    
    DEFINE OSC 20
    ADCON1 = 7                  ' Set Ports to digital
    TRISA = %00000000           ' Set all Ports to output 
    TRISB = %00000000
    TRISC = %00000000
    TRISD = %00000000
    TRISE = %00000000
    PORTA = %00000000           ' Set ports OFF
    PORTB = %00000000
    PORTC = %00000000
    PORTD = %00000000
    PORTE = %00000000
        pause 100
    mainloop:
        TRISD = %11111001       ' Enable pins D.1 and 2
        PORTD = %00000100       ' Turn ON pin D.2 --> D.1
        pause 500
        PORTD = %00000010       ' Turn ON pin D.1 --> D.2
        pause 500
    
    ;    TRISD = %11110101       ' Enable pins D.1 and 3
    ;    PORTD = %00001000       ' Turn ON pin D.3 --> D.1
    ;    pause 500
    ;    PORTD = %00000010       ' Turn ON pin D.1 --> D.3
    ;    pause 500
    
    ;    TRISD = %11110011       ' Enable pins D.2 and 3
    ;    PORTD = %00000100       ' Turn ON pin D.2 --> D.3
    ;    pause 500
    ;    PORTD = %00001000       ' Turn ON pin D.3 --> D.2
    ;    pause 500
    
        TRISD = %11111111       ' All pins disabled
        pause 500
        goto mainloop
    End
    Robert

  3. #3
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hi AvionicsMaster1
    No big deal, someone on here reckons that mistakes are not mistakes but learning opportunities and I think he's right having had plenty of learning opportunities myself.
    Still getting them.
    Using your idea to copy and paste |OR Demon, thanks.
    Thanyou to Richard for keeping us right and for introducing me to the lookup command which has led me onto writing my code in decimal and hex.
    Having great fun with them, well this is a hobby and hobbies are supposed to be fun.
    The following code is for a set of traffic lights on the roads as part of a 1/76 scale model railway.

    Code:
    '****************************************************************
    '*  Name    : Four Way Traffic Lights                           *
    '*  Author  : Jim Hagan                                         *
    '*  Date    : 10/07/2016                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : For 16F84A                                        *
    '****************************************************************
     #CONFIG
        __CONFIG _XT_OSC & _CP_OFF
    #ENDCONFIG
      'Defines
       DEFINE OSC 4          'Tell PBP3 expected system clock frequency
      'Aliases
       LEDS1 var PORTB        'Assign name LEDS1 to PORTB
       LEDS2 VAR PORTA        'Assign name LEDS2 to PORTA
       'Variables
       i var byte
       'Initialize
       TRISB = $0            'Set PORTB to Output
       TRISA = $0
       'Program Code
    START
       gosub REDGREEN
       gosub REDAMBER
       gosub GREENRED
       gosub AMBERRED
       goto START
    REDGREEN
       LEDS1 = $61            'LEDS 0, 5 and 6 on PORTB On
       LEDS2 = $08            'LED 3 on PORTA On
       pause 3000             'Puts lights on for 3 seconds
       for i = 1 to 10
       LEDS1 = $0
       LEDS2 = $0
       next i
       return
    REDAMBER
       LEDS1 = $D3             'LEDS 0, 1, 4, 6 and 7 on PORTB On
       LEDS2 = $04             'LED 2 on PORTA On
       pause 2000              'Puts lights on for 2 seconds
       for i = 1 to 10
       LEDS1 = $0
       LEDS2 = $0
       next i
       return
    GREENRED
       LEDS1 = $C              'LEDS 2 and 3 on PORTB On
       LEDS2 = $03             'LEDS 0 and 1 on PORTA On
       pause 3000
       for i = 1 to 10
       LEDS1 = $0
       LEDS2 = $0
       next i
       return
    AMBERRED
       LEDS1 = $9A              'LEDS 1, 3, 4 and 7 on PORTB On
       LEDS2 = $06              'LEDS 1 and 2 on PORTA On
       pause 2000
       for i = 1 to 10
       LEDS1 = $0
       LEDS2 = $0
       next i
       return
       end
    Regards
    Jim

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Quote Originally Posted by AvionicsMaster1 View Post
    Did this a while ago. Don't know if it will help. http://www.picbasic.co.uk/forum/showthread.php?t=14220

    If you use the above program you'll need to change you define osc line.

    Good luck.

    LMAO!

    I posted YOUR program above! I googled and searched this forum to try and find where I got it from but never found it.

    I'll have to look this over again, I must miss something obvious. You have GPIO, I only see PORT and TRIS registers as relevant on a 16F877.

    Robert

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Partly fixed.

    I was using 3 red, green and yellow LEDs; they have wildly different current draw/voltage drops. I switched to all greens and the ghosting effect is practically gone.

    I saw your comments about ghosting and noticed you output PORT before TRIS, didn't help me; tried both ways.

    Robert

    EDIT:
    Code:
    asm
     __config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _BODEN_ON & _LVP_OFF & _CPD_OFF & _WRT_OFF & _DEBUG_OFF & _CP_OFF
    endasm
    DEFINE OSC 20
    ADCON1 = 7                  ' Set Ports to digital
    TRISA = %00000000           ' Set all Ports to output 
    TRISB = %00000000
    TRISC = %00000000
    TRISD = %00000000
    TRISE = %00000000
    PORTA = %00000000           ' Set ports OFF
    PORTB = %00000000
    PORTC = %00000000
    PORTD = %00000000
    PORTE = %00000000
        pause 100
    mainloop:
        TRISD = %11111001       ' Enable pins D.1 and 2
        PORTD = %00000100       ' Turn ON pin D.2 --> D.1
        pause 500
        TRISD = %11111001       ' Enable pins D.1 and 2
        PORTD = %00000010       ' Turn ON pin D.1 --> D.2
        pause 500
    
        TRISD = %11110101       ' Enable pins D.1 and 3
        PORTD = %00001000       ' Turn ON pin D.3 --> D.1
        pause 500
        TRISD = %11110101       ' Enable pins D.1 and 3
        PORTD = %00000010       ' Turn ON pin D.1 --> D.3
        pause 500
    
        TRISD = %11110011       ' Enable pins D.2 and 3
        PORTD = %00000100       ' Turn ON pin D.2 --> D.3
        pause 500
        TRISD = %11110011       ' Enable pins D.2 and 3
        PORTD = %00001000       ' Turn ON pin D.3 --> D.2
        pause 500
    
        TRISD = %11111111       ' All pins disabled
        pause 500
        goto mainloop
    End

  6. #6
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hi
    Looks like I made a wrong post??
    Don't know what?

  7. #7
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    On topic, the March 2018 Nuts and Volts Magazine has an article on "Charlieplexing an analog style LED clock", by Robert Gill. It drives 182 LEDs with 14 I/Os.

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Isn't that impressive?

    Ioannis

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