Announcement

Collapse
No announcement yet.

Problem with UCAM-II and continuous take pictures.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with UCAM-II and continuous take pictures.

    Hello.
    Sorry for my english :-)
    I have problem with continuous take pictures.
    Often I have problem with camera initialization but this isn't the biggest problem.
    First picture (in "Setup" section) saved on SD card ok but second breaking in loop:
    PHP Code:
        while (bytes camera.getData() )
        {
          for (
    0bytesx++)
          {
            
    Serial.print("0x");
            
    Serial.print(camera.imgBuffer[x], HEX);
            
    Serial.print(" ");
          } 
    My code:

    PHP Code:
    #include <SPI.h>
    #include <SD.h>
    #include <uCamII.h>

    UCAMII camera;
    File myFile;

    int time1time2time3time4all_time;

    void setup()
    {
      
    Serial.begin(115200); // Arduino IDE Monitor
      
    Serial3.begin(115200); // uCAM-II Default Baud Rate
      // Serial1 is HARDCODED in the uCAM-II library for the Camera  

        
    Serial.println("Initializing SD card...");
        if (!
    SD.begin(53))
        {
          
    Serial.println("SD initialization failed!");
          return;
        }
      
    Serial.println("SD initialization done.");



      
    delay(1000);
      
    time1 millis();

      
    short x 0;
      
    int bytes;

      
    Serial.println("CAMII - inicjalizacja.");
      
    delay(1000);  
      if (
    camera.init())
      {
              
    time2 millis();
              
    Serial.println("CAMII init OK!");
              
    camera.takePicture();
              
    time3 millis();
              
    Serial.print("Image Size: ");
              
    Serial.println(camera.imageSizeDEC);
              
    Serial.print("Number of Packages: ");
              
    Serial.println(camera.numberOfPackages(), DEC);

            
    // open the file. note that only one file can be open at a time,
            // so you have to close this one before opening another.
            
    myFile SD.open("test2.txt"FILE_WRITE);

              if (
    myFile)
              {
              
    Serial.print("Writing to test.txt...");
              while (
    bytes camera.getData() )
              {
                for (
    0bytesx++)
                {
                  
    myFile.print("0x");
                  
    myFile.print(camera.imgBuffer[x], HEX);
                  
    myFile.print(" ");
                }
              }
              
    Serial.println("Done Downloading");
              
    myFile.close();
              
    Serial.println("done.");
              
    time4 millis();
            }
             else
             {
              
    // if the file didn't open, print an error:
              
    Serial.println("error opening test.txt");
            }
      }
      else
      {
        
    Serial.println("Error open CAMII");
      }

      
    all_time = (time2 time1)/1000;
      
    Serial.println(all_time);
      
    all_time = (time3 time2)/1000;
      
    Serial.println(all_time);
      
    all_time = (time4 time3)/1000;
      
    Serial.println(all_time);
    }

    void loop()
    {
      
    short x 0;
      
    int bytes 0;
      
    delay(1000);
    if (
    camera.init())
      {
              
    time2 millis();
              
    camera.takePicture();
              
    time3 millis();
              
    Serial.print("Image Size: ");
              
    Serial.println(camera.imageSizeDEC);
              
    Serial.print("Number of Packages: ");
              
    Serial.println(camera.numberOfPackages(), DEC);

              
    all_time = (time3 time2)/1000;
              
    Serial.println(all_time);

        while (
    bytes camera.getData() )
        {
          for (
    0bytesx++)
          {
            
    Serial.print("0x");
            
    Serial.print(camera.imgBuffer[x], HEX);
            
    Serial.print(" ");
          }
          
    Serial.println("");
        }
        
    Serial.println("Done Downloading");
      }

    Can I plese for help?

  • #2
    magicmarcus,

    There is a bug in the uCAM-II library which make taking pictures continuously impossible. Attached is the modified uCAM-II Library which is hardcoded to work with Serial Port 1 of
    the Arduino MEGA 2560. You can test it with your code above. The problem is in the camera.getData()

    Best regards,
    Attached Files

    Comment

    Working...
    X