Pages: [1]   Go Down
Author Topic: Two simultaneus I2C communication  (Read 1116 times)
0 Members and 1 Guest are viewing this topic.
M
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Discovering Arduino...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

I'm working on a project where i connect LEGO Mindstorms NXT robot with Arduino usin the I2C protocol. And i want also to connect some sensors to the Arduino board, so it will be something like this: Mindstorms <--> Arduino <--> Sensor.

I want Arduino to be the slave in the communicaction with the robot, and to be the master in the communication with the sensors. Is this possible? Can i do both simultaneously?

I know that for I2C communication i have to use the pins 4 and 5 of the analog input, and i'm using Arduino MEGA board.

Thanks a lot (and i apologise for my english, it's not perfect).
« Last Edit: January 12, 2011, 05:10:35 am by cstockmans » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 626
Posts: 34172
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is this possible?

The I2C specification does cater for multi master bussed. So in theory it is.

However there are two snags:-
1) I don't know of any multi master software.
2) The Lego uses a 3v3 I2C bus and the sensors might need a 5V bus so you will need some hardware bus level shifters.

Quote
Can i do both simultaneously?
You can do nothing simultaneously on a single processor, you do them sequentially very fast so it looks like simultaneously.

Quote
I know thath for I2C communication i have to use the pins 4 and 5 of the analog input,
It is not those pins on a mega it is pins 20 & 21
« Last Edit: January 12, 2011, 05:07:05 am by Grumpy_Mike » Logged

M
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Discovering Arduino...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your answer smiley

Quote
You can do nothing simultaneously on a single processor, you do them sequentially very fast so it looks like simultaneously.

Yes, you're right. Is what i wanted to say: first Arduino is the slave and receives instructions from de Mindstorm, and then is the master for the sensors, sending the instructions to them. It's not simulatenous.

Quote
It is not those pins on a mega it is pins 20 & 21

Oooops! I was confused because i've just been reading about the Arduino Duemilanove board. Thanks!
Logged

Florida, US
Offline Offline
Newbie
*
Karma: 0
Posts: 7
:-)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The arduino can be a slave and a master at the same time. Also the arduino supports multi masters on the same bus.
The big question: dose the mind storm support multi masters.
It is worth a try.
Logged

M
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Discovering Arduino...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Mindstorm doesn't support multi masters. I think i'm going to do this using software I2C, using two analog pins of Arduino to communicate with the sensors, and the two I2C pins to communicate with the robot.
Logged

Florida, US
Offline Offline
Newbie
*
Karma: 0
Posts: 7
:-)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One trick my be to poll your slave just after the mind storm polls you.
The thought process is that the mind storm polls it's slave (your arduino) in a regular cycle. If the bus is idle just after the poll, you may have time to poll your slave.
Logged

Worcester, MA
Offline Offline
God Member
*****
Karma: 3
Posts: 623
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
2) The Lego uses a 3v3 I2C bus and the sensors might need a 5V bus so you will need some hardware bus level shifters.

Actually you can use this snag to your advantage.  Since you'll need a level shifter use an IC like a TXS0102 that has an output enable pin.  Once the mindstorm is done communicating with the Arduino, drive the output enable LOW and force the bus between the mindstorm and Arduino into a Hi-Z state.  If the mindstorm tries to poll the Arduino it won't get a response and will leave you free to communicate with the rest of the sensors.  Just make sure the sensors are all wired downstream of the level shifter.  Also if the sensors can handle Fast Mode (400kHz) bump up the I2C speed when communicating with them, that should minimize timing concerns.
Logged

I2C GPS Shield

Checkout my Open Source GPS Tracker on Kickstarter

M
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Discovering Arduino...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to both smiley

Quote
One trick my be to poll your slave just after the mind storm polls you.

That's an option that i was thinking about, but i'm not shure if it will works. I will try it smiley

Quote
ally you can use this snag to your advantage.  Since you'll need a level shifter use an IC like a TXS0102 that has an output enable pin.  Once the mindstorm is done communicating with the Arduino, drive the output enable LOW and force the bus between the mindstorm and Arduino into a Hi-Z state.  If the mindstorm tries to poll the Arduino it won't get a response and will leave you free to communicate with the rest of the sensors.  Just make sure the sensors are all wired downstream of the level shifter.  Also if the sensors can handle Fast Mode (400kHz) bump up the I2C speed when communicating with them, that should minimize timing concerns.

It's another good option smiley Thanks!
Logged

Pages: [1]   Go Up
Jump to: