Charlie-plexing - Page 2


Closed Thread
Page 2 of 2 FirstFirst 12
Results 41 to 61 of 61

Thread: Charlie-plexing

  1. #41
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hi Richard
    I'll need to do a lot more reading to know what most of your code is doing.
    I sort of understand some of it but there is a lot I don't.
    You say it is for a 64 Led cube though there only appears to be 12 leds in the lookup?
    I really need to upgrade to PBP3 compiler Gold as I can't run your code with my set up.
    On learning about the Decimal and Binary I tried to run some code for 20 Leds but some didn't light, namely the Leds whose decimal was 16.
    Is there something else that needs to be changed in the code.

    Code:
    '****************************************************************
    '*  Name    : CharliePlex                                     *
    '*  Author  : Jim                   *
    '*  Notice  : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 21/06/2016                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : For PIC 16F84A                                                 *
    '****************************************************************
    #CONFIG
        __CONFIG _XT_OSC & _CP_OFF
    #ENDCONFIG
    'DEFINES:
         define OSC 10
         led var byte
         tmp var byte
         mainloop:
            
            for led=0 to 19
            lookup led,[12,12,9,9,3,3,7,7,10,10,5,5,11,11,6,6,13,13,14,14],tmp
            TRISB = $f0|tmp
            lookup led,[2,1,4,2,8,4,16,8,4,1,8,2,16,4,8,1,16,2,16,1],tmp
            PORTB = tmp
            pause 400
            next
             
    goto mainloop
    16 would be PORTB.4(00010000) by my Bin/Dec table.

    Regards
    Jim

  2. #42
    Join Date
    May 2013
    Location
    australia
    Posts
    2,515


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    I probably could have phrased that better , the code does only support 12 leds . the idea was to get a feel about led brightness and flicker
    to see if a 64 led version was worth the effort.
    when expanded to 64 leds the brightness is disappointing even with the resistors down to 39ohm.
    Warning I'm not a teacher

  3. #43
    Join Date
    May 2013
    Location
    australia
    Posts
    2,515


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    On learning about the Decimal and Binary I tried to run some code for 20 Leds but some didn't light, namely the Leds whose decimal was 16.
    Is there something else that needs to be changed in the code.
    TRISB = $f0|tmp the $f0 masks off the upper 4 bits [ this was to ensure other pins are not set to o/p by mistake

    if you need to make portb.4 an output the
    mask becomes $e0
    TRISB = $e0|tmp
    however
    all your tris values that don't need portb.4 as an output now need to bit4 set in your lookup table
    12 becomes 28 9 becomes 25 etc
    Last edited by richard; - 22nd June 2016 at 10:52. Reason: however
    Warning I'm not a teacher

  4. #44
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hi Richard
    Thanks again for some great information.
    Got the 20 Leds working fine. Tried the pauseus 1200 in the code and they are very dim with 100 ohm resistors.
    Found out that in the tris values where you have a pair you leave both alone if the port.4 (16) is involved.
    I have been looking through the PBP compiler manual but can not find any reference to the $e0 or the $f0.
    Does the $e0 remove the mask from all the upper 4 bits? and are there any more masking commands?
    I am thinking of doing a 30 led charlieplex, I have the layout for it.
    They are just on a breadboard at the moment and until I can design a good pattern that is where they will stay.
    I would like to know more about your last code set but I think I will need to wait until I upgrade and get a 16f1825 pic.
    Regards
    Jim

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


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    $e0 = binary 11100000
    $f0 = bin 11110000

    logical function AND (&) goes like this

    a b a&b
    0 0 0
    0 1 0
    1 0 0
    1 1 1

    logical bitwise function OR (|) goes like this
    a b a&b
    0 0 0
    0 1 1
    1 0 1
    1 1 1

    masking clearing and setting bit/s in a var can be accomplished this way

    eg if a = %11111111 (255 or $ff)

    then a&$e0= %11100000

    then a | 12 = %11101100

    see bitwise in book
    Warning I'm not a teacher

  6. #46
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hi Richard
    Thank you for the information, seems I have a lot to learn.
    I have been reading up on Bitwise in the PBP Compiler Ref manual.
    Can't find out how to type in the OR operator, doesn't appear to be on my keyboard.
    Anyway I'll keep on reading and see if I can make sense of it.
    Regards
    Jim

  7. #47
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,979


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Jim,

    If you can't type | using SHIFT, go through again with ALT.

    Edit: or come here and COPY the character and then PASTE it in your code.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

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


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Depending on the keyboard the | character doesn't look like it on your keyboard. Never could figure out why they do this but it's above the ENTER key and is accessed by using SHIFT and the \ key. It looks like a vertical line separated by a space in the middle. I thought in old programming terminology it's called the pipe symbol.

    Though it looks cool to use those symbols I think it's easier just to type OR and know what it means.

  9. #49
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hi Demon and AvionicsMaster1
    Thank you for the information.
    I will try your suggestions though I think typing OR seems the easiest.
    Regards
    Jim

  10. #50
    Join Date
    May 2013
    Location
    australia
    Posts
    2,515


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    I will try your suggestions though I think typing OR seems the easiest.
    Though it looks cool to use those symbols I think it's easier just to type OR and know what it means
    .


    NOT sure about that , this is what the book says


    3.4.2 Logical vs. Bitwise

    Logical operators are very different than bitwise operators! There are

    circumstances under which PBP will allow the use of logical operators in
    expressions. This means that no error message will be generated when you
    mistakenly use a logical operator in a bitwise calculation. Consider the following:
    result = PORTB AND %00001111
    ' Returns logical result (1 or 0)
    The above example will compile and give a result. The value of the result can only
    be one or zero (true or false). If the intent is to use a bitwise operation to obtain a
    binary result, you MUST USE BITWISE OPERATORS:
    Code:
       i_term=0
       d_err=4
       i_err= 3 
       i_term= i_err |  d_err
       serout2 PORTA.0,84,[ "3 | 4 ",9,#i_term, 13,10]
       i_term= i_err OR d_err
       serout2 PORTA.0,84,[ "3 OR 4 ",9,#i_term, 13,10]
    PRINTOUT:
    3 | 4 7
    3 OR 4 65535
    Last edited by richard; - 29th June 2016 at 05:36.
    Warning I'm not a teacher

  11. #51
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hi Richard
    Looking at the PBP3 Compiler Manual it only shows OR as the description for
    | in the Bitwise operators. It does show OR as an operator in the Logical operators.

    Regards
    Jim

  12. #52
    Join Date
    May 2013
    Location
    australia
    Posts
    2,515


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Logical operators are not bitwise operators
    | does a bitwise OR
    OR does a Logical OR

    2 | 3 = 7
    2 OR 3 = ! 0 [ not nothing ]

    Warning I'm not a teacher

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


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Yes I made a mistake. There is a difference between bitwise operations and logical operations. I vehemently apologize for the second part of my post.

  14. #54
    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

  15. #55
    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?

  16. #56
    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.

  17. #57
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,993


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Isn't that impressive?

    Ioannis

  18. #58
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Hello [insert user name ],
    You can disagree with someone's opinions, but calling that person an idiot or a profane name is a violation of our forum etiquette. Some forums are more liberal about this than others, but keeping it civil is never the wrong thing to do.

    Posting the same thing over and over again is called scrolling, and is also a banning offense. It is annoying in the extreme and it is entirely unnecessary, please refrain from further activity of that nature or risk a ban from this forum.DATA sheets are your friend.
    Please read the chips DATA sheet and make it happy You are in breach of the forums rules.

    Your recent post [insert post ref] breached the rules because [insert reason]

    This warning has been noted. We operate a three strike policy, however enforcement is at the admin / moderator discretion, in all respects our decision is final.

    Further warnings will result in suspension of the service to you.Please start a thread in the appropriate forum for detailed technical help. This is just a chat box, your post will disappear quickly.We accept that the vast majority of our forum members follow general forum etiquette.

    Forum etiquette means maintaining a standard of posting behavior that is acceptable and appropriate. Forum etiquette can be flexible, according to the subject of the forum, but there are certain standards most people expect others to maintain. Some lines must be drawn for the safety of all posting on the forum.

    You may disagree with someone's opinions, but calling that person an idiot is a violation of forum etiquette.

    Posting the same thing over and over again is called scrolling, and is also a violation of forum etiquette.

    Trolls enjoy disturbing the peace. Trolls tend to call names, gossip about other posters, post things that are deliberately provocative and usually violate the forum's rules about posting. Don't become a Troll.

    Another violation of forum etiquette is posting in ALL CAPS. This is considered shouting and is very rude.

    Flaming, or deliberate insults or personal rants, are also against forum etiquette. Flaming is often employed by people who are losing arguments on a forum. Their response is to personally insult the poster disagreeing with them, usually in a long, nasty post. The veil of anonymity seems to bring out the worst in these people, and any bullying tendencies they have tend to become magnified in the semi-protection given by the anonymity provided on a forum.

    Forum etiquette involves using the Golden Rule: treat others as you would like to be treated.

    Behaving as a reasonable adult, even in the face of being flamed, is always the best course of action. If a poster becomes harassing, obscene or personal, do not retaliate. Instead, report it to the moderators or forum administrators.

    Here we set out the basic rules that we use when managing the forum. By using the forum, you agree to abide by these rules and the decision of the administrators and moderators.

    General Forum Use
    • Do NOT make the same post in multiple forums. Moderators will remove multiple posts and you will receive an infraction for doing so.
    • The User Infraction system is designed to automate the management of misbehaving users. When a user reaches pre-determined number of infractions, the user permissions may be restricted.
    • Members should post in a way that is respectful of other users. Flaming or abusing users in any way will not be tolerated and will lead to an infraction, followed by a BAN.
    • Members are asked to not act as “back seat moderators”. If members note an issue which contravenes something in this policy document they are welcome to bring it to the attention of a moderator.
    • Members should remember this board is aimed at a general audience. Posting pornographic or generally offensive text, images, links, etc. will not be tolerated and will lead to a BAN.
    • Members are asked to respect the copyright of other users, sites, media, etc. Users linking to or asking for information on warez, crackz, etc. or re-printing material without permission will receive an infraction and their post will be removed. Blatant abuse and links to warez may result in an instant BAN.
    • Members are asked only to post in English, as this is an English speaking community.
    • Members should post in a way which is consistent with "normal writing". That is users should not post excessive numbers of emoticons, large, small or coloured text, etc. Similarly users should not SHOUT by writing in upper case or use excessive punctuation (e.g. ! and ?) in topic titles or posts. Users consistently abusing this will receive an infraction.
    • Members should use an appropriate, descriptive subject when posting a new topic. Examples of bad subjects include; "Help me!", "I'm stuck!", "I've got an error!" etc.
    • Members are welcome to use the test forum for general "test purposes". These may include checking signatures, testing a link or image, etc. (subject to previous points on decency, warez, etc.).
    • Spam is not tolerated here under any circumstance. This includes offering hosting services (charged and free), installation services, solicitation etc. Users posting 'SPAM' will be banned.
    • The moderators may edit, remove or put on moderation queue any post at any time. Please note that currently any very first post by a new user is automatically placed in the moderation queue and will be approved/disapproved according to the present Rules. The determination of what is construed as indecent, vulgar, spam, etc. as noted in these points is up to the admins and moderators, NOT the users.
    • The above forum rules where applicable also apply to private messaging. Abuse of the private messaging system may lead to an infraction and/or the revocation of private messaging facilities.

    Signatures
    • Signatures containing an image may also include one line of small size text.
    • Animated images are not allowed.
    • Links in signatures are permitted to a maximum of four unique pages or sites. Such links may only be to relevant or moderator approved material. Links to sites may be commercial in nature. You may not include links in a way which suggests you offer official support, software, etc. for Crownhill Products. You may not link to warez, porn, racist or other similar hate sites. Links are included in signature size limits.
    • Users abusing these rules will receive an infraction, their signature will be removed and repeated abuse will result in a BAN.

    Policing
    • Arguing with moderators or admins after having received an infraction or warning will lead to an immediate additional infraction and ultimately a BAN.
    • Users who feel they have been unfairly warned may contact an admin with their complaint. The admin's decision is final.
    • Any attempt to circumvent a temporary ban or other moderator action will lead to a permanent ban of your account(s). Circumvention includes re-registering or using an already registered account under a non-banned username. Other examples include changing IP addresses, using a new email account or other action that can be taken to evade moderator action to hide your identity as the owner of the sanctioned account.
    • An exception to the three strike rule applies when users contact team members personally (via any method) and post insulting, indecent or vulgar material. Such users may be subject to an immediate permanent BAN.
    • Permanent bans are a last resort and thought is given before implementing them.

  19. #59
    Join Date
    Jun 2016
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    It seems I went off Topic?

  20. #60
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    It seems more intuitive (for me) to depict a Charlieplexed matrix in column and row format. If I take the matrix (below) and fold along the dotted line, so to speak, I end up with a matrix, like Demon's, which should support some relatively inexpensive 2-pin Red/Green LED's I have laying around, right?
    Attached Images Attached Images   
    Last edited by Mike, K8LH; - 6th May 2018 at 14:40.

  21. #61
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,979


    Did you find this post helpful? Yes | No

    Default Re: Charlie-plexing

    Quote Originally Posted by Mike, K8LH View Post
    It seems more intuitive (for me) to depict a Charlieplexed matrix in column and row format. If I take the matrix (below) and fold along the dotted line, so to speak, I end up with a matrix, like Demon's, which should support some relatively inexpensive 2-pin Red/Green LED's I have laying around, right?

    Sorry, I took a break for a few years and didn't see this post.

    At first glance, your grid does look functionally like my leaning pyramid.

    It's weird, your design looks more confusing to me.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Members who have read this thread : 9

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