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: Search Results - Sony Pro
Technical Manual (includes very well-documented protocol starting on page 31):Search Results - Sony Pro
Some key points from the Tech Manual:
"Data flow will take place with the LSB first" (p32)
How to start communication with the camera me like bike: Image
Wiring:
me like bike: Image
How to zoom:
me like bike: Image
My code:
/*
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:
- 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. - Tested continuity on all wires. Yes, it's really hooked up like this.
- Switching RX and TX wires between MAX232 chip and Camera. I've tried all things with wires in both configs.
- 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