simple 16 signal GPIO I2C board


32 posts   Page 1 of 2   1, 2
by Frank Buss » Fri Jan 06, 2012 4:50 pm
I've designed a simple board, which could be used for the Raspberry Pi to expand the number of GPIOs:

http://www.frank-buss.de/io-expander/

It should be very good for educational purposes, because each GPIO pin has a 680 ohm resistor, so you can't damage the Raspberry Pi, if you short it and you can just connect low power LEDs without resistors to it (they are so bright these days, that they are good to see even at 3.3 V with 680 ohm). You could even short all output connections and the expander board survives it.

I have tested it with a PIC as a master, works great, up to 500 kHz with breadboard wires and two expander boards, with no problems from 2.8 V to 5 V. I'll get some prototype boards of the version 0.2 in some days (smaller board and external address coding pins, for selecting the 3 lower bits of the I2C address without soldering).

And I've tested it with a Raspberry, but looks like it doesn't work: http://i.imgur.com/mqkLe.jpg  :-)
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Joules » Fri Jan 06, 2012 4:56 pm
Needs more juice…..

and a crust
Posts: 87
Joined: Sun Dec 25, 2011 8:50 pm
by hippy » Fri Jan 06, 2012 6:23 pm
Frank Buss said:

You could even short all output connections and the expander board survives it.


Watch out for the maximum draw of the 3V3 rail though; just 50mA.

With 680R that's just shy of 5mA per output ( good enough as you say for most LED's ), but 16 outputs all drawing max current = 78mA.

It may be better to add a small 3V3 100mA regulator and take power from the GPIO 5V pin.
Posts: 828
Joined: Fri Sep 09, 2011 10:34 pm
by Frank Buss » Fri Jan 06, 2012 7:04 pm
hippy said:

Watch out for the maximum draw of the 3V3 rail though; just 50mA.

Thanks, you are right, just found the information at http://elinux.org/RaspberryPiBoard , I will add the MCP1703, which I've already used in another project ( http://www.frank-buss.de/joyst.....ckadapter/ ) and which works fine up to 250 mA, with short circuit protection, so could be even used to power parts which needs more current at 3.3 V on the breadboard.

BTW: Is there a more complete datasheet with full specification of the GPIO port and the Raspberry Pi in general?
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by jamesh » Fri Jan 06, 2012 8:48 pm
Frank Buss said:


hippy said:


Watch out for the maximum draw of the 3V3 rail though; just 50mA.


Thanks, you are right, just found the information at http://elinux.org/RaspberryPiBoard , I will add the MCP1703, which I've already used in another project ( http://www.frank-buss.de/joyst.....ckadapter/ ) and which works fine up to 250 mA, with short circuit protection, so could be even used to power parts which needs more current at 3.3 V on the breadboard.

BTW: Is there a more complete datasheet with full specification of the GPIO port and the Raspberry Pi in general?


Those datasheets are not ready yet I am afraid - everyone too busy on getting the board ready.
Volunteer at the Raspberry Pi Foundation, helper at Picademy September, October, November 2014.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 12342
Joined: Sat Jul 30, 2011 7:41 pm
by error404 » Fri Jan 06, 2012 11:28 pm
Nice. KISS. I like it. And there is already a driver in-tree for PCA9555, so all you need to make it work is an i2c bus driver for the BCM2835.

My only suggestion is that this seems to be designed for use on a breadboard without soldering anything, so perhaps it is worth using headers & jumpers or DIP switches to set the address.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by Frank Buss » Fri Jan 06, 2012 11:45 pm
error404 said:


Nice. KISS. I like it. And there is already a driver in-tree for PCA9555, so all you need to make it work is an i2c bus driver for the BCM2835.

My only suggestion is that this seems to be designed for use on a breadboard without soldering anything, so perhaps it is worth using headers & jumpers or DIP switches to set the address.



Thanks. Yes, the second version is all without soldering, see the last two pictures. Pulldown resistors for the address and headers with which you can pull it to Vdd. But no need for it, if you use only one of it.

Too bad that I don't have a Raspberry Pi so far, I could write a Linux I2C driver for it, because I worked for a company the last 8 years who developed embedded systems with Linux, and I wrote the Linux drivers and application for it.

Does the BCM2835 support open collector settings on the I2C pins, if configured as GPIO? Then an intermediate solution would be to use the software I2C in the Linux kernel for a beginning. Just include the software driver, declare the pins and functions to set the pin states in the "architecture" section and you are done.

Is the toolchain already available to play with? I hope the foundation is going to use something like Google Code or Sourceforge to make it easier for contributors.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Frank Buss » Tue Jan 17, 2012 6:02 am
Ok, I've updated the schematic and the board. Now there is an additional 3.3 V voltage regulator on board, which can be connected independently, and can be used also for other 3.3 V external components, which needs more power than the 50 mA of the Raspberry Pi 3.3 V rail:

http://www.frank-buss.de/io-ex.....index.html

(hit reload, if you have the old page cached)

I plan to sell it, but I'm not sure about the demand. Next week I'll get the new prototype PCBs and I'll assemble some for final tests. I can pre-finance 1000 boards, then it would be very cheap, less than 5 USD production cost (without soldered headers). I would do this, because I think there is some demand for it, and it can be used with other boards like the Arduino, too, and I would even build a test rig for 100% tested boards, if the Raspberry Pi shop would sell the IO expander boards for me :-)
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by SeanD » Tue Jan 17, 2012 6:35 am
Frank

It looks good, and you are right this would be useful not just for the RPi.  Sure you do not want to pop ADC onto it?  From my experience teaching kids Arduino there are two features that get used pretty quick and they are one or two channels of analog input and PWM.  There are so many interesting analog sensors out there to experiment with (including 2 pieces of wire and the kid themselves).  PWM is a different issue.
Posts: 121
Joined: Wed Sep 21, 2011 12:25 am
by Frank Buss » Tue Jan 17, 2012 7:02 am
SeanD said:

It looks good, and you are right this would be useful not just for the RPi.  Sure you do not want to pop ADC onto it?  From my experience teaching kids Arduino there are two features that get used pretty quick and they are one or two channels of analog input and PWM.  There are so many interesting analog sensors out there to experiment with (including 2 pieces of wire and the kid themselves).  PWM is a different issue.

Sorry, no PWM and ADC, it should be just a simple digital IO board. But PWM is already available on the Raspberry Pi, and for slow ADC tasks, like reading a potentiometer, it is easy to implement something with a RC combination on the digital ports, which has an additional educational effect. I'll develop some demo applications with the RPi as soon as I get one.

For advanced tasks a nice chip for breadboarding is the MCP3002 with SPI interface (you can get it for USD 2.15 at Digikey). For a full featured board the Gertboard is better.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by bredman » Tue Jan 17, 2012 4:51 pm
You can easily read a potentiometer value using 2 digital GPIO pins and a capacitor.

Use one GPIO as digital output to charge/discharge a capacitor through the pot. Use the other GPIO as a digital input (schmidt trigger if possible).

By measuring the time needed to charge/discharge the capacitor, the relative value of the pot can be calculated. Not great for actual pot values, but good enough to measure low/medium/high.

This is a typical trick used in older microcontrollers which do not have ADC support.
Posts: 1413
Joined: Tue Jan 17, 2012 2:38 pm
by Frank Buss » Sat Jan 21, 2012 10:22 pm
I've soldered a version 0.2 board (this is the same as the final version, but without the voltage regulator). I don't have a Raspberry Pi for testing it, but I've modded my LinkStation, this is an example how to use it with Linux:



On a Raspberry Pi it should work the same: You can login with SSH and mount a Samba drive for editing the source code with your favorite editor on your favorite OS. Or with X11 (is there X11 ported to it?) and a keyboard and monitor connected, you don't need another computer for editing and starting it.

Source code:

http://www.frank-buss.de/io-ex.....i2c-test.c

It should work on all Linux systems with I2C support. If anyone with a Raspberry Pi wants to try it, or wants to implement or test the I2C driver in the Linux kernel, I would be happy to send her/him an IO Expander board for free.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Neon22 » Sat Jan 21, 2012 11:10 pm
Russell Davis has put up a virtual raspberry pi machine here:

http://russelldavis.org/2012/0.....t-vm-v0-2/

He is assuming its based on fedora13. if it isn't he's probably close...

You could use it to test your board and ideas.

Also an example driving the ports from python would be excellent.

I think your board is very nice.
Posts: 29
Joined: Mon Sep 19, 2011 4:11 am
by Frank Buss » Sun Jan 22, 2012 12:05 am
I have converted it to Python, but I have not much experience with it, so could be not very Python idiomatic, but it looks already much nicer than the raw C version and it works on my LinkStation:

http://www.frank-buss.de/io-ex.....2c-test.py

I think I should program more in Python. And thanks for the VM link, currently downloading the Torrent.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Frank Buss » Sun Jan 22, 2012 10:01 am
Donwload finished, the I2C test program compiles in the VM for the Raspberry Pi scratchbox and I can start it, but it doesn't find the I2C device. Is it possible to emulate I2C inside of the scratchbox (I guess it is QEMU)? Looks more like an environment to test compilation and if it starts with all the libraries on the target system, but this is still very useful.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Neon22 » Tue Jan 24, 2012 5:26 am
Looks great to me Frank. So simple. Very cool.

If controlling the h/w is this simple on the pi its going to be great.

Cheers…

P.S. to turn it into a module just put a:

if __name__ = "__main__":

before the demo useage code.

I hope your going to offer it as a kit ? or even a set of boards ?
Posts: 29
Joined: Mon Sep 19, 2011 4:11 am
by bcatalin » Mon Jan 30, 2012 10:44 am
Very nice GPIO board. I am waiting for Rpi just to used to communicate with other devices. I want to test it with all kind of sensors, even to see how openCV is working on this little machine. If I will get a Rpi I want also a GPIO board.
Posts: 21
Joined: Mon Jan 30, 2012 9:45 am
by AdamantUK » Tue Feb 14, 2012 7:35 pm
Hi Frank,

I'd be interested in a few, I can see the Raspberry PI with this being better (and easier to work with, along with way more functions) than an Arduino with an ethernet shield!

I've been meaning to hook up the office Coke machine to the Net so could do with a fair few IO ports to hook up to the "sold out" lights, relay onto the "free vend" line, and relay onto the can options with both I and O so I can logon to a web page from my PC and push on the can I want - then also see what is the most popular purchase!

It'll be fun for my first Raspberry Pi project and also first ever Linux project - I'm a windows software guy by day who likes to dabble with hardware by night! :)
Posts: 7
Joined: Tue Feb 14, 2012 7:21 pm
by Frank Buss » Wed Feb 15, 2012 1:32 pm
I've updated my website with an Arduino example. And I have ordered some boards from a professional PCB assembling company, who does the soldering of the slightly difficult small SMD parts. I'll get the boards in the week from march 26 and after a full test, it will be available from a shop I've found who sells it internationally for me. I don"t know the final price, will be more expensive than I thought, because I didn't ordered thousands of it and some offset for the shop, but there will be kits available, with breadboards and wires.

I have asked if it could be sold in the Raspberry Pi shop, too, which would make it cheaper to order when you buy a Raspberry Pi anyway, but no answer so far.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by gregd99 » Thu Mar 08, 2012 2:19 am
Frank,

That's a nice board.

I built a similar board for use as an atmega 64-way expander but using a protoyping pcb rather than a custom board.

a couple of questions....

1. I used the 4 x MCP23017 and then some ULN2803s. Did you consider the 23017? does the PCA9555 offer advantages?

2. do you need some pull-ups that are jumper selected on the sda/scl?

3. my application was model rail and I included screw connectors (2.54mm pitch) for the wiring. this is pretty tiny but allows easy and permanenet connection rather than flying leads. have you considered this?
Posts: 20
Joined: Mon Feb 20, 2012 6:57 am
by Frank Buss » Thu Mar 08, 2012 6:40 am
The MCP23017 looks good. Compared to the PCA9555 it is nice to configure the pins as open collector and the advanced interrupt configurations. But looks like it doesn't have ESD protection for static discharges.

Jumper selectable pull-ups for SDA and SCL would be a good idea, but the value of the resistors depends on the I2C system and if powered by 5 V or 3.3 V, so I didn't included this. But could be soldered in the second row on the board, if used without a breadboard or a veroboard.

Thanks for the screw connector idea, it should fit on the board, I'll try it.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by gregd99 » Thu Mar 08, 2012 6:48 am
These are the connectors I used http://www.modtronix.com/index.....63_164_169.

they are tiny which was good for me as I had 64 connection points and on a proto board the 2.54mm pitch aligned with the device pin outs.
Posts: 20
Joined: Mon Feb 20, 2012 6:57 am
by Frank Buss » Mon Apr 09, 2012 10:00 pm
Got the first batch of 100 boards. I forgot one 2 mm trace to route, for the address coding pin header, but I patched already 50 boards (see below) and soldered the address pin header, I'll do the rest tomorrow. I've built a test setup with pogo test pins (nice tutorial how you can do this: http://www.ladyada.net/make/pogojig/ ) for a 100% test of all boards, and I hope you can buy it from the shop which sells them next week. Will be announced in this thread. Happy Easter!

User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Neon22 » Mon Apr 09, 2012 11:07 pm
Looking forward to it :)
Posts: 29
Joined: Mon Sep 19, 2011 4:11 am
by Frank Buss » Sun Apr 15, 2012 2:50 am
Good news: The tests are finished. I've created a test circuit with another simple project I've developed ( http://www.frank-buss.de/displ.....index.html ). With two 4051 multiplexers and the analog input of the PIC, I measure each output of the PCA9555 of the board and all neighbours, so I can detect shorts to GND, Vdd and shorts between pins (half voltage). I've tested all 3 jumper positions for each board.

The voltage regulator delivers some mA to a resistor for testing, which are ok for all 100 boards (between 3.27 V and 3.30 V). One board had a faulty solder joint, so looks like the quality is really good. The first 100 boards are shipped now to the shop. I'll create a datasheet for it in the next days and post the link to the shop when it is available.

A picture of the test board with a jumper at address bit 0. Professionally constructed with hot glue :-)

User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm