Main Site Documentation

I2C is slow


#1

Hi!

We’ve just bought a Fez Panda II and are just getting things to work.

One thing we’re wondering about is the time it takes to to an I2C-read, it takes 1.5-1.6 ms for each read, for 2 bytes of data.

Is it really supposed to take that long time? In that case we have to rethink our robot.


#2

If you haven’t looked at it yet - check RLP.


#3

If you can read multiple bytes then it will be faster


#4

Invoking RLP takes too long.

We’re reading 2 bytes and would like to do that in a fraction of a millisecond preferably, would SPI be a faster alternative?


#5

I2C depends on the selected clock.
SPI can operate faster than I2C (generally speaking).

For 2 bytes of data, I think none will be fast enough in .NET MF.

Try to be more precise on what you are trying to do. There could be other solutions.


#6

This is problematic for me as well as I am need a sample frequency of at the very least 2 kHz with the ADXL345. I was able to get this with using an anolog sensor but the I2C is another beat.

I suspect reading this that 2 kHz is not possible?


#7

I think it is possible to read the values via SPI at 2 KHz.
The question is what are you planning to do with the data after you read it?
What board are you using? Does it support RLP? I’m not sure you can sample the sensor readings at 2KHz from managed code.


#8

Thanks Godfather.

Actually I am using the FEZ panda II and writing it is an SD card. The device will be mounted outside and be running for about a week recording data when vibrations exceed a certain range. I have a few problems that are mostly due to the hardware limitations.

Using analog sensors I was writing the data to a jagged array and then dumping the data when it reached a certain memory threshhold. The prblem is this was 250 x,y,z, time stamp data sets and far to little at 2kHz to be useful.

I decided to use digital sensors for 2 reasons: Less noise and the ability to have more sensors. My advisor want two sensors now and this means I2C as analog will not cut it. Unless I can find a board with 6 analog inputs.


#9

I see it supports RLP. I would use a Timer in RLP to read the samples and write them to a buffer. Once the buffer is full, trigger an event to the managed side and write the buffer to the file. I guess it would be fast enough.


#10

We’re building a robot. We have two quadrature rotary encoders for the wheels which are handled by a PIC, the Panda then has to poll the encodervalues from the PIC to make adjustments on the speed of the motors. To go as straight as possible we’d like to do this around 250 times per second.

The PIC has some alternatives to using i2c, such as SPI and UART. As of now we’re running I2C at 400KHz

The polling would probably go faster by running i2c in RLP yes, but there is no fast way of getting the data from the RLP side to the managed side then, is there?


#11

How fast do you think you could read i2c from RLP?


#12

Things get fast only when you use large chunks instead of single bytes.