1
\$\begingroup\$

I am using a PIC18F2420 microcontroller (I can change if required). The task is to drive up to 20 Power level indicator LEDs along with a few other LED indicator & switches using PIC. I can imagine connecting the anode of all 20 LEDs to the rail (~ 30V) and connecting cathode of each LED to a PIC I/O pin. But this would mean 20 I/O pins reserved just for this - waste of many I/Os. External I/O expander would add cost and only gives 8 more I/Os with ICs like MCP23008. Cost and PCB real estate is important consideration.. With Charliplexing LEDs, I can only turn ON 1 LED ON at a time. I don't want to drive them at duty cycle with reduced brightness..

How can I drive up to all 20 LEDs ON together with best usage of the PIC I/O pins? Do I really need a controller with so many pins that I have to assign 1 pin for each LED only? LEDs connection scheme drawing would be helpful to understand..

I don't want to turn all 20 LEDs on/off at the same time as a group..These LEDs are level indicators and as per the user input, I need to turn each next level indicator LED ON by keeping all lower level indicators ON as well, as level is increased by user and turn off each highest level LED off one at a time, as level is decreased by the user..

\$\endgroup\$
6
  • \$\begingroup\$ This is confusing : "connecting all 20 LEDs in series and hooking the anode to the rail (~ 30V) and connecting cathode of each LED to a PIC I/O pin" If the LED's were in series, you would only need one I/O pin to turn them on (using a transistor to buffer your Output pin) \$\endgroup\$
    – Marla
    Commented Feb 21, 2016 at 21:05
  • \$\begingroup\$ There is 16 and 24 bit port expanders. And you could always use a second PIC as a port expander. \$\endgroup\$
    – Passerby
    Commented Feb 21, 2016 at 22:16
  • \$\begingroup\$ Sorry for the confusion and thank you for your feedback..I don't want to turn all 20 LEDs on/off at the same time..These LEDs are level indicators and as per the user input, I need to turn each next level indicator LED ON by keeping all lower level indicators ON as well, as level is increased by user and turn off each highest level LED off one at a time, as level is decreased by the user.. \$\endgroup\$
    – user101095
    Commented Feb 22, 2016 at 0:38
  • \$\begingroup\$ I am aware about the port expanders but would like to avoid them if I can to reduce the cost and layout space on board.. \$\endgroup\$
    – user101095
    Commented Feb 22, 2016 at 0:46
  • 2
    \$\begingroup\$ At this point I am inclined to say that your requirements can not be met. You don't want to drive those 20 LEDs in parallel, because too many pins. You don't want to multiplex them, because too low brightness. Any Port extenders, working off PWM, Serial, I2C are too big and too costly for you. So I have to conclude that I am out of ideas. Maybe you should revise your requirements. Maybe you could change your design to fewer LEDs. Maybe incorporating the brightness in your display? \$\endgroup\$
    – jwsc
    Commented Feb 22, 2016 at 8:00

5 Answers 5

3
\$\begingroup\$

It appears that you are creating something like an audio VU meter. The easiest way to do this would be to create a PWM signal, filter it and send it out to an LM3914 dot/bar display driver. These drive ten LEDs each and can be cascaded to driver as many as required.

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the response..I would like to do this with the microcontroller PIC only, as I will need it for other purpose anyway. I would like to avoid using additional chips like LM3914 & IO expanders, if I can, to reduce cost and PCB space.. \$\endgroup\$
    – user101095
    Commented Feb 22, 2016 at 0:49
1
\$\begingroup\$

IF you are wanting to control all 30 LED's individually...

Use a shift register with a high current capability (if you need it). Shift registers allow you to switch a larger number of pins with only a small number of input pins by serializing data into the chip and outputting it to the number of pins that are on the device in parallel. There are many tutorials on this, just search around for shift registers. The nice thing about shift registers is that you can daisy-chain them together to use only a few output pins to control a large number of them, with the tradeoff of how quickly you can update the outputs.

What voltage and current are you wanting to run the LED's at? This will limit whether or not you can run the LED's from any conventional shift register. You may need to use the shift register to drive a MOSFET if you are wanting to control large LED's.

Here's a link to a common high current sinking shift register:

https://www.adafruit.com/products/457

\$\endgroup\$
1
\$\begingroup\$

I think you are three choices:

(1) The direct LED controlling, using a larger PIC eg the 18f4620 (having 35 I/O pins). There are superbright LEDs, these lit well with 2-3 mA also.

(2) Same as above but use a small and cheap transistor as emitter-follower for each LED, and normal (even high-power) LEDs.

(3) As 'Korozjin' wrote above, use shift registers. The TPIC6B595 is very good, but the much cheaper HC595 is also enough (able to sink/source max 8-9 mA/pin at a time).

\$\endgroup\$
0
\$\begingroup\$

If your LEDs are all to be controlled as a group - all switched on and off simultaneously - you only need to use one output from the microcontroller, but will likely need a driver transistor to handle the total LED current.

\$\endgroup\$
1
  • \$\begingroup\$ thank you for your feedback..I don't want to turn all 20 LEDs on/off at the same time as a group..These LEDs are level indicators and as per the user input, I need to turn each next level indicator LED ON by keeping all lower level indicators ON as well, as level is increased by user and turn off each highest level LED off one at a time, as level is decreased by the user.. \$\endgroup\$
    – user101095
    Commented Feb 22, 2016 at 0:40
0
\$\begingroup\$

PMIC led driver chip that talk over I2C . 24+ channels are easily and commonly available :)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.