PTZ controller

I am trying to program an Arduino UNO to accept Pelco-D protocol used in PTZ (Pan-Tilt-Zoom) cameras and output it to 2 servos. I found a Pan-Tilt platform at Servocity http://www.servocity.com/html/spt100_pan___tilt_system.html/url] . I have posed a Pelco-D protocol manual as well. Ant help would be appreciated.

TNX Gary

pelco-d.pdf (27.4 KB)

Ant help would be appreciated.

What kind of help does your ant need?

All that you are said is that you are trying to do something. No code. No explanation of what worked or what didn't work.

Hey Troll, If you look at your keyboard you will see that the T and the Y are right next to each other it's called a type-o. I've got 3 other forums where I can get less abuse and more answers.

Don't mind PaulS, he does the best he can. Do you want to use some Pelco control device to control a ptz setup, are you using a pelco cam, or are you making a ptz setup from scratch?

Thanks for the reply Zoomcat,

I am building this from scratch. I have purchased several pan tilt servo platforms for my stationary cameras that are already installed. I've done a search on this forum and Google for a PTZ Pelco-D servo controllers using an Arduino....to no avail. I priced a controller and the price way up there. Besides if I buy a controller, I miss out on all the fun and learning.

Buzz239

Hey Troll, If you look at your keyboard you will see that the T and the Y are right next to each other it's called a type-o.

You want your leg back? I had no idea that a gentle tug would rip it clean off.

I've got 3 other forums where I can get less abuse and more answers.

Just out of curiosity, why didn't you go there, then?

Asking you to explain what kind of help you need is hardly abuse. Asking you what code you have (none is a perfectly reasonable answer) is hardly abuse.

A DIY servo pan/tilt can be simple like the one below, or get more fancy with various components. What you do depends mostly on the control conditions you desire, such as direct wired connection, over a network control, joystick control and such.

http://web.comporium.net/~shb/wc2000-PT-script.htm

I am trying to program an Arduino UNO to accept Pelco-D protocol used in PTZ (Pan-Tilt-Zoom) cameras and output it to 2 servos.

Can you post your code? As far as I can see, the trickiest part will be implementing the pan/tilt speed, but without seeing your code, it is really hard to know what you perceive as the hard parts.

(BTW, it is "typo" (short for "typographical error") not "type-o" (a blood group) )

Nice site Zoomkat,
I got this code from SparkFun Electronics. It uses a serial input to control the pan and tilt servo assembly. With this program I will have to design a translator that will take the single 8 bit Pelco-d serial word and convert it to 2 8 bit words for the arduino. The first word selects the servo ( 0 or 1) and the second word designates the position (0 to 180 degrees). I hope I’m on the right track.

/*******************************************************
* SerialServoControl Sketch
* Written by Ryan Owens for SparkFun Electronics
* 7/15/11
*
* This sketch listens to serial commands and uses the data
* to set the position of two servos.
*
* Serial Command Structure: 2 bytes - [ID Byte][Servo Position byte]
* ID byte should be 0 or 1.
* Servo position should be a value between 0 and 180.
* Invalid commands are ignored
* The servo position is not error checked.
* 
* Hardware Setup
* Servos should be connected to pins 2 and 3 of the Arduino.
* 9V DC Power supply is recommended as USB can't always handle powering two servos
*/

#include <Servo.h>  //Used to control the Pan/Tilt Servos

//These are variables that hold the servo IDs.
char tiltChannel=0, panChannel=1;

//These are the objects for each servo.
Servo servoTilt, servoPan;

//This is a character that will hold data from the Serial port.
char serialChar=0;

void setup(){
  servoTilt.attach(2);  //The Tilt servo is attached to pin 2.
  servoPan.attach(3);   //The Pan servo is attached to pin 3.
  servoTilt.write(90);  //Initially put the servos both
  servoPan.write(90);      //at 90 degress.
  
  Serial.begin(57600);  //Set up a serial connection for 57600 bps.
}

void loop(){
  while(Serial.available() <=0);  //Wait for a character on the serial port.
  serialChar = Serial.read();     //Copy the character from the serial port to the variable
  if(serialChar == tiltChannel){  //Check to see if the character is the servo ID for the tilt servo
    while(Serial.available() <=0);  //Wait for the second command byte from the serial port.
    servoTilt.write(Serial.read());  //Set the tilt servo position to the value of the second command byte received on the serial port
  }
  else if(serialChar == panChannel){ //Check to see if the initial serial character was the servo ID for the pan servo.
    while(Serial.available() <= 0);  //Wait for the second command byte from the serial port.
    servoPan.write(Serial.read());   //Set the pan servo position to the value of the second command byte received from the serial port.
  }
  //If the character is not the pan or tilt servo ID, it is ignored.
}

Moderator edit: Please use code (# icon on the editor’s toolbar) tags when posting code. AWOL