Charlieplexing led's on microcontroller/ Refresh rate - Page 1
Forum section: electronics / beginners

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: July 22, 2016, 06:37:04 am
content: 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 onThen no of led's = 9900Refresh rate = 9900*50 = 495000HzThat for single led: on time-2us & off time 20ms. Is 2us pulse enough to turn on led?

author: Ian.M
author_rank: Super Contributor
timestamp: July 22, 2016, 07:00:26 am
content: 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.

author: Brutte
author_rank: Frequent Contributor
timestamp: July 22, 2016, 07:50:16 am
content: Quote from: Vindhyachal.takniki on July 22, 2016, 06:37:04 amOk.QuoteYes.QuoteI'd go for 20Hz.QuoteThe 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.

author: MosherIV
author_rank: Super Contributor
timestamp: July 22, 2016, 08:46:28 am
content: QuoteIt 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.pngHere 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

author: mikerj
author_rank: Super Contributor
timestamp: July 22, 2016, 02:49:53 pm
content: Quote from: Vindhyachal.takniki on July 22, 2016, 06:37:04 amThe 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.

author: tszaboo
author_rank: Super Contributor
timestamp: July 22, 2016, 02:58:11 pm
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: July 22, 2016, 03:25:31 pm
content: 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.gPMD3001D), 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.

author: Galenbo
author_rank: Super Contributor
timestamp: July 23, 2016, 02:29:41 am
content: Quote from: Vindhyachal.takniki on July 22, 2016, 06:37:04 amPlease 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.

author: ebclr
author_rank: Super Contributor
timestamp: July 24, 2016, 07:17:47 pm
content: If you want to use a lot of led's with only few pins take a look on this ICTM1638http://retrocip.cz/files/tm1638.pdfA 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

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: July 26, 2016, 10:14:01 am
content: 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

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: July 26, 2016, 12:26:05 pm
content: Used Max7301 for 28 led's & 7 led using direct MCU pins.MAX7301 is 28 io port exapnder using SPI.

author: Galenbo
author_rank: Super Contributor
timestamp: July 29, 2016, 07:50:24 am
content: Quote from: Vindhyachal.takniki on July 26, 2016, 10:14:01 amGood 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.