Announcement

Collapse
No announcement yet.

Inconsistent, almost works, then nothing.

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

  • Inconsistent, almost works, then nothing.

    Our uCam-TTL is connected to the hardware UART on a Teensy++ 2.0 http://pjrc.com/teensy/pinout.html . We've added the SD card socket and 3.3v regulator from the same site. We are programming with Arduino 1.0.1 For those of you finding this in the future, our code should probably work on the new Leonardo Arduino.

    With the uC running a simple sketch that forwards all UART characters to the USB com port and vice versa(functionally equivalent to a blank sketch on a real Arduino), the example test application running on a pc works correctly about 90% of the time. It usually synchs between 3 and 12 attempts and most images look fine. But 1 out of 10 times it refuses to synch at all and occasionally an image will have horizontal lines of varying sizes, usually red when it occurs. We are mainly concerned with 80x60 RAW 8bit(332) color but will occasionally send a 640x480 JPEG.

    The problem is much worse when we try the camera in its intended application running independently on the Teensy++. I've attached our unfinished actual source code which does occasionally work (uCam.zip). The last time it sort of worked I captured the serial monitor debug output.

    Card failed, or not present //this was expected, no card was insertedSync successful. // yay!!! it worksInitial successful.Package size successful.Light frequency successful.RAW snapshot successful.Get RAW picture failed. // bummer. Why fail here?JPEG snapshot failed.RAW snapshot failed.JPEG snapshot failed.RAW snapshot failed.JPEG snapshot failed.RAW snapshot failed.JPEG snapshot failed.RAW snapshot failed.JPEG snapshot failed.RAW snapshot failed.JPEG snapshot failed.RAW snapshot failed.JPEG snapshot failed.RAW snapshot successful. // Why start working again here?Get RAW picture successful. // and here?JPEG snapshot failed. // only to die again.RAW snapshot failed.JPEG snapshot failed.

    I then added debug code to print all UART transmissions on the serial monitor and noticed that sometimes the 6 hex elements of the commands did not result in 12 ASCII characters. (wish I had saved that output) This is because(I think) Serial.print(_command[i],HEX) does not print leading zeros. So 0xAA is AA, but 0x07 is 7, and 0x00 is 0. So I changed to Serial.write(_command[i]) instead. Then in order to be absolutely sure what was happening on the serial lines I hooked up a logic analyzer. Output attached(totalFail.zip), in order to view you will need the analyzer software here http://www.saleae.com/downloads Start by scrolling past where reset goes high. That is where it first turns on.

    The current result is sometimes correct behavior from the Teensy++ but absolutely no response from the camera. The voltage at the camera is a stable 3.31v The first time I ran the logic analyzer I saw several responses from the camera but I wanted to capture additional channels, label them, and correlate with the serial monitor. So I reconfigured before saving the first run.

    Can someone please give me an idea what to try next? I am absolutely stumped. At least I learned a valuable lesson. Record your first result whatever it is, you may never see it again.Dustin Maki

    Interesting, but inconsequential note: since changing Uart.print(x,HEX) to Uart.write(x) , the serial monitor only prints garbage in place of the command characters. A single garbage character in place of a 6 hex digit command. That character increases in ASCII value by 1 for each command ?! weirdness all over. Attached files totalFail.zip (1009.2 KB) uCam.zip (7.4 KB)

  • #2


    Not finished, but I am including these updates in hopes that they will be useful for someone besides myself.

    Major changes:
    Serial.Prints for debug purposes were changed to macros so they can be switched off without hunting for and commenting them, instead just undefine DEBUG.
    I have added the simple pass through code to setup() in uCam.ino so that I can initialize the camera using the Demo software and then pull a jumper and have my code take over. The new attachment includes:
    all the current code;
    logic analyzer output for passthrough run with jumper in place;
    Demo program log from the passthrough run with jumper in place;
    logic analyzer output for run without jumper will follow;
    For reference, the order of actions I performed during the passthrough run were:
    Install Lens cap
    Plug Teensy++ into USB port
    Start logic analyzer
    Open Comms
    Sync
    Sync
    select 8bit colour
    80x60 RAW resolution
    Init
    Light 60Hz
    Set
    Snapshot
    Current (RAW) picture
    Get picture
    Video mode on
    ... run for a few seconds
    Video mode off
    Remove passthrough jumper and let Teensy++ code take over attempting to grab pictures.


    Update:
    Still does not sync reliably without Demo program. In fact, does not sync at all now with my code.
    Reason is probably that I reverted back to Uart.print(_command[i],HEX) and added a few lines so that HEX values are always printed as 2 digits. The output appears to be the ASCII values of each digit instead of the HEX values. Next mod is probably to go back to Uart.write(_command[i]) for writing to camera and stay with it because that works with the passthrough code. Change DEBUG_PRINT to Serial.print(_command[i],HEX) so it displays correctly.
    Once I have time to analyze the signals sent by the Demo program, it will be easier to know exactly what to send from the Teensy++ to get the same results.
    Regarding the previous message reference to 'garbage' replies from the camera; I cannot be sure it is remotely related, but I was able to get similar garbage replies from the Demo program if I attempted to get RAW picture before taking a snapshot(of course, that shouldn't be done). Once that was done, no reset or anything short of power cycling would get the camera to behave again.

    Future proposed changes:
    Add a JFET to the camera power line so that I may effect a hard reset by driving the JFET gate HIGH with a uC pin.

    Dustin Maki Attached files uCam.zip (237.4 KB)

    Comment


    • #3


      testSetup.JPG is a photo of the actual hardware used to capture the data.
      jumperRemoved.zip is the logic analyzer capture taken from a run with identical code, but the passthrough jumper removed.

      Dustin Maki Attached files jumperRemoved.zip (839.8 KB)

      Comment


      • #4


        When you sent the Sync command you will receive 2 x 6 byte responses, that for all practical purposes looks like a single 12 byte response.

        I think your code is probably getting out of whack because of that sequence of events, you are probably seeing the 'ACK' but then not seeing the 'SYNC' because you already have it.

        Hope that helps
        Mark

        Comment


        • #5


          Thanks, that was it. Works every time now. Just doubled the _receive_cmd buffer size, received all 12 bytes at once, checked positions 1,2 and 7, and shortcut the timeout loop so it breaks once the buffer is full.
          Dustin Maki

          Comment


          • #6


            Hi Dustin,

            I have bought a uCam-TTL OV528 and I try to do the following things with it.

            First: the ucam works with the uCamDemo-rev2.exe software and that's a good point to start!

            What I want to do is: taking a photo every X minutes, recording it to my SDCard and send it over the air to my server (RFM12B). The road will be long !!

            I use Arduino 1.0 with Arduino Uno R3 and the Sparkfun microSD shield. To make the sketch compile, I have changed all the HardwareSerial to SoftwareSerial in the .h and .cpp and replaced HardwareSerial Uart = HardwareSerial(); by
            SoftwareSerial Uart(2, 3);

            I have try your program and got a successful sync, most part of the time but the Get RAW picture failed. If i bypass this function, the JPEG snapshot is successful but the Get JPEG failed. (look at my attached file for more details)

            If the Get JPEG succeed, the image will be written to my computer ?

            hope you can help me. I have try different library and sketch and yours is the first that return me a successful sync with my uCam!

            Cheers.
            Vince Attached files uCamlib_1.zip (7.8 KB) uCamlib_serial_output.txt (559 B)

            Comment


            • #7


              Hi,

              I'm stuck and I have no other idea for the moment. Could someone help me to make it work please ?

              Cheers
              Vince

              Comment

              Working...
              X