Pages: [1]   Go Down
Author Topic: I2C Based Robotics Library  (Read 409 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 I am trying to develop a robotics Library which has I2C at its core. I am wondering if it was a smart idea. Also I am trying to implement my framework on Arduino but I am running into issues with Wire.endTransmission() hanging.
I am writing to get opinions on the basis of my robotics framework and the fact that it relies and probably over-estimates the capability of I2C.
I have written a paper describing the framework and I have sample code of me trying to make it work on Arduino. the paper can be found here: http://cl.ly/3K3t2y112I1a (6 pages)
The code has two libraries. I called the project the X10ABOT robotics framework. You can perues the code on github here:
Motherboard Project: https://github.com/frazras/X10ABOT_MB
Daughterboard Project: https://github.com/frazras/X10ABOT_DB

You can test the code on two separate Arduinos with these simple sketches:
MB Sketch: http://cl.ly/070r3c290L2f
DB Sketch: http://cl.ly/3j38120u170y

Hope this is not too much.
Looking forward to hearing your opinion/views on the approach I took as well as how I am using the TWI Library within the X10ABOT Library. I would appreciate it immensely.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18794
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am wondering if it was a smart idea.

Why are you wondering this? The Wii uses I2C for its nunchuk. The Lego Mindstorms robot uses I2C to communicate with its various peripherals. The protocol itself therefore seems to be well-established.
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18794
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

From your paper:

Quote
The I2C protocol does not allow for slave devices to initiate any communication, but this is necessary for managing sensors, and some actuators on a peripheral module. So the second component of the peripheral bus comprises an RS-232 serial line to allow a module to signal an interrupt service request (ISR) to the motherboard.

However multiple devices can become masters. So they can in fact initiate communication.

My example on this page shows that: http://www.gammon.com.au/i2c
Logged


nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 127
Posts: 8517
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting and close to one of my fields, IE monitoring and control networks.

A couple of questions.

Quote
There are also measures to handle simultaneous acquisitions based on a priority system where daughterboards with higher priority, determined by their proximity to the motherboard on the bus, would have priority access to the bus
Can you explain how you implement this?

Quote
The power and ground pins provide electrically isolated power for the sensors
Using isolated DC/DC converters?

______
Rob
« Last Edit: March 04, 2013, 07:23:47 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Why are you wondering this?
I am wondering this because I say that the framework can manage up to 112 (based on the specification)slave devices(daughterboards)  but each of my daughterboards can support tens of sensors and actuators. Practically speaking, is the I2C protocol able to practically handle all that traffic if it were ever to be fully utilized without an apparent lag.

Quote
However multiple devices can become masters. So they can in fact initiate communication.
Because all daughterboards will perhaps have to initiate communication at one point or the other, that would mean all daughterboards would have to be masters as well. Is that a reasonable and practical implementation on the protocol, 15 devices on the same I2C bus, where all are masters.

Quote
There are also measures to handle simultaneous acquisitions... Can you explain how you implement this?
To be honest, I'm just starting to implement it now, but theoretically, based on fig. 2 in the paper, if two daughterboards pull the arbitration line low, current will take the shortest route to ground. So strictly speaking its the daughterboard closest to the source that get control of the line, there will be checks from each to verify that it has control.

Quote
Quote
The power and ground pins provide electrically isolated power for the sensors
Using isolated DC/DC converters?

I guess that should have been worded to say physically isolated. The power supplies would be physically separate, however, the dc/dc converters sounds like a good idea.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 127
Posts: 8517
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Practically speaking, is the I2C protocol able to practically handle all that traffic if it were ever to be fully utilized without an apparent lag.
Potentially 1000s of sensors, the short answer is no but that depends on what "apparent lag" you are happy with and how busy these sensors are going to get.

I can't find your frame size now but you could multiply that by the speed, number of sensors that need to be handled and add maybe 10% for overheads to get a rough idea of the average latency. Then decide if that's good enough.

As the daughter boards are smart they only need to report if there's something to say so I2C should easily handle 15 I would think, as long as they don't all have something to say all the time. You also have quite a lot of overhead in the "interrupt" procedure that needs to be taken into account.

I've not used I2C so can't comment on the viability of having 15 or more masters.

Quote
if two daughterboards pull the arbitration line low, current will take the shortest route to ground. So strictly speaking its the daughterboard closest to the source that get control of the line, there will be checks from each to verify that it has control.
This is not correct and a major problem with the protocol IMO.

While at some quantum level one signal may change at a different time to another 6" away on the same wire there will be no discernible difference to you using microprocessors.

This sort of scheme is very prone to race conditions and the longer you take to test the worse it gets. For example using standard Arduino functions

if (digitalRead(arbitration_pin) == HIGH) {
     digitalWrite(arbitration_pin, LOW)
}

will take quite a long time to execute and if two or more slaves are doing it at the same time they may ALL think they have control. If this happens your RS-232 drivers will not be happy and the data will be corrupted.

Using something like RS-485 wired correctly will solve the unhappy driver problem when there's a clash but not the underlying race conditions and resultant corrupted data.

That's my 2c worth anyway smiley

_______
Rob


Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18794
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Somebody had a post a while back about a lot of daughter boards using I2C. ( http://arduino.cc/forum/index.php?topic=61643 )

Quote
if two daughterboards pull the arbitration line low, current will take the shortest route to ground

Yes, but it is travelling at the speed of light. I doubt you could detect that.

A prioritized system is what I understand you can get from CANBUS, however I haven't used it yet.

Quote
each of my daughterboards can support tens of sensors and actuators. Practically speaking, is the I2C protocol able to practically handle all that traffic if it were ever to be fully utilized without an apparent lag

I think you need to define stuff here. How many sensors / actuators? How often do they need to give a reading / be turned on? How do you define "apparent lag"?

For example: "there will be 30 sensors, which give a reading each every 10 mS. I need to be able to handle that reading within 200 uS."

The Mindstorms system uses I2C, I don't know if they poll or have multiple masters. If you didn't have too many daughterboards you could have a "I have data" separate line (for each) perhaps going through a shift register or port-expander. Then the daughter asserts that line when she has something to say and the master asks what this new data is. Or just a periodic poll, perhaps. The master could poll (or respond to this line) in a priority order which you determine.

Logged


Pages: [1]   Go Up
Jump to: