Show Posts
Pages: [1] 2 3
1  Using Arduino / Installation & Troubleshooting / Re: Mini Pro Serial port running at half speed on: December 04, 2012, 09:38:54 pm
Ooops, 8 MHz...

2  Using Arduino / Installation & Troubleshooting / Mini Pro Serial port running at half speed on: December 01, 2012, 03:45:52 pm
So this is odd...
I pulled two Arduino Mini Pro's (3.3V - 8kHz) out of my bin to use them and I was having difficulty even getting a "Hello World" sketch to work properly on either. I put the same sketch on an Uno and it worked fine. After noodling around it was clear that I have to set the serial monitor on my laptop to twice the baud rate as I specify in the sketch. When I do that it works fine. I'm guessing the problem is either that the serial port on both mini's is running at the wrong rate or the Arduino ide (mac) is mismatched for the mini.

I put the mini on a logic analyzer and and it confirmed that the data is coming out at 14400 even though I initialized the serial port at 28800 so I guess it's something in the mini.

Any ideas?
3  Using Arduino / Project Guidance / Re: LinkSprite Camera unexpected behavior on: September 23, 2012, 08:53:03 pm
Code:
[code]Last input on this topic. I succeeded in getting an image out of my Linksprite camera. One issue that went undetected was that I exceeded an array bound during a loop and that was creating a random error in the address at which I was reading the data out of the camera. Once I fixed this error I was able to read out exactly the right amount of data for each picture. What was then left was to write the data to an SD card and I needed to learn how to write binary data but as soon as I figured that out, voila, a picture. I had this success using the Arduino Uno. My final remaining task is to wire up my original circuit using the Arduino Mini Pro and to see if the issues I was experiencing were the result of the addressing error.

Here's the code for completeness.

#include <SoftwareSerial.h>
#include <SD.h>

     /* SD Card  */
     
    const int chipSelect = 10;
     
     /* Linksprite */

    byte incomingbyte;
    int sizeMessage[9], readtest[2];
    long a=0x0000;  //Read Starting address
    int i=0, j=0, b = 0, packetcount=0, imageSize, test;     
    boolean ImageEnd = 0, packetcycle = 0;
    uint8_t MH,ML;
 
    File dataFile;

    void SendResetCmd();
    void SendTakePhotoCmd();
    void SendReadDataCmd();
    void StopTakePhotoCmd();
    void GetImageSize();

    SoftwareSerial mySerial(4,5); //Configure pin 4 and 5 as soft serial port

    void setup()
    {
      Serial.begin(38400);
      mySerial.begin(38400);
       
// Set up SD Card

    pinMode(chipSelect, OUTPUT);

    if (!SD.begin(chipSelect)) {
      Serial.println("  Card failed, or not present"); // don't do anything more:
      return;
    }
    Serial.println("card initialized.");
   
// Create image filename

    int index = millis()/1000;
    Serial.print("index: ");
    Serial.println(index);
   
    String filename = "CAM_"+String(index)+".jpg";   // Create new filename
       
    int strlen=filename.length()+1;                       // Get the length of the string including the null character
    char charBuf[strlen];                             // initialize a charachter array to fold the filename
    filename.toCharArray(charBuf, strlen);            // convert the String filename to character array
   
    dataFile = SD.open(charBuf, FILE_WRITE);     // Open new file on SD Card

    Serial.println("file created: ");
    Serial.println(dataFile);

// Reset Camera *************************************
         
      Serial.print("Clearing input buffer\n");
      while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();
      } 
       
// Reset Camera *************************************
               
      Serial.print("Sending Reset\n");
      SendResetCmd();
      while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();
      } 

     
//   After reset, wait 2-3 second to send take picture command
     
      delay(2500);

// Take Picture **************************************

      Serial.print("Sending Take Photo\n");
      SendTakePhotoCmd();
      while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();
      }
       
// Clear Serial Buffer ********************************

      while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();
      } 

// Get Image Size **************************************

      Serial.print("Sending Image Size\n");
      GetImageSize();
      Serial.println("Get Image Size: ");
      i=0;

      while(mySerial.available()<9) // wait for 9 bytes
      {
      }

      while(mySerial.available()>0) // Read the serial buffer contents
      {
        incomingbyte=mySerial.read();
//        Serial.println(incomingbyte,HEX);
        sizeMessage = incomingbyte;
        i++;
      } 
     
      imageSize=word(sizeMessage[7], sizeMessage[8]);

      Serial.println(imageSize);
    }

    void loop()
    {
     
      byte packet[42];

// Read Data Packet ********************************

      while(!ImageEnd)
      {
        while(mySerial.available()>0) // Read the serial buffer contents
        {
          incomingbyte=mySerial.read();
        } 
       
        Serial.print("Sending Read Data\n");
        Serial.print("Read Address: ");
        Serial.print(a);

        SendReadDataCmd();
     
        packetcount++;

        while(mySerial.available()<42)
        {
        }
         
        i = 0;       
        while(i < 42)    // Read 42 bytes in from serial buffer
        {                 
          while(mySerial.available()>0)
          {     
            incomingbyte=mySerial.read();
            packet = incomingbyte;
            i++;
          }
        }

//              Test packet to see if preable 5 bytes equals the trailing 5 bytes

        test = 0;
        for ( i=0; i <5; i++) 
        {
          if( !(packet == packet[i+37])) test += 1;
        }
       
        if( test>0)
        {
          Serial.print("Bad Packet*************************");
          Serial.println(test);
        }

//          Loop through data packet

        for ( i=5; i <37; i++)  //read the image data out of the packet
        {
          b++;
         
//       Write data to packet to SD card
         
        if (dataFile)
        {
          dataFile.write(packet);
          Serial.print(packet, HEX);
          Serial.print(" ");
        }
        else
        {
          Serial.println("error creating file");
        }
         
          if((packet[i-1]==0xFF)&&(packet==0xD9))   // Test for end of image tag
          {
            dataFile.close();
           
            Serial.print("Image End: ");
            Serial.print(packet[i-1],HEX);
            Serial.print(" ");
            Serial.println(packet,HEX);
            Serial.print("packets: ");
            Serial.print( packetcount);
            Serial.print("  bytes read: ");
            Serial.print( b);
            Serial.print("  bytes remaining: ");             
            Serial.println( imageSize-b);
 
            packetcount++;
            ImageEnd=1;
            return;
          }
        }
        Serial.println(" ");
      }
    }     

//Send Reset command
void SendResetCmd()
{
mySerial.write(0x56);
mySerial.write(byte(0x00));
mySerial.write(0x26);
mySerial.write(byte(0x00));
}

//Send take picture command
void SendTakePhotoCmd()
{
mySerial.write(0x56);
mySerial.write(byte(0x00));
mySerial.write(0x36);
mySerial.write(0x01);
mySerial.write(byte(0x00));
}

//Read data
void SendReadDataCmd()
{

    MH=a/0x100;
    ML=a%0x100;
    mySerial.write(0x56);
    mySerial.write(byte(0x00));
    mySerial.write(0x32);
    mySerial.write(0x0c);
    mySerial.write(byte(0x00));
    mySerial.write(0x0a);
    mySerial.write(byte(0x00));
    mySerial.write(byte(0x00));
    mySerial.write(MH);
    mySerial.write(ML);
    mySerial.write(byte(0x00));
    mySerial.write(byte(0x00));
    mySerial.write(byte(0x00));
    mySerial.write(0x20);
    mySerial.write(byte(0x00));
    mySerial.write(0x0a);
    a+=0x20; //address increases 32£¬set according to buffer size

}


void StopTakePhotoCmd()
{
  mySerial.write(0x56);
  mySerial.write(byte(0x00));
  mySerial.write(0x36);
  mySerial.write(0x01);
  mySerial.write(0x03);
}


void GetImageSize()
{
  mySerial.write(0x56);
  mySerial.write(byte(0x00));
  mySerial.write(0x34);
  mySerial.write(0x01);
  mySerial.write(byte(0x00));
}

