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

Dellyjoe

Active member
Hello everyone,

I'm using this library for the Charlieplexing https://playground.arduino.cc/Code/Charlieplex/#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
 
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);
 
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?
 
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.
1.jpg

and this one
2.jpg


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?
 
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:
6-led-charlieplex-circuit.png

1k resistors protect low current IO pins such as the T4 which can't handle more than a few mA ]
 
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?
 
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);
 
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.
 
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
 
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.
 
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
 
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 ...
 
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!
 
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:
 
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 :)
 

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
 
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.
 
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
 
Back
Top