Go Down

Topic: Using Wire Library for Interfacing a camera-module (Read 1 time) previous topic - next topic

maxwellMuc

Hi together,

i want to interface this camera-module with the arduino:
http://www.sparkfun.com/datasheets/Sensors/Imaging/TCM8230MD.pdf
I don't want to read out the pictures with the Arduino, just want to communicate via I²C and set up the camera, so it sends out its pictures.
But now i'm a bit confused about how to adress the camera. The datasheet tells me the internal addresses of the registers, where i can set up the settings like frame rate etc...
But don't i have to addrres the camera as a slave first? I am very confused on how to address an internal register of the cam with the Wire Library...

Thank you very much,
Max

robtillaart

step 1: Google I2Cscanner Arduino and you will find an app to retrieve the device ID.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

maxwellMuc

#2
Apr 09, 2011, 05:23 pm Last Edit: Apr 09, 2011, 05:38 pm by maxwellMuc Reason: 1
Hi robtillaart,

thanks for that! i scanned and found address 60, which corresponds quite well to the datasheet of the camera, saying 0b0111000 is the address!
So, how can i go on? I now used the following code, but the return value is 3, which is "received NACK on transmit of data":
Code: [Select]

Wire.beginTransmission(60); 
    Wire.send(0x03);                // sends one byte 
    Wire.send(0x00);                // sends one byte 
    Wire.endTransmission();      // stop transmitting


Cheers,
Max

maxwellMuc

Now i also tried the i2cmaster-library of peter fleury, using this code:
Code: [Select]
#include <i2cmaster.h>

void setup()
{
   i2c_init();
   Serial.begin(9600);
   //digitalWrite(13,1);
   byte ret = i2c_start(120);     // set device address and write mode
   Serial.write(ret); 
   //digitalWrite(13,0);
   ret = i2c_write(3);                        // write address = 5
   Serial.write(ret);
   ret = i2c_rep_start(120);
   Serial.write(ret);
   ret = i2c_write(0x00);                        // write address = 5
   Serial.write(ret);
   ret = i2c_write(0x02);                        // write address = 5
   Serial.write(ret);
   ret = i2c_write(0x00);                        // write address = 5
   Serial.write(ret);
   i2c_stop();
}

void loop()
{

}


And the message i receive is "010111", so that means the start-functions work and the write-functions don't?! How could that be?

robtillaart

the number 120 and 60 comes from the fact that the device number is seven bit and the Arduino wants to send eight. The trick used is to shift the device number one bit (effectively a factor 2)

Quote
i2cmaster-library of peter fleury

Don't know that one
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

maxwellMuc

yes, i already noticed that, so i guess the adressing of the slave-adress is no problem any more. But why does the sending of data do not work?! Could it be a hardware-problem?

Go Up