Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 18 of 18

Thread: Charlieplexing: Issue, do all pins have pull-up resister?

  1. #1

    Charlieplexing: Issue, do all pins have pull-up resister?

    Hello everyone,

    I'm using this library for the Charlieplexing https://playground.arduino.cc/Code/C...lex/#Functions

    I'm using pins 24,25,26 to help me light up 6 LEDs

    Here are my defines
    Code:
    #define NUMBER_OF_PINS 3
    //define pins in the order you want to address them
    byte pins[] = {24,25,26}; // 0 , 1 , 2
    Charlieplex charlieplex = Charlieplex(pins,NUMBER_OF_PINS);
    //individual 'pins' , address charlieplex pins as you would address an array
    charliePin led1 = { 0 , 1}; //led1 is indicated by current flow from 12 to 13
    charliePin led2 = { 1 , 2 };
    charliePin led3 = { 0 , 2 };
    charliePin led4 = { 1 , 0 };
    charliePin led5 = { 2 , 1 };
    charliePin led6 = { 2 , 0 };
     
    boolean singleOn = false;
    
    Here is the code that makes them blink and then cycle from LED1-6
    Code:
      if (singleOn){ charlieplex.clear(); }
     delay(1000);
      charlieplex.charlieWrite(led1,HIGH);
     delay(1000);
      charlieplex.clear();
      charlieplex.charlieWrite(led2,HIGH);
     delay(1000);
      charlieplex.clear();
      charlieplex.charlieWrite(led3,HIGH);
      delay(1000);
       charlieplex.clear();
       charlieplex.charlieWrite(led4,HIGH);
      delay(1000);
       charlieplex.clear();
       charlieplex.charlieWrite(led5,HIGH);
      delay(1000);
       charlieplex.clear();
       charlieplex.charlieWrite(led6,HIGH);
      delay(5000);
     singleOn=!singleOn;
    I'm able to get all 6 LEDs blinking and turning off in order... great! For now I'm just using 6 LEDs, in the future I will have to use 64.

    The next thing I try to do is turn on LED 5, and 6 at the same time and by doing that you can take away the clear and delay function. It lights both of them up!

    Code:
      if (singleOn){ charlieplex.clear(); }
     delay(1000);
      charlieplex.charlieWrite(led1,HIGH);
     delay(1000);
      charlieplex.clear();
      charlieplex.charlieWrite(led2,HIGH);
     delay(1000);
      charlieplex.clear();
      charlieplex.charlieWrite(led3,HIGH);
      delay(1000);
       charlieplex.clear();
       charlieplex.charlieWrite(led4,HIGH);
      delay(1000);
       charlieplex.clear();
       charlieplex.charlieWrite(led5,HIGH);
       charlieplex.charlieWrite(led6,HIGH);
      delay(5000);
     singleOn=!singleOn;
    Next I try and turn LED 4,5,6
    Code:
     //charlieplex.clear();
      if (singleOn){ charlieplex.clear(); }
     delay(1000);
      charlieplex.charlieWrite(led1,HIGH);
     delay(1000);
      charlieplex.clear();
      charlieplex.charlieWrite(led2,HIGH);
     delay(1000);
      charlieplex.clear();
      charlieplex.charlieWrite(led3,HIGH);
      delay(1000);
       charlieplex.clear();
       charlieplex.charlieWrite(led4,HIGH);
       charlieplex.charlieWrite(led5,HIGH);
       charlieplex.charlieWrite(led6,HIGH);
      delay(5000);
     singleOn=!singleOn;
    This doesn't work,
    I get LED 1,2,3 to come on then it skips 4 and lights up 5,6

    Does anyone know why this is happening, is there pull up resisters I need to disable?

    Thank you for reading,
    Joe

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,699
    Three pins - at any one time one is GND and at most two on a row are HIGH?

    wiring not shown - and just guessing from general understanding and quick wiki glance ... 5 and 6 are on a row and powering them uses pin 4 HIGH line as GND?

    What does this show:
    Code:
       charlieplex.charlieWrite(led4,HIGH);
       delay(200);
       charlieplex.charlieWrite(led5,HIGH);
       delay(200);
       charlieplex.charlieWrite(led6,HIGH);

  3. #3
    Senior Member
    Join Date
    Jul 2020
    Posts
    897
    Nothing to do with pullups.

    With N pins you can charlieplex N(N-1) LEDs and light at most N-1 up at once, and only then if they all share
    the same pin as the same sense (anode or cathode). Follows directly from the circuit topology.

    BTW never mix red and blue/white LEDs in a Charlieplexed array, else the ~3V on voltage of a blue/white LED will
    inadvertently light up two red LEDs (1.4V forward voltage or so).

    You do have current limiting resistors?

  4. #4
    Quote Originally Posted by MarkT View Post
    Nothing to do with pullups.

    With N pins you can charlieplex N(N-1) LEDs and light at most N-1 up at once, and only then if they all share
    the same pin as the same sense (anode or cathode). Follows directly from the circuit topology.

    BTW never mix red and blue/white LEDs in a Charlieplexed array, else the ~3V on voltage of a blue/white LED will
    inadvertently light up two red LEDs (1.4V forward voltage or so).

    You do have current limiting resistors?


    Hello Defragster,

    Thank you getting back to me !

    I wanted to say I took the teensy out of the circuit, and did everything by hand and also had a 10M resister that was plugged into Vdd to ack as an input pin. The circuit worked great, I was able to turn on/off all LEDs

    With the circuit you asked me to test,

    Code:
      charlieplex.charlieWrite(led4,HIGH);
       delay(200);
       charlieplex.charlieWrite(led5,HIGH);
       delay(200);
       charlieplex.charlieWrite(led6,HIGH);
    I get the following two states,

    LED 6 and 4
    LED 6 and 5

    LED 6 is on all the time,
    followed by LED 4 and 5 blinking on and off.

    I again tested this circuit without the tennsy and everything seems to work great.
    Click image for larger version. 

Name:	1.jpg 
Views:	9 
Size:	156.5 KB 
ID:	23856

    and this one
    Click image for larger version. 

Name:	2.jpg 
Views:	7 
Size:	108.5 KB 
ID:	23857


    Thank you for taking the time out of your day to help me with this. Do you think this has to do with the pull-up resisters in each pin?

    Should I disable all pull-up pins on my teensy I don't use them atm, I just use circuit pull-ups?

  5. #5
    Senior Member
    Join Date
    Jul 2020
    Posts
    897
    Let me say it again: Nothing to do with pull-up resistors. Nothing.

    And do you have current-limiting resistors? You need them to protect the output pins from overload.


    [ Here's one way to do current limiting:
    Click image for larger version. 

Name:	6-led-charlieplex-circuit.png 
Views:	7 
Size:	12.0 KB 
ID:	23858

    1k resistors protect low current IO pins such as the T4 which can't handle more than a few mA ]

  6. #6
    Quote Originally Posted by MarkT View Post
    Let me say it again: Nothing to do with pull-up resistors. Nothing.

    And do you have current-limiting resistors? You need them to protect the output pins from overload.
    Hello MarT,

    yes atm i'm using 75ohm resisters and sorry I didn't see your post as it was making the post above.

    I'm using all white leds

    With N pins you can charlieplex N(N-1) LEDs and light at most N-1 up at once, and only then if they all share
    the same pin as the same sense (anode or cathode). Follows directly from the circuit topology.

    I'm able to get them all to light up by using this code
    Code:
      charlieplex.charlieWrite(led3,HIGH);
       charlieplex.charlieWrite(led4,HIGH);
       charlieplex.charlieWrite(led5,HIGH);
       charlieplex.charlieWrite(led6,HIGH);
    when using

    Code:
     charlieplex.charlieWrite(led3,HIGH);
       charlieplex.charlieWrite(led4,HIGH);
       charlieplex.charlieWrite(led5,HIGH);
       charlieplex.charlieWrite(led6,HIGH);
       delay(200);
    only LED 6 and 5 light up.

    This is so strange,
    What am I not understanding?

  7. #7
    with this code I get all three of them to blink in a row


    Code:
      charlieplex.clear();
       charlieplex.charlieWrite(led4,HIGH);
       delay(200);
       charlieplex.clear();
       charlieplex.charlieWrite(led5,HIGH);
       delay(200);
       charlieplex.clear();
       charlieplex.charlieWrite(led6,HIGH);
       delay(200);

  8. #8
    Senior Member
    Join Date
    Jul 2020
    Posts
    897
    With white LEDs the high forward voltage allows the resistors to be smaller, but 75 ohms sounds risky - for instance
    no pin on the T4 can handle more than 4mA at max drive level, and 4mA through 75 ohms only drops 300mV.

    You didn't say which Teensy, the current limitations vary depending on processor.

  9. #9
    Quote Originally Posted by MarkT View Post
    With white LEDs the high forward voltage allows the resistors to be smaller, but 75 ohms sounds risky - for instance
    no pin on the T4 can handle more than 4mA at max drive level, and 4mA through 75 ohms only drops 300mV.

    You didn't say which Teensy, the current limitations vary depending on processor.
    Sorry MarkT I'm new here and I can see I have alot to learn,
    I'm using a teensy 3.6 !

    But I'm using your topology show above with a 75ohm resister

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,699
    Not having used the library - but again charlieplexing works by running (fast cycling) power out the desired pins counting on the diode to light when biased properly and block otherwise.


    RE p#6 ::

    At no point is it expected that any LED gets full attention for very long - but rather quickly in turn such that it is lit less than full time/power - but often enough to 'appear' on so p#6 first code works well.

    With the delay(200) that stalls the cycle - leaving the last LED(s on that rail) powered 100%. But LEDs #3 and #4 are excluded and only get a non-perceptible nanoseconda flash of power before the feed power is cut to make #5 and #6 work at full brightness.

    Then it cycles through repeating - properly in p#6 first code and stalled in the second on the delay.

  11. #11
    Quote Originally Posted by defragster View Post
    Not having used the library - but again charlieplexing works by running (fast cycling) power out the desired pins counting on the diode to light when biased properly and block otherwise.


    RE p#6 ::

    At no point is it expected that any LED gets full attention for very long - but rather quickly in turn such that it is lit less than full time/power - but often enough to 'appear' on so p#6 first code works well.

    With the delay(200) that stalls the cycle - leaving the last LED(s on that rail) powered 100%. But LEDs #3 and #4 are excluded and only get a non-perceptible nanoseconda flash of power before the feed power is cut to make #5 and #6 work at full brightness.

    Then it cycles through repeating - properly in p#6 first code and stalled in the second on the delay.
    Right ok I understand that !,

    I also wanted to state that I did get the functionality I was looking for but I had to use the delay(1), white makes it appear like it is on.

    So for right now I will use this, and I will get it ready for my 64LED 8x8 matrix.

    Thanks for the Help MarkT and Degragster,

    MarkT atm I traded out the 75ohm resister for 270ohm resisters given you were talking about a power concern. But given They are not on for a full cycle am I ok with using 75ohm?

    Thanks again,
    Joe

  12. #12
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,699
    Before I powered up my first Teensy I was looking at DigiSpark 8 bit AVR - a guy there did dithering for gray scale. I don't find signs of it from 6+ years ago ...

    @MichaelMeissner - any chance you remember that? It seemed a cool scheme at the time - especially for 512Bytes of RAM and 6 I/O pins ...

  13. #13
    Senior Member
    Join Date
    Jul 2020
    Posts
    897
    Quote Originally Posted by Dellyjoe View Post
    Hello MarT,

    yes atm i'm using 75ohm resisters and sorry I didn't see your post as it was making the post above.

    I'm using all white leds

    With N pins you can charlieplex N(N-1) LEDs and light at most N-1 up at once, and only then if they all share
    the same pin as the same sense (anode or cathode). Follows directly from the circuit topology.

    I'm able to get them all to light up by using this code
    Code:
      charlieplex.charlieWrite(led3,HIGH);
       charlieplex.charlieWrite(led4,HIGH);
       charlieplex.charlieWrite(led5,HIGH);
       charlieplex.charlieWrite(led6,HIGH);
    when using

    Code:
     charlieplex.charlieWrite(led3,HIGH);
       charlieplex.charlieWrite(led4,HIGH);
       charlieplex.charlieWrite(led5,HIGH);
       charlieplex.charlieWrite(led6,HIGH);
       delay(200);
    only LED 6 and 5 light up.

    This is so strange,
    What am I not understanding?
    You are probably not allowing dead-time between switching off one set of LEDs and switching on
    the next set - the LED junction capacitance and stored charges may be holding enough charge
    for phantom illumination if you switch at high rates.
    In the first example you are not waiting anywhere so the output frequencies will be in the MHz or
    10's of MHz range perhaps.

    The way to drive is this:

    switch off the ones you want to turn off
    wait a few 100ns to allow capacitances to discharge
    switch on the ones you want on
    wait at least a ms or so

    With a slow microcontroller the first wait isn't needed, but with faster devices you'll find the
    microcontroller is faster than the LED!

  14. #14
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,008
    Quote Originally Posted by defragster View Post
    Before I powered up my first Teensy I was looking at DigiSpark 8 bit AVR - a guy there did dithering for gray scale. I don't find signs of it from 6+ years ago ...

    @MichaelMeissner - any chance you remember that? It seemed a cool scheme at the time - especially for 512Bytes of RAM and 6 I/O pins ...
    I remember Digispark, but I decided some time ago that I never wanted to deal with the restrictions of the ATtiny85 and got rid of them. I don't remember the dithering, sorry.

    Lets see some random google search links:

  15. #15
    Quote Originally Posted by MarkT View Post
    You are probably not allowing dead-time between switching off one set of LEDs and switching on
    the next set - the LED junction capacitance and stored charges may be holding enough charge
    for phantom illumination if you switch at high rates.
    In the first example you are not waiting anywhere so the output frequencies will be in the MHz or
    10's of MHz range perhaps.

    The way to drive is this:

    switch off the ones you want to turn off
    wait a few 100ns to allow capacitances to discharge
    switch on the ones you want on
    wait at least a ms or so

    With a slow microcontroller the first wait isn't needed, but with faster devices you'll find the
    microcontroller is faster than the LED!
    Thanks MarkT, Yes this is what I ended up doing, thank you for giving me an answer to why this works!

    Again thank you for helping me with this issue, next is to build a 64 LED grid

  16. #16
    Quote Originally Posted by MichaelMeissner View Post
    I remember Digispark, but I decided some time ago that I never wanted to deal with the restrictions of the ATtiny85 and got rid of them. I don't remember the dithering, sorry.

    Lets see some random google search links:
    Hello MichaelMeissner,

    I will look into this and maybe make an upgrade later down the road. Atm I'm still learning alot of C++ for the first time, and struggling through my first project, but hey this is just something I have to do. After my first go at it, I will make a list of upgrades and features I want to add, and I do want to make the LEDs multiple colors to show green yellow and red, and also want to make a PCD board for this.

    Thanks for the above information !!

    Cheers for now,
    Joe

  17. #17
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,008
    Quote Originally Posted by Dellyjoe View Post
    Hello MichaelMeissner,

    I will look into this and maybe make an upgrade later down the road. Atm I'm still learning alot of C++ for the first time, and struggling through my first project, but hey this is just something I have to do. After my first go at it, I will make a list of upgrades and features I want to add, and I do want to make the LEDs multiple colors to show green yellow and red, and also want to make a PCD board for this.

    Thanks for the above information !!

    Cheers for now,
    Joe
    Note, I am a software guy, and I tend to have a high level view of electronics, but often times I don't have the depth. I have never used CharliePlexing, only looked at it from reading the spec sheets.

    If you want simpler, I tend to think WS2812B/SK6812 leds are the way to go rather than Charlieplexing. Both WS2812B and SK6812 chipsets implement the same protocol, WS2812B is from the original manufacturer, and SK6812 is from another manufacturer. Adafruit sells WS2812B/SK6812 leds under the name neopixel. Note because only 1 data pin is used and there is no clock pin, the host microprocessor has a strict window to send the next packet. The simple minded libraries will block interrupts while updating the whole stream. Blocking the interrupts for a period of time can be problematical if you have servos or are playing music, both of which must send out their information in a timely fashion. There are various optimizations to allow the library to use DMA to send the packets and not turn off interrupts for the whole time.

    Or you can usey APA102 leds, which Adafruit sells as dotstar and Sparkfun sells as luMini. Unlike WS2812B/SK6812, since APA102 uses a data and a clock pin, the LEDs are not tied to a fixed timing window. You can send the information faster or slower than you can get with WS2812B/SK6812. This helps if you are trying to do POV lights and it also helps that other things don't have interrupt blocked while displaying the lights.

    Both WS2812B/SK6812 and APA102 are sequential streams where you have one pin (WS2812B/SK6812) or two pins (APA102) to control data send to the LED pixel (with 3 or 4 individual LEDs of different colors). Each LED pixel processes the first request and any other requests are sent to the next LED pixel in the line. So if you have 60 LED pixels in the strand, you will send 60 packets through the 1 or 2 data pins.

    It is simpler because you don't have to solder each individual LED. Instead, you can buy strands, rings, or matrixes of the LED pixels, and you only have to solder the connection at each end of the chain. And since each LED pixel contains a tiny microprocessor, you don't have to do PWM in the host microprocessor to change the brightness. Instead, each LED pixel has a byte to control the power level of each color, and the microprocessor takes care of doing the PWM for each color. If you don't send data down the wire, the LED pixels will continue with the color they were programmed with as long as they have power.

    I imagine with Charlieplexing one advantage is you can pack the individual LEDs in tighter.

  18. #18
    Thank you MichaleMeissner for the write up. Atm I think I will stick to my current way to doing CharliePlexing... might be kicking myself down the road but I can see a finished project by doing it this way.

    However I will be making updates to the project, and this will most likely me one of them. Thank you for writing the post up, I will store this information for now !!



    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •