Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Linksprite LS-Y201 Camera unable to take more than one picture on: November 14, 2013, 03:42:02 am
Hello,

I have a linksprite LS-Y201 camera - https://www.sparkfun.com/products/retired/10061

I have got it working and it is capturing one image...but any attempt to get it take more than one image, fails.

I'm using a Mega, with hardware serial.

Here is my code - Please bear in mind that the code contains a lot of stuff that shouldn't be there! -
Code:
#include <SoftwareSerial.h>

int count=0;
int count2=0;   
int GPScount=0;
unsigned char buffer[64]; // buffer array for data recieve over serial port
int buffercount=0;     // counter for buffer array
int datatosend=0;     // counter for buffer array
String indata;

int a=0x0000,j=0,k=0;                    //Read Starting address       
uint8_t MH,ML;

byte incomingbyte;
                   
void SendResetCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();

void setup(){

Serial.begin(115200);

  pinMode(22, OUTPUT); 

}

void loop(){
  int EndFlag=0;
 
 
  digitalWrite(22, HIGH);    ////// Turn camera/relay on
  delay(5000);
  Serial2.begin(38400);
  delay(5000);
 
  while (Serial2.available()>0){
  Serial.print(Serial2.read());
  }
      int flag = 0;
      int count=0;
      int totalcount=0;

     SendTakePhotoCmd();
     delay(500);
      while (Serial2.available()>0){
      Serial.print(Serial2.read());
  }
 
      byte a[32];
      EndFlag=0;
      while(EndFlag != 1)
     
      { 
         j=0;
         k=0;
         count=0;
         SendReadDataCmd();
         delay(50);
         while(Serial2.available()>0)
          {
               incomingbyte=Serial2.read();
               k++;
               if((k>5)&&(j<32)&&(EndFlag != 1))
               {
               a[j]=incomingbyte;
               if((a[j-1]==0xFF)&&(a[j]==0xD9))      //Check if the picture is over
               EndFlag=1;                           
               j++;
       count++;
               }
          }
               
         for(j=0;j<count;j++)
          {   if(a[j]<0x10)
         Serial.print("0");
           Serial.print(a[j],HEX);
          Serial.print(" ");
           
          }             

      }
  digitalWrite(22, LOW);   ////// Turn camera/relay off
    while (Serial2.available()>0){
  Serial.print(Serial2.read());
     }
     
delay(5000);
Serial.println("Ended");



}





//Send Reset command
void SendResetCmd()
{
      Serial2.write(0x56);
      Serial2.write((byte)0x00);
      Serial2.write(0x26);
      Serial2.write((byte)0x00);
      delay(5000);
     
      Serial.println("Reset = ");
      Serial.print(Serial2.read());
}

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

//Read data
void SendReadDataCmd()
{
      MH=a/0x100;
      ML=a%0x100;
      Serial2.write(0x56);
      Serial2.write((byte)0x00);
      Serial2.write(0x32);
      Serial2.write(0x0c);
      Serial2.write((byte)0x00);
      Serial2.write(0x0a);
      Serial2.write((byte)0x00);
      Serial2.write((byte)0x00);
      Serial2.write(MH);
      Serial2.write(ML);   
      Serial2.write((byte)0x00);
      Serial2.write((byte)0x00);
      Serial2.write((byte)0x00);
      Serial2.write(0x20);
      Serial2.write((byte)0x00); 
      Serial2.write(0x0a);
      a+=0x20;                            //address increases 32£¬set according to buffer size
//      Serial.println("photo");

}

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

void SetSize()
{
      Serial2.write(0x56);
      Serial2.write((byte)0x00);
      Serial2.write(0x31);
      Serial2.write(0x05);
      Serial2.write(0x04);
      Serial2.write(0x01);
      Serial2.write((byte)0x00); 
      Serial2.write(0x19);   
      Serial2.write(0x22);    // unrem this if you want 640x480
      // 640x480     Serial2.write((byte)0x00);
}


void SetCompression()
{
      Serial2.write(0x56);
      Serial2.write((byte)0x00);
      Serial2.write(0x31);
      Serial2.write(0x05);
      Serial2.write(0x01);
      Serial2.write(0x01);
      Serial2.write(0x12);
      Serial2.write(0x04);
      Serial2.write(0xFF);
}


void GetSize()
{
      Serial2.write(0x56);
      Serial2.write((byte)0x00);
      Serial2.write(0x34);
      Serial2.write(0x01);
     Serial2.write((byte)0x00);

}




As you can see, I'm using a relay to turn the camera on then off.
So each loop, the camera is effectively starting afresh.
But this is the data I get back in the serial window -
First pass = 11805400FF D8 FF FE .....loads of picture data..... AF B1 FF FF D9 Ended
Second pass = 0255118054007F FF FF D9 Ended

As you can see, the second pass is completely missing all the picture data and appears to just be the end of another pic (because of the FF D9).

The strange thing is that if I perform a reset of the Arduino by using the reset button, I get a picture, which leads me to believe that it isn't the camera or arduino needing a full power cycle.  I suspect it's more of a case of the Arduino holding some rubbish data in the buffers, which passes over onto subsequent loops.

Thank you for your assistance with this head scratcher :o)
2  Using Arduino / Project Guidance / Re: JPG Camera - Dec to Ascii conversion on: November 12, 2013, 06:15:36 am
I see what you're saying, but no matter what I do, I can't seem to get the EXIF or JFIF to appear in my data stream.
Here is a snippet of the raw data as it is piped to the Arduino COM window...so not even after the data is sent over the internet, which may introduce corruption -

FF D8 FF FE 80 24 9E 0C 93 81 80 00 80 00 80 00 80 00 80 00 80 00 00 80 00 B8 00 D0 00 87 00 99 12 0B 91 82 51 82 00 00 FF DB 00 84 80 04 83 03 83 03 82 04 81 03 81 04 04 04 84 06 89 06 86 05

Which translates to  (carriage returns an' all) (bear in mind the HEX is probably shorter than what I copied from the ASCII) -

ÿØÿþ€$ž “€ € € € € €  € ¸ Ð ‡ ™™ ‘‚Q‚  ÿÛ „€ƒƒ‚„‰†    ‰ŒŽ
Œ
‰
š”—„„‚…ƒ



What I'd like to know is does this camera definitely output a JPG file that contains JFIF or EXIF.  Google is not throwing up any example images that I can interrogate.
Does anyone here use this camera and can confirm the presence of JFIF or EXIF in one of their working JPGs?
3  Using Arduino / Project Guidance / JPG Camera - Dec to Ascii conversion on: November 12, 2013, 05:22:38 am
Hello,

I am using the Linksprite Camera with Arduino. - https://www.sparkfun.com/products/retired/10061
Due to certain circumstances I am sending the image from the camera over the Internet in Dec format (255,216,255,254,...and so on).
I end up with a file - http://www.binaryorbit.org/original.txt
I then convert this file to ASCII characters in the hope of seeing the image - http://www.binaryorbit.org/pic-ascii.txt   (theory is I can just rename this to .jpg).  It just doesn't work though.
I'm pretty sure I have the correct characters, because when I view in in HEX, I see the all important FFD8 at the beginning and FFD9 at the end. - http://www.binaryorbit.org/pic-hex.txt

When I view the JPG in JPEGsnoop, I get "ERROR: dqt_dest_id = 11, >= 4".


Can anyone shed any light??
4  Using Arduino / Networking, Protocols, and Devices / ICOMSAT 1.1 GPRS Shield - AT Commands on: July 19, 2013, 02:39:25 am
Hello,

I have recently purchased an ICOMSAT 1.1 GPRS /GSM Shield, based on the SIM900 chip.
This is exactly the one I've purchased - http://www.ebay.co.uk/itm/251201741345?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

I've been playing around with it for a few days and have managed to get SMS to work using the GSM Library here - http://code.google.com/p/gsm-shield-arduino/

However - I am keen to keep my code as lean as possible, so was hoping to send/receive data to the modem using AT commands.
But everything I try, doesn't work.

What I would like to try is to talk directly to the modem using a terminal emulator, eg - Putty.  But when I think I have everything right, I just get gibberish back, or sometimes, nothing at all.

I'm hoping someone has used this modem before and can shed some light - I'd specifically appreciate any code that will help me talk to this via putty.

here is the code I am using -

Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(4, 5); // RX, TX  - There are jumpers on the modem and the settings here reflect the jumper positioning

void setup() 
{
   // Open serial communications and wait for port to open:
   Serial.begin(9600);
   while (!Serial) {
     ; // wait for serial port to connect. Needed for Leonardo only
   }


   Serial.println("Goodnight moon!");

   // set the data rate for the SoftwareSerial port
   mySerial.begin(9600);
   mySerial.println("Hello, world?");
}

void loop() // run over and over
{
   if (mySerial.available())
     Serial.write(mySerial.read());
   if (Serial.available())
     mySerial.write(Serial.read());
}
5  Topics / Product Design / Re: 2 Axis Solar Tracker (The evolution of an idea) on: September 06, 2012, 03:02:05 am
Looks very interesting.
And also looks to be following some similar ideas to my Arduino Dual Axis Tracker.

I've nicked one or two of your ideas...so only fair I offer some of mine - http://www.binaryorbit.org
Pages: [1]