Announcement

Collapse
No announcement yet.

New uCam-II Arduino library

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

  • #16
    I try as you suggested i hook up the ucam-ii using mega hardware serial and change the code accordingly. but the output is garbage on the serial monitor. attached is the code with output.
    Attached Files

    Comment


    • #17
      I have also done some changes in the library the .cpp and .h files as well files are attached as follow.

      Any suggestions?


      Attached Files

      Comment


      • #18
        Well to me it looks like you are talking to the Camera at 115200, and the Arduino IDE monitor at 57600, yet you have the monitor set to 115200.
        Change the monitor serial port (Serial0) to be 115200 in code, or change the monitor to be 57600 to match what you have in code, and try again.
        James

        Comment


        • #19
          Nothing much changes still some kinda garbage as output

          Comment


          • #20
            ah looking at this closer, I see more problems.

            You are writing stuff which I think you were meaning for the Serial Monitor, to Serial1. Should be to Serial.

            Camera is connected to Serial1. So all your Serial1.prints to the Serial Monitor should be going to Serial, not Serial1.
            James

            Comment


            • #21
              Click image for larger version

Name:	2015-10-13_18-08-40.png
Views:	61
Size:	74.4 KB
ID:	48701


              Not very easy to show you what is wrong as you have only pasted your code as images, not as text.
              All of those marked with an arrow are wrong. They should be going to Serial, not to Serial1.
              Serial1 is your camera.
              Serial is your Serial Monitor on Arduino IDE

              Also I assume your camera is set to use 115200? If not, you need to change Serial1.begin() at the top to use the baud rate it is set to by default. Which is likely 9600 until you change it.
              Serial1.begin() needs to match the baud rate you are using on the Arduino IDE's serial monitor.

              Seems you have got things all crossed over.
              James

              Comment


              • #22
                After changes getting something now, but its not going any further
                Attached Files

                Comment


                • #23
                  Looking at the library now, it seems to be hard coded to use Serial (Serial0) for the camera, and your debug serial you have now made Hardware serial. So its still not written correctly for your setup.

                  You need to change the library to use Serial for debug, and use Serial1 for the camera.

                  In the library, it should be something like this:

                  Code:
                  int UCAMII::attempt_sync() 
                  {
                    int attempts = 0;
                    byte cam_reply;
                    int ack_success = 0;
                    int last_reply = 0;
                  
                    while (attempts < 60 && ack_success == 0) 
                    {
                      // Flush
                      while (Serial1.available());
                      delay(200);
                  #ifdef cameraDebugSerial
                      this->debugSerial->println("Sending SYNC...");
                  #endif
                      for (int i = 0; i < 6; i++) 
                      {
                        Serial1.write(_SYNC_COMMAND[i]);
                      }
                  
                      if (this->wait_for_bytes(_SYNC_ACK_REPLY) ) 
                      {
                        if (this->wait_for_bytes(_SYNC_ACK_REPLY_EXT)) 
                        {
                          delay(50);
                  #ifdef cameraDebugSerial
                          this->debugSerial->println("\r\nSending FINAL SYNC...");
                  #endif
                          for (int i = 0; i < 6; i++) 
                          {
                            Serial1.write(_SYNC_FINAL_COMMAND[i]);
                          }
                          return 1;
                        }
                      }
                    }
                    return 0;
                  }
                  But I have never used this library so there is likely more to change.
                  All the debug stuff should ideally be changed to be more readable, and be Serial. Its very hardcoded so best to just make it all hardcoded using Serial and Serial1 accordingly, for your purposes.
                  James

                  Comment


                  • #24
                    I remove the serial1 and connect the camera to serial(serial0) and keep the library same as i already uploaded.
                    this is my output now.
                    Any thoughts on this
                    Attached Files

                    Comment


                    • #25
                      Well you are part way there, but you cant write Serial.print stuff to the same serial port as what you will be writing to the camera, as the camera cannot understand what you write in plain text.

                      Just hacking this library, give me a few minutes.

                      Remember, this is not our library, we didnt write it.
                      James

                      Comment


                      • #26
                        oh thats not your library. I was thinking its your new library thats why i was trying to work it on. Kindly if you have the arduino code along with your library provide it to me and i will work on it.

                        Comment


                        • #27
                          4D does not have a library for the uCAM-II to an Arduino. The library was provided by a customer.
                          This is a modification of the library in the first post of this thread from another Customer. I have changed it forcing the Camera on to Serial1 using 57600 baud, and Debug output to Serial so it goes to the Arduino IDE monitor at 57600 baud.

                          Attached is my output, along with the modified library and the demo I tried. Demo is located inside the library.

                          See if that works for you.
                          Again - this is NOT our library. Very difficult for us to support something that we didnt write.

                          Regards
                          Attached Files
                          James

                          Comment


                          • #28
                            Debug off in this output, looks more usable
                            Attached Files
                            James

                            Comment


                            • #29
                              Thanks for the modified library and demo. I tried it out and it seems working for me at last.
                              How can i convert the hex code to image to check whether the output is correct or not

                              Comment


                              • #30
                                Again... we didnt write the library...

                                In the github from the guy that did, he has a hex-to-bytes.py file.
                                That looks to make a JPEG from the hex.
                                How to use it, I have no idea.

                                You are best to contact the author.
                                James

                                Comment

                                Working...
                                X