CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Reading a lot of digital I/O.....

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Reading a lot of digital I/O.....
PostPosted: Mon Aug 27, 2007 7:15 pm     Reply with quote

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
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Mon Aug 27, 2007 9:37 pm     Reply with quote

My favorite trick: I2C I/O expanders such as PCA9671.
_________________
Read the label, before opening a can of worms.
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Aug 28, 2007 5:45 am     Reply with quote

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.
Guest








PostPosted: Tue Aug 28, 2007 8:29 am     Reply with quote

have a look to I2C 16-I/O Ports Expander MCP23017 from Microchip.

Nilsener
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Aug 28, 2007 8:30 am     Reply with quote

As above, Microchip port expanders work well.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Tue Aug 28, 2007 1:51 pm     Reply with quote

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.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Aug 28, 2007 3:22 pm     Reply with 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 guess multi I2C buses can be done....
Look at rcurl and @@sda
http://www.picbasic.org/forum/showthread.php?t=3899
http://www.fairchildsemi.com/ds/CD/CD4051BC.pdf


Last edited by treitmey on Tue Aug 28, 2007 3:48 pm; edited 5 times in total
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Aug 28, 2007 3:22 pm     Reply with quote

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.
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Aug 28, 2007 3:27 pm     Reply with quote

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?
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Aug 28, 2007 3:29 pm     Reply with quote

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
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Aug 28, 2007 4:20 pm     Reply with quote

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
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Aug 29, 2007 6:49 am     Reply with quote

Quote:
20-60 pins from Cypress


Nice parts - I especially like the PWM mode.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Aug 29, 2007 8:37 am     Reply with quote

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
Peter273
Guest







PostPosted: Mon Sep 03, 2007 4:13 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group