전체상품목록 바로가기

본문 바로가기


현재 위치
  1. home
  2. community
  3. 기술문의 :)

기술문의 :)

기술문의 게시판 입니다.

상품 게시판 상세
subject JPEG 시리얼 통신 카메라 A형과 UNO R3 결합
writer 송권 (ip:)
  • date 2013-11-13 13:29:23
  • like 추천하기
  • view 40
rating 0점

아트로봇 판매 제품 JPEG 시리얼 통신 카메라 A형 (TTL Serial JPEG Camera with NTSC Video 입니다. 이 제품과 UNO R3 ,그리고 SD 메모리 쉴드 E형 (SD card shield) 까지 사용하려합니다. (학과비가 없는 관계로 JPEG 트리거나 FTDI USB ti Serial  변환기는 구매가 어려울듯 합니다.  세가지 제품 모두 아트로봇에서 구매 한 제품들입니다.) 

제품에 링크되있는 홈페이지의 라이브러리를 추가하고 사용해봤는데 컴파일는 컴퓨터에 따라 되기도하고 안되기도 하는데 되는곳에서 실행 해봤을때에는 카메라 연결이 안되있다고 뜹니다. 그리고 컴파일이 되지않는 컴퓨터에서는 에러가 많이 뜹니다. (1.0.5 버전과 0023 버전 에서 컴파일 해봤는데 말도 못하게 에러가 많이뜨네요)

그래서 네이버 카페 아두이노스토리에 있는 소스를 예제삼아 업로드 시켜봤습니다.

#include <SoftwareSerial.h>

#define rxPin 4
#define txPin 5

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

byte incomingbyte;

int a = 0x0000;
int j = 0;
int k = 0;
int count = 0; //Read Starting address

uint8_t MH;
uint8_t ML;
boolean EndFlag = 0;

void SendResetCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();
void GetPhotoSizeCmd();
void SetPhotoSizeCmd(uint8_t x);

void setup() { 
  Serial.begin(9600);
  mySerial.begin(38400);
}

void loop() {
  SendResetCmd();
  delay(4000); //After reset, wait 2-3 second to send take picture command

  SendTakePhotoCmd();

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

  byte a[32];

  while(!EndFlag)
  { 
    j = 0;
    k = 0;
    count = 0;
    SendReadDataCmd();
  
    delay(25);
    while(mySerial.available()) {
      incomingbyte = mySerial.read();
      k++;
      if((k > 5) && (j < 32) && (!EndFlag)) {
        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(" ");
    } //Send jpeg picture over the serial port
    Serial.println();
  }
  while(1);
}

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

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

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

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

void GetPhotoSizeCmd() {
  mySerial.write((byte)0x56);
  mySerial.write((byte)0x00);
  mySerial.write((byte)0x30);
  mySerial.write((byte)0x04);
  mySerial.write((byte)0x04);
  mySerial.write((byte)0x01);
  mySerial.write((byte)0x00);
  mySerial.write((byte)0x19);
}

void SetPhotoSizeCmd(uint8_t x) {
  mySerial.write((byte)0x56);
  mySerial.write((byte)0x00);
  mySerial.write((byte)0x31);
  mySerial.write((byte)0x05);
  mySerial.write((byte)0x04);
  mySerial.write((byte)0x01);
  mySerial.write((byte)0x00);
  mySerial.write((byte)0x19);
  mySerial.write((byte)x);
}


위 소스입니다. 우선 컴파일, 업로드는 아무 이상없습니다. 그러나 시리얼 모니터로 확인하면 X XX XX XX XX XX ... 이렇게 쭉 뜹니다.
어떻게 해야될지 막막하네요.


file
password 삭제하려면 비밀번호를 입력하세요.
댓글 수정

password :

/ byte

비밀번호 : 확인 취소

댓글 입력

commentsname : password : 관리자 답변 보기

/ byte

왼쪽의 문자를 공백없이 입력하세요.(대소문자구분)

회원에게만 댓글 작성 권한이 있습니다.

관련 글 보기

관련글 모음
번호 상품명 제목 작성자 작성일 조회
16922 [배송안내] 설연휴 배송 아트로봇CT 2019-02-01 193
16646 usb2serial보드 문의 (주)프라임소프트 2018-03-14 207
16654 usb2serial보드 문의 아트로봇CT 2018-03-18 190
16638 [ 설연휴 및 배송 ] 휴무 및 택배배송 일정 안내 아트로봇CT 2018-02-13 205
16624 구매 관련 문의드립니다. 강민구 2018-01-25 3