mrteach
Posts: 181
Joined: Sun May 26, 2013 6:49 am

Cheap I/O Expansion chips

Tue May 28, 2013 4:53 am

So very new to pi, but have heard some stuff about expansion i/o
I've seen a couple of chips referenced. but wanted to know which is usually the cheapest (and easiest to use) so I can expand my i/o pins. And how many addition pins could I technically have? (Is it 256?)

Probably don't need that much but just curious.

User avatar
joan
Posts: 14937
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Cheap Expansion chips

Tue May 28, 2013 7:57 am

It depends on the use you plan to make of the expanded IO.

For instance if you wanted to interface to sensors with analogue outputs you'd need a chip with analogue inputs (the Pi's gpios are digital inputs and outputs).

You can attach as many inputs/outputs as you want to the Pi. I think people mention 256 because it's easy to do using the I2C bus. With specialised ad-hoc hardware you could add billions of inputs/outputs. Wouldn't be very practical though.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Cheap Expansion chips

Tue May 28, 2013 9:31 am

mrteach wrote:So very new to pi, but have heard some stuff about expansion i/o
I've seen a couple of chips referenced. but wanted to know which is usually the cheapest (and easiest to use) so I can expand my i/o pins. And how many addition pins could I technically have? (Is it 256?)

Probably don't need that much but just curious.
The limit is your imagination... Using mcp23s17's - they have 16 IO's per chip, you can connect 8 of them on one SPI bus, the Pi has 2 SPI buses, so that's 16 x 16 = 256 pins.

Add to that 8 more mcp23017's on the I2C and you're up to 384.

Now, shift-registers are convenient little output ports, and you can dasiy-chain them together to same drive pins, so for (e.g.) 4 x 595 SR's, using 3 pins, you can add on: 384 / 3 = 128 units of 32 output pins, giving you 128*32 = 4096 output pins.

Accessing them won't be terribly fast, but it's usable (and wiringPi v2 would handle this without any issues)

So use your imagination :)

But the easiest to use might be the mcp23s17 (SPI) or mcp23017 (I2C) based chips. No additional hardware required (although a decoupling capacitor would be recommended) Trivial to hook-up too - e.g.

http://wiringpi.com/extensions/spi-mcp23s08-mcp23s17/

Or for the combined SPI + I2C + shift-register example:

http://wiringpi.com/about/testing-wiringpi-v2/

-Gordon
--
Gordons projects: https://projects.drogon.net/

mrteach
Posts: 181
Joined: Sun May 26, 2013 6:49 am

Re: Cheap Expansion chips

Tue May 28, 2013 11:08 am

Ah I see seems like 16 extra is all I would need, unsure if I need analog or digital yet.

Not too many ebay listings for that chip.

PCF8574AP seems to have more listings and cheaper - 8bit = (3 dollars for 2)
PCF8575TS - similar price to MCP23s17 - both 16bit = (7 dollars ea)
MCP23s08 - most expensive.... (10 dollars ea)

any other possibilities. I like the cost of the PCF8574, but hopefully its easy to use as well.

also what do shift registers do?

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Cheap Expansion chips

Tue May 28, 2013 11:17 am

mrteach wrote:Ah I see seems like 16 extra is all I would need.

Not too many ebay listings for that chip.

PCF8574AP seems to have more listings and cheaper
That's an 8-bit chip with a rather curious way to do inputs - the outputs are effectively open collector outputs too - so they'll pull down to 0, rather than drive 3.3 ... To read it as an input, you need to write a 1 to each bit you want to read...

wiringPi supports it though, but programming it yourself from anything that can acces the I2C isn't hard - just rememberthe trick to reading an input is to write it high first.

The mcp23s17/23017 are much more versatile though. they're not expensive - about £1 each last time I bought any.

-Gordon
--
Gordons projects: https://projects.drogon.net/

Metz
Posts: 37
Joined: Mon Nov 28, 2011 3:38 pm

Re: Cheap Expansion chips

Tue May 28, 2013 11:22 am

I've quite succesfully used a set of 15 74HC595s from 3 wires on the Raspi. All daisy chained together, those 15 chips control 240 LEDs. These are only good for output, though, not input. They draw very little current, and I can run those 240 LEDs off a 5v 1A charger, including running the Pi.

If you buy the 595s in bulk, as I did, you can get them for as little as 12p each. (I bought 100 for about £12)

Metz
Posts: 37
Joined: Mon Nov 28, 2011 3:38 pm

Re: Cheap Expansion chips

Tue May 28, 2013 11:28 am

Shift registers allow you to send through an 8-bit pattern into the chip, and then 'latch' that pattern over to the output pins. So, sending through 0xAA would give you b10101010, meaning pins 2,4,6 and 8 would be high (Vcc), with the others being low (GND).

fanoush
Posts: 544
Joined: Mon Feb 27, 2012 2:37 pm

Re: Cheap Expansion chips

Tue May 28, 2013 5:18 pm

I have good experience with http://www.taydaelectronics.com they stock 74HC595, mcp23017 and other stuff like attiny85, atmega328, l293d,... for good prices. also watch their facebook page, they have 15% discount codes each month. so far I got two orders and quality seems to be good

mrteach
Posts: 181
Joined: Sun May 26, 2013 6:49 am

Re: Cheap I/O Expansion chips

Tue May 28, 2013 10:00 pm

yeah that s from 0 changed the prices =)

now 2.5 on ebay. I'll check out the site though and hopefully get 15% off =)

mrteach
Posts: 181
Joined: Sun May 26, 2013 6:49 am

Re: Cheap I/O Expansion chips

Tue May 28, 2013 10:06 pm

ah this is opening so many more possibilities now lol. Just want to build a tiny pi robot for now, but all the accessories are going to make it huge!

tummychow
Posts: 41
Joined: Wed Feb 20, 2013 6:36 am

Re: Cheap I/O Expansion chips

Wed May 29, 2013 12:36 am

If your concern is prices, there are much better ways than ebay. Remember that ebay prices are usually extremely high per unit (I find it's usually well over 100% markup), and the "free" shipping is being subsidized into the cost over their thousands of low-volume orders. There are better ways to get one or two chips in your hands. Sites like futurlec will gladly ship chips to you without murdering you on shipping (in toronto, canada, USPS insured shipping from new york - just a hop across the border - is on the order of 12-17 dollars... too much for a small order). They're very slow (6-8wks), but for four dollars anywhere in the world (from thailand), I can live with it. Idk what other low-cost shipping retailers there are but always be sure to check. If you're making low volume orders, shipping can be murder. Sometimes that's a fair reason to buy on ebay... but instead I get samples.

If you're a university student with a corresponding email address, or if you have a corporate email address, you might be able to request samples (free chips provided in small volumes for educational/hobbyist/prototyping purposes). 100% free and the shipping will typically be by standard postal or courier, so it's the same speed you'd get from a 12-17 dollar shipping fee. The shipping/processing is usually free as well. You can get 3-5 free chips in your hand within less than two weeks. How to go about this depends on the company, but a lot of companies have good policies and won't ask too many questions (TI, maxim, microchip all have pretty reasonable standard sampling processes. NXP is VERY forgiving. atmel is a bit of a squeeze.)

Anyway there's like a baijllion chips in the GPIO expander market, you can find stuff from microchip, maxim, NXP, TI... basically any company that has an "interface" section under their product categories list will have i2c gpio expanders in there somewhere, often SPI expanders as well. I think maxim has some big ones (24 pins) but in SMT packages which are inconvenient for a hobbyist. You're welcome to shop around if you want, but generally if i just want a few more pins, there are too many options on the market to bother; choose something in a DIP package, and use the time you saved to go make something.

And as for your tiny robot being huge... DIP chips will do that. The actual silicon die inside a dip chip is tiny and most of the volume of the chip is the epoxy body plus the long through-hole legs (look up a video of someone cutting an LPC1114 to a narrow pdip). If you're more advanced, you can design your own PCBs on something like oshpark and use surface mount components, which are orders of magnitude smaller... but that takes soldering experience, equipment, familiarity with PCB cad software, etc. Start off on a breadboard, worry about assembly later.

mrteach
Posts: 181
Joined: Sun May 26, 2013 6:49 am

Re: Cheap I/O Expansion chips

Mon Jun 03, 2013 1:49 am

ah too much knowledge for now =)

I got the jist of it though. Yeah I know there probably is a lot of chip distributors. Problem is, I don't know where to look and with the millions of sites out there. Its a pain to go through all of them.

The tayda seems like a pretty cheap one.

tummychow
Posts: 41
Joined: Wed Feb 20, 2013 6:36 am

Re: Cheap I/O Expansion chips

Mon Jun 03, 2013 11:42 pm

There's only one place you need to look: http://www.digikey.com/product-search/e ... rs/2556690
Digikey is arguably the premier online part distributor (other good, borderline-universal distributors include mouser and farnell/element14/newark) and they have a very comprehensive, and admittedly intimidating parametric search. If you don't know what manufacturer you're going to choose, this search is the ideal tool to select the part you plan to use. Once you know what part you're using, it's easy to find a distributor, because there are a bajillion distributors and they all basically do the same thing. Master the digikey parametric search index, and the entire domain of integrated circuits is yours to unravel.

