Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: rbtying on August 10, 2010, 09:24:50 PM

Title: I2C Slave for Arduino Duemilanove
Post by: rbtying on August 10, 2010, 09:24:50 PM
Dear All,
    I am looking to offload the sensor processing logic away from my main uC (Arduino).  I want to communicate with the sensor board as an I2C slave, with the main uC as an I2C master.  For ease of configuration, I'd like something arduino-compatible, but it's not necessary.  My question is, what is the best uC for the slave, cost and functionality wise?  I know buying another arduino would work, but it's a little costly.  I do have access to a number of Cypress PSoC's, so if any of you know how to wire and program those for I2C, it would be a no-cost solution.

Thanks in advance,
Title: Re: I2C Slave for Arduino Duemilanove
Post by: Soeren on August 10, 2010, 09:30:02 PM
Hi,

I do have access to a number of Cypress PSoC's, so if any of you know how to wire and program those for I2C, it would be a no-cost solution.
The datasheet should tell you, but if you feel up to it, you can bit bang IIC as well (with any controller).
Title: Re: I2C Slave for Arduino Duemilanove
Post by: rbtying on August 10, 2010, 09:56:41 PM
Well... part of the problem with the PSoC is that the entire architecture is designed to act almost like an FPGA, so you'd have to configure the parts within the uC as well (adc, timers, etc), and I haven't learned how to do much more than blink an LED yet.  Also, for bitbanging I2C, isn't there an issue with the bitrate? 

I would use SPI with the PSoC, but I'm short pins on the Arduino, and sacrificing a bunch to a communication protocol defeats part of the reason I'm transferring the board out.  Also I hear that Arduino has a library for ridiculously easy I2C, which would be nice =). 

Thanks anyways.
Title: Re: I2C Slave for Arduino Duemilanove
Post by: Soeren on August 10, 2010, 10:12:27 PM
Hi,

SPI or IIC, both needs 2 lines.

But then go for another controller - won't set you back more than $1 to $3, depending on your choice.

Alternatively, you could use PCF8574, which is an IIC 8 bit I/O port expander with the optional feature of an interrupt signal on any I/O port changing status (0/1 or 1/0).
PCF8574 is adressable on 3 pins, so you can use up to 8 of them on the same bus and hence get up to 64 I/O lines for an outlay of 2 I/O lines on the controller.
Title: Re: I2C Slave for Arduino Duemilanove
Post by: rbtying on August 10, 2010, 10:15:07 PM
Recommend a controller?  I'm tempted to get another ATMega328 because that's what the Arduino uses, but I don't have the accompanying Vregs and such.  Perhaps the RBBB?

I had though that SPI needed an enable line?  Thus 2 lines + 1 per slave?

PCF8574 sounds useful, but I'm looking to get separate processing power, so I can have it scan and move without taking a processing hit.  (Mapping is hard on 2kb RAM)
Title: Re: I2C Slave for Arduino Duemilanove
Post by: Soeren on August 10, 2010, 10:32:16 PM
Hi,

Recommend a controller?  I'm tempted to get another ATMega328 because that's what the Arduino uses, but I don't have the accompanying Vregs and such.  Perhaps the RBBB?
I don't know what you mean with "RBBB"?
It would make sense to use an AVR, as you are allready into that one and so you have the software tools for it. Which member of the family to select must be based in what you need of it (speed, I/O count and onboard peripherals), so only you can make that decision.

A voltage regulator and the "glue" needed is dirt cheap, so don't let that stop you.
There's an Indian business selling Arduiono clones (very cheap), perhapws that would be a viable route (they're not as cheap as if you bang something together yourself of course).


I had though that SPI needed an enable line?  Thus 2 lines + 1 per slave?
My Bad, you need a clock line as well - sorry for the misinformation  :-[


PCF8574 sounds useful, but I'm looking to get separate processing power, so I can have it scan and move without taking a processing hit.  (Mapping is hard on 2kb RAM)
Well, then the port expander won't do.
Title: Re: I2C Slave for Arduino Duemilanove
Post by: rbtying on August 11, 2010, 12:00:12 AM
Thanks, I'll probably get an ATMega328 or something...  Can they be programmed with the Arduino board?  (The built-in STK500)?

The RBBB is an arduino clone with pretty much just the parts that are needed and a normal PCB, ie, really-bare-bones-board.  It's 12 bucks, kit, so I may get that. 
(http://cdn.shopify.com/s/files/1/0038/9582/products/RBBB_Assembled_1_grande.jpg?1281262404)