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


    • #3
      Noel I can't download the file you have attached to your response. Could you upload it again?

      Thanks.

      Comment


      • #4
        Hello,

        Welcome to the forum.

        I have just sent you a private message.

        Best regards

        Paul

        Comment


        • #5
          Originally posted by pauleilio View Post
          Hello,

          Welcome to the forum.

          I have just sent you a private message.

          Best regards

          Paul
          Thanks Paul. Unfortunately, it didn't help my case. I'm trying to make a few snapshots (the next one after receiving the current one). The problem is, that even if I send the final ACK (AA 0E 00 00 F0 F0), then on the next request (AA 05 00 00 00 00) the camera module response is AA 0E 04 03 00 00 instead of AA 0E 05 xx 00 00. Sp, it looks like I can only get the same snapshot every time.

          Is there a different application flow for taking different snapshots every x seconds instead of 8.3.1 from documentation?

          Comment

          Working...
          X