Author Topic: Charlieplexing led's on microcontroller/ Refresh rate  (Read 3595 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Charlieplexing led's on microcontroller/ Refresh rate
« on: July 22, 2016, 06:37:04 am »
1. i have a micrcontroller whose all pins are used only 7 left & have to use 35 led's on it. SO i htought of using Charlieplexing.

2. Attached is the circuit. Its using 35 leds on 7 pins (X1-X7). Charlieplexing allows n(n-1), so 7*6=42 leds. Since I am using only 35 leds so haven't connected rest of them.  Is it ok?

3. I have reading on wikipedia for refersh rate. It says tyical rate for 1 led is 50Hz, so for 35 leds it would be 35*50=1750hz i.e around 571us.
So does that mean I have to make a timer interrupt of around 571us. On each interrupt one led will be brought to high or low depending on its state.
So consider if at any point all leds need to be high then in that one led seuence would be:
571us on & 19414us off  (517*34=19414)
So this will cycle 50 times in a second.


4. Is there any limit to maximum leds that can be used in Charlieplexing.
Since as led grows, on time decreases (and so off time), but I think there would be minimum on time required for led to glow?
So lets suppose I am using 100 pins (this is extreme example just for theory) & at some point all leds need to be on
Then no of led's = 9900
Refresh rate = 9900*50 = 495000Hz
That for single led: on time-2us & off time 20ms. Is 2us pulse enough to turn on led?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #1 on: July 22, 2016, 07:00:26 am »
2. There's a trick to the required series resistors for the LEDs when charliplexing - you only need seven, one in each X line, of half the value you require in series with an individual LED.   Due to the low duty cycle, once you charliplex on more than three or four pins, you generally want the lowest value series resistor your MCU can safely drive.

3.  You *ALWAYS* need to keep the refresh rate above 30Hz,   Anything below 60Hz has a high risk of objectionable flicker.  If you want to be certain the flicker wont be noticed, get the refresh rate above 100Hz.  Upto 100Hz, faster is better. Above that there is little benefit.   For your application, I'd probably make the timer rate 500us so the same timer can drive a 1ms or 10ms tick count for general application timing.   That would give you a 57Hz refresh rate.

4. The low duty cycle  combined with the limited current capability of an I/O pin limits the brightness and thus the maximum number of charliplexed LEDs.  Lets assume your MCU is good for +/-10mA on each I/O pin.  With 9900 LEDs, the average current would be only fractionally over 1uA.  Assuming you are using small high efficiency LEDs, this will be easily visible in a totally dark room, but will be unusable with any normal background illumination level.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #2 on: July 22, 2016, 07:50:16 am »
1. i have a micrcontroller whose all pins are used only 7 left & have to use 35 led's on it. SO i htought of using Charlieplexing.
Ok.

Quote
2. Attached is the circuit. Its using 35 leds on 7 pins (X1-X7). Charlieplexing allows n(n-1), so 7*6=42 leds. Since I am using only 35 leds so haven't connected rest of them.  Is it ok?
Yes.
Quote
3. I have reading on wikipedia for refersh rate. It says tyical rate for 1 led is 50Hz, so for 35 leds it would be 35*50=1750hz i.e around 571us.
I'd go for 20Hz.
Quote
4. Is there any limit to maximum leds that can be used in Charlieplexing.
The limit is the intensity one can get with given IO driver. Mind you are charlieplexing a LED from uC pin (20mA limit?) so do not expect it to be super bright. For best effects run a uC on highest rated voltage and use a drop resistor on each pin. This way power dissipation in a uC is minimized.

Also mind that you do not have to turn one led at n*(n-1) steps. You could easily turn on (n-1) at each of n steps if you would like to but because of the IO current limit a typical uC won't crank. Because of that there are SPI chips for Charlieplexing.

