View previous topic :: View next topic |
Author |
Message |
Guest
|
Reading a lot of digital I/O..... |
Posted: Mon Aug 27, 2007 7:15 pm |
|
|
Hi All,
I have a need to read the state of about 200 digital inputs with a PIC. Obviously, I need to multiplex them in some way to get all the data into the processor. I was thinking shift registers or something like that. Any other clever tricks come to mind?
Thanks,
Derek |
|
![](templates/subSilver/images/spacer.gif) |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Mon Aug 27, 2007 9:37 pm |
|
|
My favorite trick: I2C I/O expanders such as PCA9671. _________________ Read the label, before opening a can of worms. |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Tue Aug 28, 2007 5:45 am |
|
|
It seems to me the type of input would depend on the speed you require. If speed is no concern then the serial expander proposed by Kender would give you almost unlimited inputs with very few control lines. On the other hand bytewide multiplexors would provide a lot more speed and random access at the expense of control lines. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Aug 28, 2007 8:29 am |
|
|
have a look to I2C 16-I/O Ports Expander MCP23017 from Microchip.
Nilsener |
|
![](templates/subSilver/images/spacer.gif) |
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Tue Aug 28, 2007 8:30 am |
|
|
As above, Microchip port expanders work well. |
|
![](templates/subSilver/images/spacer.gif) |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Tue Aug 28, 2007 1:51 pm |
|
|
Anonymous wrote: | have a look to I2C 16-I/O Ports Expander MCP23017 from Microchip. |
You can have only eight MCP23017s on one I2C bus. The original poster needs 200 I/O. 8*16=128 < 200 _________________ Read the label, before opening a can of worms. |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Tue Aug 28, 2007 3:22 pm |
|
|
One option is to use the CS pins to select banks of MCP23017s. With one CS line from the PIC up to 16 MCP23017 chips could be used. |
|
![](templates/subSilver/images/spacer.gif) |
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Tue Aug 28, 2007 3:27 pm |
|
|
Quote: | Perhaps, with the 8 limit you could mux the SCL line out to 3 ""I2C"" buses.
Code: | SCL-->pin_C3--mux-> SCL1
-> SCL2
-> SCL3 | |
I'd need to check, but you'd have to ensure that the mux (demux I suppose being pedantic..) keeps the inactive sub-bus clock lines high, I think I2C interprets a clock low as a bus hold? |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Tue Aug 28, 2007 3:29 pm |
|
|
dyeatman's CS looks better, now. I have to admit,.. I was thinking this route, but didn't see the CS line till I looked twice.
Note that the MCP23S17 is SPI not i2c ((this is the one with CS))
Code: |
2 pins -- demux -> CS bank1
-> CS bank2
-> CS bank3
|
|
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Aug 28, 2007 4:20 pm |
|
|
The microchip MCP23017 with 16 ports costs about USD1.58 to USD1.85 at Digikey (depending on package type).
Possible alternatives I found using Google are 20-60 pins from Cypress and a 40 pin expander from NXP.
Does anyone have experience with the Cypress port expanders? These are I2C based devices with up to 60 I/O lines in a single package. Port configuration can be stored into the interal EEPROM eliminating the need to reconfigure the device after each power-up. With up to 127 devices addresses per bus there is no need for multiplexing tricks.
-- The CY8C9520 has 20 expansion I/Os, 3 KB of EEPROM and 4 PWM sources. Digikey 1 piece = USD2.23
-- The CY8C9540 has 40 expansion I/Os, 11 KB of EEPROM and 8 PWM sources. Digikey 1 piece = USD3.26
-- The CY8C9560 has 60 expansion I/Os, 27 KB of EEPROM and 16 PWM sources. Digikey 1 piece = USD5.18
NXP (Philips) has the PCA9505 / PCA9506, a 40 bit I2C port expander. Digikey 1 piece = USD5.40 |
|
![](templates/subSilver/images/spacer.gif) |
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Wed Aug 29, 2007 6:49 am |
|
|
Quote: | 20-60 pins from Cypress |
Nice parts - I especially like the PWM mode. |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed Aug 29, 2007 8:37 am |
|
|
If any of the bus lines are going to be mux'd then pull-up resistors will be needed on both sides of the mux chip. If not, the mux'd side will see an extra pulse signal on that bus line when it is unselected, which will throw things all hay-wire.
I made a project where I wanted to place several SHT15 sensors on the same bus. The address, of these sensors, cannot be changed. So, I muxed the I2C bus and found I needed pull-ups on the master side and on each sensor's bus.
Ronald |
|
![](templates/subSilver/images/spacer.gif) |
Peter273 Guest
|
|
Posted: Mon Sep 03, 2007 4:13 pm |
|
|
Personally I used a 4620 lying around here in a setup using 1 port for databus, 1 port for addresbus, one "read/write" line and one "latch" line to simulate a complete "databus/addressbus with RW-control and datalatch-control". It gave me a full 256 "external ports" which are physically distributed over addon-boards on a proprietary bus, but still leaving me enough "free pins" on the 4620 for pwm-out, rs232, adc etc...
All I needed on the external boards were address-decoders to create the chip-selects for the physical IO chips, the rest was just read-write or latch as needed. |
|
![](templates/subSilver/images/spacer.gif) |
|