C3088 Camera Sensor + Arduino

Hello everybody,

I’m doing a project that captures images from the camera C3088 to a resolution of 88x72 pixels. The camera is handled perfectly from IC2 and low clock speed to the minimum speed 69.25 KHz. The data are sent directly to processing for viewing and perform the testing.

The control and image capture is done but not perfectly synchronized with the presentation of the picture, I get blurred or striped always something wrong with me the synchronization of data capture.

Someone to do something similar project? The timing could be bad for sending data through the serial port? someone could help me or give an idea? is posible the proyect?

The project is similar to: Digital Project -- Digital Camera Interface

I leave with you the code and all data.

Thank you very much.

// I2C
#define SYSCLK 16

// PINES DEL 0 AL 7
#define PORTY PORTD
#define PINY PIND
#define DDRY DDRD

// PINES DE CONTROL
#define PCLK 10
#define HREF 11
#define VSYN 12

// REGISTROS DE LA CÁMARA
#define camAddRead 193
#define camAddWrite 192
#define camRegClock 0x11
#define camRegControlA 0x12
#define camDatReset 0x80
#define camDatbarras 0x26
#define camDatEspejo 0x40
#define camDatEspejoNo 0xBF // repasar
#define camDatFrecLo 0x10
#define camDatFrecMed 0x01 //medio AC
#define camDatFrecMed2 0x3F //medio AC
#define camDatFrecUp 0x00

#define camRegControlC 0x14
#define camDatQCIF 0x20

// VARIABLES ************************************************************************

byte pixels[8];

// FUNCIONES ************************************************************************

void cameraIni(){
  //DDRY = 0x00;
  //DDRD = (DDRD & 0xE3);
  
  pinMode(PCLK, INPUT);
  pinMode(HREF, INPUT);
  pinMode(VSYN, INPUT);
  for(int i = 2;i<=9;i++) pinMode(i, INPUT);
  
  
  // resetear camara
  //write_register(camRegControlA, camDatReset);
  delay(1000);
  // min frec: 69,25KHz
  write_register(camRegClock, camDatFrecLo);
  // QCIF
  write_register(camRegControlC, camDatQCIF);
  // se muestran barras de color
  //write_register(camRegControlA, 0x26);
  
  
}

void photo(void){
  // QCIF 176x144
  // CIF  352x292

        // NEW FRAME
          while(digitalRead(VSYN));
        while(!digitalRead(VSYN));
          for(int y = 0;y<40;y++){ //lineas que quiero leer

            // NEW LINE
            
            while(!digitalRead(HREF));
        
              for(int r = 0;r<176;r++){ //longitud de una linea
          
                 // PIXEL OK
                 while(digitalRead(PCLK));
               while(!digitalRead(PCLK));
          
                 // READ 8 PINS AND MAKE A BYTE
                 byte sdd=0;
                 for(int i = 9;i>=2;i--){
                   sdd |= digitalRead(i); //LEO PATILLA
                   if (i>2) sdd <<= 1; //LA DESPLAZO UN BIT A MENOS QUE SEA LA ULTIMA
                 }
                 
                 // SEND DE DATA BY SERIAL PORT
                 Serial.print(sdd, DEC);
                 Serial.print("P");
            }
            while(digitalRead(HREF));
          }
  Serial.println();
}


// SETUP ************************************************************************

void setup(){
  Serial.begin(115200);
  
  i2c_init(SYSCLK);
  cameraIni();
}


// LOOP ************************************************************************

void loop(){
  photo();
  delay(1000);
}

Hello, I am interested in doing exactly the same thing. Could you please drop me a line at zonkyu@gmail.com

I've now all the components and I will try your code. Have you fixed the problems you had?

cheers fabrizio

I hate to tell you this, Vincent, but the original poster of this thread hasn't made a forum post in nearly an entire year. You are extremely unlikely to get a response this way. You should e-mail him directly and hope for the best.

Hello!! Vicent…

Well unfortunately I did not have to complete the project. The control registers of the camera are done perfectly, but I have not managed to capture good images, and then sent to software Processing.

The latest to hit this code is below.

Good luck if you continue with this, because if there are people who do so, it must be possible.

Un saludo.

*sorry for the spanish coment…

/*
 PINY son 8 pines controlados de golpe para leer 8 bites. en arduino 
 serian B del 8 al 13, C los analogicos y D del 0 al 7

va sacando bytes (8) de golpe de 352x244
tengo que pasar de leer datos para una matriz mas pequeña
y mirar el tamaño minimo que da la camara QCIF 176x144

0xC0 (192) for writing and 0xC1 (193) for reading

 *  Arduino analog input 5 - I2C SCL
 *  Arduino analog input 4 - I2C SDA

 */

// INCLUDES ************************************************************************



// DEFINES ************************************************************************

// I2C
#define SYSCLK 16

// PINES DEL 0 AL 7
#define PORTY PORTD
#define PINY PIND
#define DDRY DDRD

// PINES DE CONTROL
#define PCLK 10
#define HREF 11
#define VSYN 12

// REGISTROS DE LA CÁMARA
#define camAddRead 193
#define camAddWrite 192
#define camRegClock 0x11
#define camRegControlA 0x12
#define camDatReset 0x80
#define camDatbarras 0x26
#define camDatEspejo 0x40
#define camDatEspejoNo 0xBF // repasar
#define camDatFrecLo 0x10
#define camDatFrecMed 0x01 //medio AC
#define camDatFrecMed2 0x3F //medio AC
#define camDatFrecUp 0x00

#define camRegControlC 0x14
#define camDatQCIF 0x20

// VARIABLES ************************************************************************

byte pixels[8];

// FUNCIONES ************************************************************************

void cameraIni(){
  //DDRY = 0x00;
  //DDRD = (DDRD & 0xE3);
  
  pinMode(PCLK, INPUT);
  pinMode(HREF, INPUT);
  pinMode(VSYN, INPUT);
  for(int i = 2;i<=9;i++) pinMode(i, INPUT);
  
  
  // resetear camara
  //write_register(camRegControlA, camDatReset);
  delay(1000);
  // min frec: 69,25KHz
  write_register(camRegClock, camDatFrecLo);
  // QCIF
  write_register(camRegControlC, camDatQCIF);
  // se muestran barras de color
  //write_register(camRegControlA, 0x26);
  
  
}

void photo(void){
  // QCIF 176x144
  // CIF  352x292

        // NEW FRAME
          while(digitalRead(VSYN));
        while(!digitalRead(VSYN));
          for(int y = 0;y<40;y++){ //lineas que quiero leer

            // NEW LINE
            
            while(!digitalRead(HREF));
        
              for(int r = 0;r<176;r++){ //longitud de una linea
          
                 // PIXEL OK
                 while(digitalRead(PCLK));
               while(!digitalRead(PCLK));
          
                 // READ 8 PINS AND MAKE A BYTE
                 byte sdd=0;
                 for(int i = 9;i>=2;i--){
                   sdd |= digitalRead(i); //LEO PATILLA
                   if (i>2) sdd <<= 1; //LA DESPLAZO UN BIT A MENOS QUE SEA LA ULTIMA
                 }
                 
                 // SEND DE DATA BY SERIAL PORT
                 Serial.print(sdd, DEC);
                 Serial.print("P");
            }
            while(digitalRead(HREF));
          }
  Serial.println();
}


void photo2(void){
  // QCIF 176x144
  // CIF  352x292
  long cont=0;
        // NEW FRAME
          Serial.print("A");
          while(digitalRead(VSYN)==LOW);
          Serial.print("B");

          while(digitalRead(VSYN)==HIGH);
          Serial.print("C");

          while(digitalRead(VSYN)==LOW){
            //while(!digitalRead(HREF));
            // EL WHILE CON HREF NO FUNCIONA  MIRAR CABLES!!!!!!!!!!!!!!!!
            while(digitalRead(HREF)==HIGH){
              while(digitalRead(PCLK)==HIGH);
              while(digitalRead(PCLK)==LOW);
              cont++;
              Serial.println(cont);
            }
             Serial.print("*****************"); 
            while(digitalRead(HREF)==LOW);
            
          }
          
          
            // NEW LINE
          /*  
            while(!digitalRead(HREF));
        
              for(int r = 0;r<176;r++){ //longitud de una linea
          
                 // PIXEL OK
                 while(digitalRead(PCLK));
               while(!digitalRead(PCLK));
          
                 // READ 8 PINS AND MAKE A BYTE
                 byte sdd=0;
                 for(int i = 9;i>=2;i--){
                   sdd |= digitalRead(i); //LEO PATILLA
                   if (i>2) sdd <<= 1; //LA DESPLAZO UN BIT A MENOS QUE SEA LA ULTIMA
                 }
                 
                 // SEND DE DATA BY SERIAL PORT
                 Serial.print(sdd, DEC);
                 Serial.print("P");
            }
            while(digitalRead(HREF));
          */
            
         
  Serial.print(cont);
    
  Serial.println();
}


// SETUP ************************************************************************

void setup(){
  Serial.begin(115200);
  
  i2c_init(SYSCLK);
  cameraIni();
}


// LOOP ************************************************************************

void loop(){
  photo2();
  delay(4000);
}

Hi Motiv, Thank you for your reply. I am working on it right now. I will start from your code and see where I can get.

if there is anybody interested in this please contact me cheers fabrizio

I'm interested and purely out of curiosity to see what you come up with.

I'd read somewhere that Arduino isn't powerful enough to do it's own image processing so sending the image data to a computer to be processed is a good approach.

There would be a number of recognition applications that could be useful to other developers so I think it would be yet another terrific addition to Arduino's capabilities.

Anything you can make Arduino do that it hasn't done before, especially if it doesn't cost very much, is a good thing = )