Seriously, dude, there are $1 constant current sink SPI drivers that could greatly ease your life.
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #3 on: July 22, 2016, 08:46:28 am »
Quote
The limit is the intensity one can get with given IO driver. Mind you are charlieplexing a LED from uC pin (20mA limit?) so do not expect it to be super bright.
It looks like the design get the GPIO of the micro to sink current instead of sourcing current. Usually the GPIO can sink a lot more than they can supply.

A way of allowing more current is to use a transistor on the output of the micro instead of trying to use the GPIO pin directly.

http://tech.cyborg5.com/files/2013/03/ir_out_1_trans_schematic.png
Here is an example of what I am talking about (ignore the fact it is driving IR LED).

Another option is to use a driver package such as the ULN2003
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #4 on: July 22, 2016, 02:49:53 pm »
4. Is there any limit to maximum leds that can be used in Charlieplexing.

The more LEDs you charlieplex, the dimmer they will appear.  Already you will be driving each LED with a 1:35 duty cycle, i.e. average current will be 1/35th of that it would be if the LED was continuously powered.

You might want to look at the MAX6952 or MAX6953.  One of these will control 35 LEDs from either an I2C or SPI bus.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7388
  • Country: nl
  • Current job: ATEX product design
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #5 on: July 22, 2016, 02:58:11 pm »
Just move the circuit in your peripheral vision, when using this multiplexing. The low duty cycle, low frequency driven LEDs make me nauseous. I will put a bunch of 74595 any day instead of PWM-ing something.
 
The following users thanked this post: newbrain

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #6 on: July 22, 2016, 03:25:31 pm »
MosherIV's suggestion of buffering the MCU I/Os is problematic as Charliplexing relies on the ability to tristate each output under program control.  You therefore need a buffer that tristates its output when its input is floating.  The simplest approach that will work is an unbiased complimentary pair of emitter followers,  (e.g PMD3001D), however they will introduce an additional voltage drop of Vbe, and therefore the maximum drive voltage across the LED network is reduced by 2*Vbe.   With a 5V supply, this may still be practical, giving >3V at currents of over 100mA.
 

Offline Galenbo

  • Super Contributor
  • ***
  • Posts: 1469
  • Country: be
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #7 on: July 23, 2016, 02:29:41 am »
1. i have a micrcontroller whose all pins are used only 7 left & have to use 35 led's on it. SO i htought of using Charlieplexing.
Please tell me you aren't really planning to do this in this world full of port expanders, and you just meantioned that as a physolophical brain sport intermezzo.
If you try and take a cat apart to see how it works, the first thing you have on your hands is a nonworking cat.
 
The following users thanked this post: newbrain

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #8 on: July 24, 2016, 07:17:47 pm »
If you want to use a lot of led's with only few pins take a look on this IC

TM1638

http://retrocip.cz/files/tm1638.pdf

A lot of leds , no resistors and will refresh for your self , your micro will work only when you need to change something also extremely cheap IC

 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #9 on: July 26, 2016, 10:14:01 am »
Thanks for reply.
I have dropped idea of using Charlieplexing, now I am planning to use MCP23S17.
I have a SPI port pending. so I will use two of these expanders for 32 led's
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #10 on: July 26, 2016, 12:26:05 pm »
Used Max7301 for 28 led's & 7 led using direct MCU pins.
MAX7301 is 28 io port exapnder using SPI.
 

Offline Galenbo

  • Super Contributor
  • ***
  • Posts: 1469
  • Country: be
Re: Charlieplexing led's on microcontroller/ Refresh rate
« Reply #11 on: July 29, 2016, 07:50:24 am »
Thanks for reply.
I have dropped idea of using Charlieplexing, now I am planning to use MCP23S17.
I have a SPI port pending. so I will use two of these expanders for 32 led's

Good idea. You can hardware-address these chips, up to 8 id's, so you don't need a CS_EN pin for each chip.
Works out of the box as output. Input is somewhat more complicated, when full init is needed for interrupt, pullup etc.
If you try and take a cat apart to see how it works, the first thing you have on your hands is a nonworking cat.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf