Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a project that involves about 200 LEDs and about 120 Switches. I'd like to use several MCP23S18 DIP chips across 2-3 buses to control everything. I'm a CS guy and just want to make sure I've got a decent idea of how this is supposed to come together.

The MCP23S18 datasheet.

Some general fact checking and advice on better ways to do this are all appreciated, I'm very new at this (for the record, this is not for class, just fun).

1) I've got LEDs for 2.2v at 20ma draw. I plan on using them in serial pairs, so the voltage drop should be 4.4 and the draw should be 20ma for each pair right?

2) According to the MCP23S18 datasheet (pg 33) the max Vin current draw is 125ma, and the max Vout is 400ma. This means I can safely power 6 pairs of LEDs with an approximate 4.4v chip input right? This means I should be able to use the remaining 11 pins an inputs as long as they are in the open drain configuration, thus avoiding significant draws right? Will it be safe to run all LEDs and have all switches open at the same time (assuming ample power supply)? What is the difference between "current sunk" and "clamp current"?

3) Does anyone have any ideas for a better alternative way to drive multiple leds? I know for some areas of the project that have groups of LEDs it will probably be easier to make a few cheap drivers so I can use all 16 pins as LED control. I've also considered using shift registers for this because I've found some with a 500ma Vin max, I could drive several easily this way. Perhaps a combination of the two, controlling the SR via an IO expander?

share|improve this question
    
I don't understand why this got a downvote, are there edits I can make to improve the question? – guyfleeman Feb 25 at 6:40
1  
Ignore the down votes, some people are just peckers. – Passerby Feb 25 at 6:55
1  
I was surprised, too. This is a well-formulated, well-researched question that I think has good general value to the community. – Jay Carlson Feb 25 at 7:12
    
@guyfleeman: Generally SE prefers single questions per site, and although they are somewhat connected, you asked about 6 or so. Especially the part for alternatives gets you dangerously near to the "too broad" region as one could surely write books about that. Some people like to express their dislike for these points as downvotes. – PlasmaHH Feb 25 at 10:24
    
@PlasmaHH thanks for the info; I just wanted some feedback on the reason so I can void it in future. I'll keep the multipoint preference in mind especially. – guyfleeman Feb 25 at 19:32
up vote 4 down vote accepted
  1. Yes. LEDs in series share the current, divide the voltage. Choose the resistor based on the combined Forward Voltage of the series LEDs.

  2. Vout is not the right term. It's Vss, or Gnd. But yes, 400 mA is the max current that can go through the Ground pin, through the Open-Collector Outputs. 6 LED strings, at 20 mA each is only 120 mA, only a quarter of the max. A resistor is required per string. Trying to just match the voltage is not good.

  3. The inputs are high impedance and not open-drain. They should only draw microamps, or fraction of a milliamp.

  4. All 6 leds and 10 inputs at the same time, sure, as long as you keep within the specs.

  5. The Clamp currents are the max current that can go through the clamp diodes, at a voltage higher than VDD or lower than VSS. Not relevant to your situation.

  6. Current Sunk means current flowing into the device, typically through the open-drain output, through VSS/Gnd. Current Sourced is from VCC, through the voltage high output.

  7. You can do up to 400mA, if your Power Dissipation is under 700 mW, so 500mA isn't significantly better. At 25 mA max per channel, when you want 20mA, you can already do 16 channels of 2 leds, per MCP. A shift register and a SPI device like the MCP23S18 are functionally quite similar as is. As for 500 mA through VIN, the difference would be wiring the in a common anode (To V+) or common cathode (To Gnd) manner. If you are using regular two pin LEDs, then that's not really a concern.

Typical Setup for LEDs:

schematic

share|improve this answer
    
Thanks for the clarifications. I was confused as to how Gnd and Vin related to the open-collector outputs. – guyfleeman Feb 25 at 7:08
    
Note that this chip isn't really designed to drive constant-current sources such as LEDs; I've added an answer with some alternative parts to consider. – Jay Carlson Feb 25 at 7:13
    
@JayCarlson i clarified that a resistor is needed. – Passerby Feb 25 at 7:15

These chips are rated to drive up to 25 mA per pin (times 16 pins = 400 mA max output current, as you mentioned), so they'll be able to pull 20 mA of current through your LED(s) without any problems. You'll be able to use all 16 channels simultaneously, as well.

I would ignore that 125 mA figure for maximum Vdd input current; it honestly makes no sense; since the chip has open-drain outputs, no appreciable current will flow into VDD (other than the rated 1 mA of current the device will pull during normal operation, as reported in the DC characteristics section of the datasheet). I suspect it might be a bad copy-paste job from another Microchip I/O port expander that has push-pull outputs.

...Having said all that, this chip has no intelligent current control; it's not designed to drive constant-current devices such as LEDs (unless you want to drive them at the current-limiting capabilities of the chip -- 25 mA). Because of this, you'll have to use series drop resistors connected to each channel, and any variances in the LEDs' current-voltage relationships will cause different brightness values across the LEDs.

Instead, I would recommend you use a true constant-current LED driver. The TLC59282 from Texas Instruments is similar to the MCP23018 in open-drain functionality, but it is less expensive and has a single IREF pin to set the current for all outputs.

The CAT4016 is a similar ON Semi part. The cheapest option is probably the ST ST16CPC26, which is similar to the other two parts mentioned.

But why stop there? Add in individual PWM brightness control with the infamous TLC5944, or the much more user-friendly (and easy-to-use) ISSI IS31F3216, or the venerable PCA9685, made by NXP. I prefer the NXP and ISSI solutions, as they have an i2C connection with internal PWM clock generation; the TI part requires a more "baby-sitting" from the MCU.

Aren't integrated circuits great? All of these parts are widely-available from your neighborhood electronic component distributor -- good luck!

share|improve this answer
    
The chip can be configured for open drain and push/pull. It's odd. The Open drain can carry significantly more current obviously. – Passerby Feb 25 at 7:16
    
My LEDs only pull 20ma so it's not current an issue for me, but I can certainly see it in future projects. Thanks for the LED driver references! I can't find them in DIP but I'm learning some reflow stuff at my UNI's studio so other form factors should be in reach soon! – guyfleeman Feb 25 at 7:16
    
I think all of those chips are available in easy-to-solder SOIC or TSSOP form. Many surface-mount components can be easily soldered without a reflow oven (BGAs and QFNs are really the only ones out of the question). There are a ton of SMD breakout boards on eBay that are useful for prototyping this sort of stuff. I'll see if I can track some drivers that come in DIP packages. – Jay Carlson Feb 25 at 7:20
    
They seem doable, but I'm very new and DIP looks much easier, especially for breadboard and then protoboard integration. I know the studio has machines that can make custom boards to solder onto, but I think that'll have to be my next project. – guyfleeman Feb 25 at 7:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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