[/code]
4  Using Arduino / Programming Questions / Re: Binary write to an SD card on: September 23, 2012, 08:30:57 pm
Thanks...
It's working now.
That was a silly error.
5  Using Arduino / Programming Questions / Binary write to an SD card on: September 23, 2012, 06:41:35 pm
Well, I'm no programmer, I can tell you that, but I'm getting better. I have been struggling to get a LinkSprite TTL JPEG camera working and tonight I made SIGNIFICANT progress toward getting this seemly simply interface established. (I found a stupid error that I never would have expected that has caused my hair to gray considerably). Bygones be bygones, I am now getting data off this camera that looks (numerically) to be exactly what is expected to come from it and my task is now to write this pre-formatted jpeg compressed data to an SD card so I can load it onto my laptop and look at it. The data come to me in 42 byte packets from the camera, the first 5 bytes and the last 5 bytes are discarded and I need to write the middle 32 bytes to the SD card.I store this packet of data in a 42 byte array. I then loop though the middle 32 values of the array and write each byte to the SD card. When I do this and look at the file, the data has been written to the card as text; the values from the camera have been written to the card as individual numbers, not binary values. (the byte 255 is written to the card as the characters "2", "5" and "5", not FF). I have tried various ways to write the data to the card but I am always getting the same result. Code below... Thanks for your help.

Code:
#include <SoftwareSerial.h>
#include <SD.h>

 ...

    dataFile = SD.open(charBuf, FILE_WRITE);     // Open new file on SD Card

      
      byte packet[42];

... take picture ...

...  Read data out of camera into "packet" 42 bytes at a time ...

        for ( i=5; i <37; i++)  //read the image data out of the packet
        {
          
//       Write data to packet to SD card
          
        if (dataFile)
        {
          dataFile.write(packet[i],BIN);   This ends up writing to the SD card a text... :-(
        }

6  Using Arduino / Networking, Protocols, and Devices / Re: SoftwareSerial on the Arduino Pro Mini 3.3V on: September 10, 2012, 08:16:18 am
I have not but I will consider it. Mostly, I'm interested in finding out if anyone else has run into this or am I looking at an isolated problem with this particular chip.
7  Using Arduino / Networking, Protocols, and Devices / SoftwareSerial on the Arduino Pro Mini 3.3V on: September 07, 2012, 09:40:59 pm
I have just spent about a month of my free time trying to figure out why a LinkSprite JPEG camera would not provide useable images for a project I'm working on. The upshot of all my labor is that reading the camera data out of the camera at 38400 baud using SoftwareSerial on an Arduino Pro Mini 3.3V (8MHz) would provide inconsistent results even when I was reading from the same  memory location in the camera. When I ran the same software on an Uno (also using softwareserial)  the results were error free. Question is, is using the Arduino pro mini for a task like this inadvisable? AM I running up against the limitation of the board? I like the size of the mini but I'm surprised that I'm seeing different results out of the mini and the uno and I'd appreciate any thoughts on what might be going on.

Thanks
8  Using Arduino / Project Guidance / Re: LinkSprite Camera unexpected behavior on: September 07, 2012, 09:34:19 pm
OK, Just to close this out for anyone who follows in my footsteps, I think the heart of the problem I've been having is with the Arduino Pro Mini. When I run my camera software on an Uno I get rock solid results and I'm only 12 bytes off from the link sprite size number (Ill figure out the 12 byte difference later) When I run it on the Mini, I get different data out of software serial every time I read from the camera (this is reading the same image address three times and getting different results...) I'm going to post a question elsewhere regarding the use of software serial on the 8MHz mini and if i'm driving it too fast.

So long (for now...)
9  Using Arduino / General Electronics / Re: 3.3v to 5V logic level shifter using transistors on: August 31, 2012, 08:26:56 am
Here's the circuit I used to perform the level shifting for the LinkSprite. Comments Welcome.
10  Using Arduino / General Electronics / Re: 3.3v to 5V logic level shifter using transistors on: August 31, 2012, 08:16:03 am
I did use a resistor divider to to reduce the camera's 5V output to the Arduino's 3.3v input. Problem is I needed a different solution to get the Arduino's 3.3V output into the camera's input. Originally I was hoping the 3.3V signal would be sufficient to trigger the logic in the camera but in early tests the camera was not responding so I sought to increase the signal level of the Arduino but, sadly, I still am not getting a response from the 5V camera.
11  Using Arduino / General Electronics / Re: 3.3v to 5V logic level shifter using transistors on: August 30, 2012, 10:08:17 pm
The camera was flaky at 3.3V but at least it was responding to commands. By inserting the 4066 chip into the 3.3V circuit at least I know it sends commands correctly before I move to the 5V circuit. After having done this, the chip worked like a charm on the 3.3V circuit but did not seem to work on the 5V circuit. After putting the USB scope on the chip it turns out when you put a voltage on the switch terminal which exceeds VCC for the chip (I was still using the 3.3V) it closes the switch and you get a flat line voltage. After I changed the hip to 5V voltage also, the chip worked as advertised. Problem is that the camera circuit did not work even after I did the logic level shift. Very frustrating. I'm going to buy a replacement camera on the notion that the one I got is a defect or that I fried it in my many sloppy attempts to get it working.
12  Using Arduino / Project Guidance / Re: LinkSprite Camera unexpected behavior on: August 30, 2012, 10:00:15 pm
I was finally able to get a copy of the linksprite test software. I was having trouble with the link on the site always telling me that I didn't have permission to access the file. FInally Linksprite support sent me a copy. I ran it and it comes up with a gui that lets you exercise most of the functionality of the camera. From what I saw in the manual, I should have been able to get a picture to come up simply by clicking on the take an image button. I was never able to get an image and in some cases the software simply crashed. I'm pretty much resigned to the fact that I got a bum camera. Other people seem to be able to get something from the camera with a lot less effort than I've put into this.

Thanks all for your help. If my new camera works right out of the box I'll update this post.
13  Using Arduino / Project Guidance / Re: Space Balloon - first project on: August 30, 2012, 09:54:26 pm
@kg4wsv - Yeah,  That's the radio set. Its good to hear someone who actually achieved the rated mileage. Most times you hear the stories about how a radio only worked to half the advertised distance.
14  Using Arduino / Project Guidance / Re: LinkSprite Camera unexpected behavior on: August 28, 2012, 02:44:06 pm
Just for completeness and for those mac users who run into the same problem, to read from a serial port uausing VMWare  /Windows XP you have to edit the VMWare .vmx file to force BIOS display. When you reboot, hit F2 key to go into BIOS editing mode and then set the Serial ports to "on" rather than auto.

Once I got a serial port to show up in X-CTU I was able to confirm that the camera is operating as the manual suggests. This means its back tot he drawing board for me. Now that I have the COM port, I'm able to use my USB O-Scope so now I'm going to look at the shape of the signals that I'm sending to the camera to make sure they're clean.
15  Using Arduino / Project Guidance / Re: Space Balloon - first project on: August 28, 2012, 02:36:13 pm
I'm working trhough a similar project though I think less ambitious.

Solar panels - This is a tradeoff between the weight required to get the required current and the weight of an equivalent battery pack to provide 4-5 hours of life for your payload. I've toyed with a small panel to provide at least some current to extend the battery life but balloon altitude is a direct function of payload weight so I will be doing some calculations to see if its worth it.

Cameras:
I'm choosing to send a Go Pro aloft to record the event in high quality for the duration (at a low frame rate) and I am trying to configure a LinkSprite JPEG camera to take periodic images for transmission to the ground. Personally I'm having difficulty getting the Linksprite to work (it hates me) but I'm still plugging away.

Transmitters:
I'm using xbee pro transmitters for prototyping (putting the payload on RC airplanes, etc.) and there is a high powwer, pin compatable transmitter with a 40 mile range that I'm considering for the payload.

Batteries:
I've never seen a LiPo expansion issue mentioned before but it seems that is something that can be checked out in advance with a vacuum chamber. I purchased a 6AH Lipo set from SparkFun and depnding on how many amps the payload draws I'm hoping that is sufficient to power the payload for the flight as well as transmitting a beacon once its back on the ground.

Good luck.
Jim
Pages: [1] 2 3