Fast I2C connection
hey,
once again need advice
i'm trying interface gy80 10dof breakout. board consists of adxl345 (accelerometer), l3g4200d (gyrometer), hmc5883l (compass) , bmp085 (barometer), need data first 3 sensors (3 axis each).
i have written little library, includes functions initialize , read out sensors (via i2c). far, every thing works fine, can calculate euler angles readings , results fine, but far slow.
it takes around 3ms read out 3 sensors , around 863us read accelerometer (calculations not included, amount fraction of time).
i need sensor time sensitive application , 3ms won't it. don't know limitation of sensor or i2c protocol itself, hoping 500us maximum (is realistic)? way, i'm using arduino due.
this code i'm using:
i think problem comes while loop, i'm using wait until wire buffer reaches desired number of bytes, don't know how change it.
also, thought changing i2c speed.
a third thing came mind using interrupts. think read interrupts occur when there new data read (at least on adxl345). reading registers if there new data in there...
any welcome!
josua
once again need advice
i'm trying interface gy80 10dof breakout. board consists of adxl345 (accelerometer), l3g4200d (gyrometer), hmc5883l (compass) , bmp085 (barometer), need data first 3 sensors (3 axis each).
i have written little library, includes functions initialize , read out sensors (via i2c). far, every thing works fine, can calculate euler angles readings , results fine, but far slow.
it takes around 3ms read out 3 sensors , around 863us read accelerometer (calculations not included, amount fraction of time).
i need sensor time sensitive application , 3ms won't it. don't know limitation of sensor or i2c protocol itself, hoping 500us maximum (is realistic)? way, i'm using arduino due.
this code i'm using:
code: [select]
void imu::readbytes(int deviceaddr, int registeraddr, int numbytes, int16_t buffer[]){
wire.begintransmission(deviceaddr);
wire.write(registeraddr | (1 << (numbytes + 1)));
wire.endtransmission();
wire.requestfrom(deviceaddr, numbytes);
while (wire.available() < numbytes);
for(int = 0; < numbytes; i++){
buffer[i] = wire.read();
}
}
void imu::getacceleration(int16_t* ax, int16_t* ay, int16_t* az){
int16_t buffer[6];
readbytes(acc_address, adxl345_datax0, 6, buffer);
*ax = (buffer[1] << 8) | buffer[0];
*ay = (buffer[3] << 8) | buffer[2];
*az = (buffer[5] << 8) | buffer[4];
}
i think problem comes while loop, i'm using wait until wire buffer reaches desired number of bytes, don't know how change it.
also, thought changing i2c speed.
a third thing came mind using interrupts. think read interrupts occur when there new data read (at least on adxl345). reading registers if there new data in there...
any welcome!
josua
at speed use i2c now?
>>i think problem comes while loop, i'm using wait until wire buffer reaches desired number of bytes, don't know how change it.
put counter in , see how loops. expect 0 time.
which means can remove it.
>>i think problem comes while loop, i'm using wait until wire buffer reaches desired number of bytes, don't know how change it.
put counter in , see how loops. expect 0 time.
which means can remove it.
Arduino Forum > Using Arduino > Sensors > Fast I2C connection
arduino
Comments
Post a Comment