For starters:
1) In my experience, digikey's search gets kinda funny if you select multiple columns at a time. Highlight the elements you want in a single column (select multiple elements with ctrl/shift), and then press apply filter. Then select your next column, and press apply filter, etc. One column after another. If you apply a filter to one column, the other columns will only show options that are still available. For example, if you select through-hole parts, and there are no through-hole parts with 24 IOs on them, then the IO column will not show an entry for 24 pins. So you don't need to worry about selecting invalid combinations. Digikey simply won't let you, if you go one by one.
2) Start with the mounting type. As a hobbyist (and no offense, but you sound rather new to the game), you will probably want to avoid surface mount parts which take extra equipment to prototype with (suitable boards to break them out). So select through hole.
3) Next take a look at the interface column. This is the serial bus that the chip uses to communicate with the Pi. You might not know what some of the entries in the list are; that's fine. Stick to i2c (aka SMBus, two-wire) and SPI (aka microwire/SSP). These protocols have strong hardware support on the Pi, and on MANY other devices. You don't need any extra parts to interface to them. Classic chips like the 74HC595 (shift register) are SPI-compatible by nature. Other common choices like the MCP23017 are i2c based, also very common. Protocols like CAN, you should stay away from, at least on the Pi. That stuff is more advanced, requires more parts. If you get into the microcontroller market, you will find more advanced micros with hardware CAN support onboard... but the Pi doesn't have it, and you're probably a ways away from that. The two buses I mentioned are the most common.
4) Under the # of IO column, choose the numbers of pins that you want from the part. Be aware that, if you want a TON of pins, you will often be restricted to a surface mount package. The DIP expanders that I use typically top out at around 16 pins; you might be able to find more or you might not.
5) Voltage supply - this is not particularly important, but still something to be aware of. The Pi runs from 3.3V, so you want any logic chips you use to run from the same voltage. Any voltage ranges that don't include 3.3V, you should exclude. Select only the ranges that include 3.3V; that way you don't get any incompatible parts that are designed for higher logic levels than the Pi can work with.
6) That's all the columns that really matter for your application, so now take a look at the table of parts that remain. Focus on the columns of the table with data that matters to you - how many IOs does this part provide? How do you communicate with it? What's its cost? (Note - if you buy small-volume like on ebay, the cost will be VERY different, because you're paying a premium for the low part count) Note that a single part might appear multiple times in the table, because Digikey sells it in various different containers. That's irrelevant to you; just focus on part numbers. Pull out the numbers that look like they do what you want, and then go find their datasheets for a more precise inspection of the nitty gritty details.

As am example, take a look at this: http://www.digikey.com/scripts/dksearch ... ageSize=50
I've applied the following filters:
i2c/spi parts only
8-16 pins
through hole
3.3v supply
What's left? Actually, not very much (the through hole restriction is by far the most significant, because it eliminates a LOT of parts). You have the MCP23XXX series of expanders, and a few other parts from NXP and TI. Now the list is nice and short, so you can seek out the individual manufacturer's part pages and take a look at datasheets, to get a more detailed impression of whether or not this part fits your needs. My personal recommendation is Microchip's parts (MCP23XXX), because they have a track record of providing through hole packages for a LOT of stuff, and in this day/age it can be rare to find through hole parts. In addition, a LOT of people have already used these parts on the Pi, and the code base is waiting for you, so you don't have to familiarize yourself with the precise commands. But if your needs are more exacting, don't hesitate to read those datasheets and draw what useful tidbits you can.

Again, if you learn how to do this parametric search yourself, the world is your oyster. Give it a shot; Digikey won't let you down.

mrteach
Posts: 181
Joined: Sun May 26, 2013 6:49 am

Re: Cheap I/O Expansion chips

Sat Jun 08, 2013 1:23 am

Wow thanks for all the tips. Getting into electronics requires a lot of knowledge. I'm still in the beginning parts so I don't even know how to properly pick chips/transistors/resistors/etc... I have only a slight idea how they interact with each other and voltages and stuff. Mainly the reason I'm asking all these questions =).

Thanks again. I order some chips, hopefully they work out when I have some time to test them

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Cheap I/O Expansion chips

Sat Jun 29, 2013 12:54 pm

I like Digikey for a few reasons.

1 - their prices are usually good depending...
2 - they will ship via USPS First class mail which is dirt cheap!

Their single lot prices for a MCP23017 is a whopping $1.44 Buy 25 of them for $25.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

kunio_bart
Posts: 1
Joined: Thu Sep 25, 2014 11:14 am

Re: Cheap I/O Expansion chips

Wed Oct 08, 2014 1:49 pm

Please look at our new product: igg.me/at/kunio
Via an SPI bus + some I/O pins, or just up to 7 simple I/O pins, you can add a huge number of digital in- and outputs in a modular way.
By using any microcontroller or Single Board Computer of your choice, you can create a powerful device (kind of PLC) that is accessible from the internet and has lots of storage and features using your own development tools.
The next step is to add more analogue inputs and outputs to this concept, without the need for more I/O pins.
I hope you enjoy this.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6229
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Cheap I/O Expansion chips

Wed Oct 08, 2014 8:58 pm

Please don't bump dead threads to advertise a product.

Return to “Interfacing (DSI, CSI, I2C, etc.)”