system
June 28, 2013, 7:12am
1
Dear all,
I have Serial Port Interfaced Camera Module with OV528 protocol (i attached picture). I want to use it with my Arduino Uno. When i searched forum and internet there are some examples for Linksprite Serial cameras. I tried this but OV528 protocol is different. Also i found library which is name C328.h and C328.cpp. But this library has written in 2009. It does not work now. So i found some codes and changed for my system;
#include <SoftwareSerial.h>
byte incomingbyte;
//Configure pin 2 and 3 as soft serial port
SoftwareSerial cameraSerial = SoftwareSerial(2, 3);
int i=;
void setup() {
Serial.begin(115200);
cameraSerial.begin(115200);
Serial.println("Start sync");
delay(5000);
for(i=0;i<40;i++)
{
SyncCamera();
delay(100);
}
while(cameraSerial.available()>0) {
incomingbyte=cameraSerial.read();
}
Serial.println(incomingbyte, HEX);
}
void loop() {
}
void SyncCamera(){
cameraSerial.write((byte)0xAA);
cameraSerial.write((byte)0x0D);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x00);
cameraSerial.write((byte)0x00);
}
The problem is here; firstly i must sync camera. In datasheet (in the attachment) it says : SYNC coomand = AA 0D 00 00 00 00. And this sync command should send 25-60 times and i can connect. But when i run this code im getting "0", i can not sync. I need help how can i write correct codes for communicate?
Any help will be appreciated.
CJ-OV528 Protocol??????.pdf (245 KB)
I cannot open the datasheet. What sets the baud rate of the camera ?
system
June 28, 2013, 7:48am
3
Here is the datasheet:
www.mturkergultepe.com/CJOV528_Protocol.pdf
Cameras baud rate: 115200 but i also tried 9600, 19200, 57600.
system
June 28, 2013, 10:14am
4
Serial.println("Start sync");
delay(5000);
for(i=0;i<40;i++)
{
SyncCamera();
delay(100);
}
while(cameraSerial.available()>0) {
incomingbyte=cameraSerial.read();
}
Serial.println(incomingbyte, HEX);
Try 40 times to sync. Read and discard all but the last character that arrives in response. Why?
Shouldn't you read EACH response, waiting for the camera to respond? Shouldn't you print EVERYTHING that you read?
You obviously have not read the documentation carefully and followed it step by step. But, I feel generous so I will give you a head start:
byte incomingbyte;
//Configure pin 2 and 3 as soft serial port
//SoftwareSerial Serial1 = SoftwareSerial(2, 3); //I use Serial1 on a Mega
int i=0;
byte parsestuff;
int nombresync;
bool premier_ACK_recu;
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
Serial.println("Start sync");
}
void loop() {
if (!premier_ACK_recu){
nombresync++;
Serial.println("Sync #"+(String)nombresync + ": ");
SyncCamera();
}
delay(100);
}
void serialEvent1() {
while (Serial1.available()) {
parsestuff++;
incomingbyte=Serial1.read();
Serial.print(incomingbyte, HEX);
if ((parsestuff == 3) && (incomingbyte == 0x0E)) premier_ACK_recu = true;
if (parsestuff == 6){
Serial.println("");
parsestuff = 0;
}
}
}
void SyncCamera(){
Serial1.write((byte)0xAA);
Serial1.write((byte)0x0D);
Serial1.write((byte)0x00);
Serial1.write((byte)0x00);
Serial1.write((byte)0x00);
Serial1.write((byte)0x00);
}
So this one is on me.