Go Down

Topic: [SOLVED] Problems communicating with Sony PTZ Camera- VISCA protocol (RS232) (Read 5 times) previous topic - next topic

senorvalenz

Hi Folks,

I know a few other people have posted this same problem, but nobody has posted their working code or solutions, so I'll try to be as clear as possible, and post my working code + wiring ASAP!

Overall Objective: Control Sony D70 PTZ Camera using Arduino via Max232 circuit and VISCA protocol.  Final product will be an analog joystick controller that allows museum visitors to control pan, tilt, and zoom.

Current objective:  For now, I'm just trying to establish communication with the Camera, and execute one command when I press the button (Zoom telephoto)

Problem: I'm not getting any response from the camera.  When I test out the circuit with the computer (by sending commands from computer to Arduino), it works fine.  However, communicating between Arduino>Camera or Computer>Camera doesn't work.

Controller: Arduino Uno
IDE: Arduino 1.0.3

All about the Camera: Sony EVI-D70
Product Page: http://pro.sony.com/bbsc/ssr/product-EVID70/
Technical Manual (includes very well-documented protocol starting on page 31):http://pro.sony.com/bbsc/ssr/product-EVID70/
Some key points from the Tech Manual:
> "Data flow will take place with the LSB first" (p32)
> How to start communication with the camera http://melikebike.files.wordpress.com/2013/02/capture1.jpg
> Wiring:
http://melikebike.files.wordpress.com/2013/02/capture2.jpg
> How to zoom:
http://melikebike.files.wordpress.com/2013/02/capture3.jpg

My code:
Code: [Select]
/*
Based on soft serial example
*/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

//Camera commands (taken from Technical Manual)
uint8_t address_command[4]= {0x88, 0x30, 0x01, 0xFF};
uint8_t if_clear[5]= {0x88, 0x01, 0x00, 0x01, 0xFF};
uint8_t zoom_tele[6]= {0x81, 0x01, 0x04, 0x07, 0x02, 0xFF};
int delayTime= 100;   //Time between commands

const int buttonPin=2;  //Button to activate sending the command
const int ledPin =  13;      //Indicator LED


void setup()  
{
 pinMode(buttonPin, INPUT);
 pinMode(ledPin, OUTPUT);
 // 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!");
 
 //SEND SETUP COMMANDS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 // set the data rate for the SoftwareSerial port
 mySerial.begin(9600);
 //mySerial.println("Hello, world?");
 
 //Send Address command
 for (int i=0; i<6; i++){
   mySerial.print(address_command[i],HEX);
 }
 
 //plenty of delay to allow camera time for next command
 delay(500);  
 
 //Send IF_clear command
 for (int i=0; i<5; i++){
   mySerial.print(if_clear[i],HEX);
   delay(100);  //For USB testing-- NOT FOR ACTUAL CONTROLLER
 }

}

void loop() // run over and over
{
 //If button is pressed, send 'Zoom_Tele' command and light up LED
 int buttonState=digitalRead(buttonPin);
 if(buttonState==HIGH){
   digitalWrite(ledPin, HIGH);
   sendCommands();
 }
 else{
   digitalWrite(ledPin,LOW);
 }
 
 //Take softSerial (RS232) input and send via Serial
 if (mySerial.available())
   Serial.write(mySerial.read());
 //Take Serial input (from Arduino Serial monitor) and send to RS232 output:
 if (Serial.available())
   mySerial.write(Serial.read());
 
}

void sendCommands(){
  delay(500);  //Delay before sending commands to avoid sending multiples
 Serial.println("Sending commands");
 //Send Zoom tele command
 for (int i=0; i<6; i++){
   mySerial.print(zoom_tele[i],HEX);
 }
}


Wiring diagram:

Note on wiring diagram:  I switch the TX and RX wires in order to communicate with the computer.

What I've tried:
1. Sending hex values from computer to camera using a Keyspan USB>RS232 converter and RealTerm (maybe I'm doing this wrong??).  Here's how I did it:
9600-8N1 , no flow control
View setup:

Send commands:

Result of RealTerm test: no response from camera.  I tried sending Zoom_tele command just for kicks, but nothing happens.
Note: the port was not active in these screenshots, but I know it works.  I used an Arduino Uno and the above code to send commands to Realterm, and vice versa.
2. Tested continuity on all wires.  Yes, it's really hooked up like this.
3. Switching RX and TX wires between MAX232 chip and Camera.  I've tried all things with wires in both configs.
4. Tried 2 Arduino Uno's... same results

Some things I'm thinking about trying:
>> Use hardware serial port to communicate with camera, and softSerial port to communicate with computer
>> any other ideas??

Thanks so much in advance, and let me know if I can provide any other info.
-S

zoomkat

Quote
When I test out the circuit with the computer (by sending commands from computer to Arduino), it works fine.


So how do you know this? Did you use a loopback wire on the max232 cam side instead of the cam?
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

zoomkat

#2
Feb 23, 2013, 04:28 pm Last Edit: Feb 23, 2013, 04:59 pm by zoomkat Reason: 1
Quote
Final product will be an analog joystick controller that allows museum visitors to control pan, tilt, and zoom.


Some time back I looked at a commercial joystick controller for these types of cams (like below) and the price was ~$1500. In thinking of making a DIY joystick controller, I looked at the control protocol, and decided that going with the absolute position commands for pan, tilt, and zoom, would be the simpliest setup to implement. I never got one of the cams, so never followedn up with the DIY joystick control.

http://www.fullcompass.com/product/374556.html?utm_source=googleps&utm_medium=shopping&utm_campaign=googleps&gclid=CLG9pbrlzLUCFQ84nAod3EAAHQ

http://compare.ebay.com/like/181084550838?var=lv&ltyp=AllFixedPriceItemTypes&var=sbar
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

DanielW

Did you check if you have all the dipswitches on the bottom of the D70 in the OFF position?   This would mean they all point to the back side of the camera.

Doing that will config the camera into 9600 Baud and RS232 instead of 422.

Then to check it and to see how the commando structure works for the D70 you could download the evi d70 demo software from sony. > http://pro.sony.com/bbsc/ssr/product-EVID70P/  Go to TAB "resources" and then at the bottom.  Install the software, run a cable to your PC and check if the cam works.  (had a few cam's over time that died on the serial port for no reason)

I developed a controller like this about 6 years ago on a basic compiler.  If needed i can check my old software. But as Basic isn't C it should be rewritten completly..
Daniel Wittenaar

senorvalenz

#4
Feb 25, 2013, 09:34 pm Last Edit: Feb 25, 2013, 09:48 pm by senorvalenz Reason: 1

So how do you know this? Did you use a loopback wire on the max232 cam side instead of the cam?


I unplugged the RS232 cable from the cam, and plugged it into my computer.  When I send text thru USB serial connection (via Arduino Serial monitor), it shows up correctly on RS232 serial connection (Hyperterminal).  Just read about loopback testing-- I'll have to try that, too.

Quote

Did you check if you have all the dipswitches on the bottom of the D70 in the OFF position?   This would mean they all point to the back side of the camera.


Yes, all dipswitches are off.

I did a bit more reading about RealTerm and realized that the random website that told me to put commas between Hex codes seems to be incorrect.  I'll try putting spaces between my hex codes ASAP.

Quote

Then to check it and to see how the commando structure works for the D70 you could download the evi d70 demo software from sony.

I tried this, but software only supports COM1 thru COM6.  I tried changing the port assigned to the adapter, with no luck, but maybe I'll have another go at that if these other things don't work out...

Thanks for help folks, I'll get back once I try these things...

Go Up