Hexadecimal and Pelco D protocol

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
neoirto
 
Posts: 19
Joined: Sat Mar 06, 2010 7:52 am

Hexadecimal and Pelco D protocol

Post by neoirto »

Hello,

I actually try to control a simple Zoom cctv camera with a rs232 communication port which is using the PELCO D protocol.
I understood I have to send some messages in hexadecimal, but this is not really clear for me. Hexadecimal still like chinese for me...
Could anybody show me how to use this protocol from my duelaminove please ?!!

Here are the spec of the PELCO D :
http://www.roboticcircuits.com/Downloads/d-rev2.pdf

And what is the maximum length of the wire I should use between the Output of the arduino and the rs232 port on the camera ?

Thanks a lot :wink:

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Hexadecimal and Pelco D protocol

Post by adafruit_support_bill »

Maximum cable length is somewhat dependent on communication speed and the construction of the cable. But for distances under 50 feet you shouldn't have any difficulties with a half-decent cable. http://www.lammertbies.nl/comm/info/RS-232_specs.html

Hexadecimal values in C++ are expressed with a "0x" prefix. For example, the synch byte in your protocol would be "0xFF". If you have some more specific details on what you want to do with this protocol, we might be able to offer more specific advice.

neoirto
 
Posts: 19
Joined: Sat Mar 06, 2010 7:52 am

Re: Hexadecimal and Pelco D protocol

Post by neoirto »

Thanks for your quick answer,

In fact, I just want to control the "Zoom Wide' and "Zoom Tele" command, but perhaps I will need too to look about "Iris close", "Iris Open" and "Camera on/off".

But I don't understand any word by myself : the example shown at the bottom of the document is just not correct for me (so I missed something !) :

Receiver 2, Left 1/2 speed FF, 02, 00, 04, 20, 00, 26
Receiver 2, Stop FF, 02, 00, 00, 00, 00, 02

Could you decode it for me ?!!

Thanks !

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Hexadecimal and Pelco D protocol

Post by adafruit_support_bill »

Those are the sequence of hexadecimal codes that make up the command. You just need to translate these into Arduino serial commands. To sent the 'Stop' command you would write:

Code: Select all

Serial.write(0xff);
Serial.write(0x02);
Serial.write(0x00);
Serial.write(0x00);
Serial.write(0x00);
Serial.write(0x00);
Serial.write(0x02);

neoirto
 
Posts: 19
Joined: Sat Mar 06, 2010 7:52 am

Re: Hexadecimal and Pelco D protocol

Post by neoirto »

Thanks for your syntax Arduwino,

How to know the address of the device ? With one camera, is that 01 by default ?

With the help of hex to decimal converter I do as follow :
01000000 - > 40 = Zoom wide
00100000 - > 20 = Zoom tele
...

Could you please confirm it's ok ?
FF 01 00 40 00 00 xx : to zoom wide ?
FF 01 00 20 00 00 xx : to zoom tele?
FF 01 00 25 00 01 xx : to set zoom speed to 01 ?
FF 01 08 00 00 00 xx : to stop the camera ?

For the check sum "xx", this a sum of all the bytes I send, for the camera to control validity of the complete message, is that correct ? As mentioned in the pdf, I should do this sum by "modulo 256".
Do you know a script that will help me with that sum ?

Thanks a lot !

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Hexadecimal and Pelco D protocol

Post by adafruit_support_bill »

It looks like you have the commands figured out pretty well. The camera address is most likey set on the camera somewhere. It might be a switch setting, or it might need to be programmed.

To do the checksum, just declare a 'byte' variable and use that to sum up all the command bytes. The byte variable will automatically roll over at 256 and give you a modulo 256 checksum.

neoirto
 
Posts: 19
Joined: Sat Mar 06, 2010 7:52 am

Re: Hexadecimal and Pelco D protocol

Post by neoirto »

Thanks again...
To do the checksum, just declare a 'byte' variable and use that to sum up all the command bytes
Ok, so for the
FF 01 00 40 00 00 xx line I do :

Code: Select all

byte check_sum = (byte)01 + (byte)00 +(byte)40 + (byte)00 + (byte)00;
I'm really not sure with the syntax....

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Hexadecimal and Pelco D protocol

Post by adafruit_support_bill »

That should work!

neoirto
 
Posts: 19
Joined: Sat Mar 06, 2010 7:52 am

Re: Hexadecimal and Pelco D protocol

Post by neoirto »

Ok, thanks for your help, I will try this soon...

neoirto
 
Posts: 19
Joined: Sat Mar 06, 2010 7:52 am

Re: Hexadecimal and Pelco D protocol

Post by neoirto »

I received my rs232 camera zoom, but there is no results...

First my manual is in chinese :
I can power in with 2 plugs, the camera is working fine...
+12V
GND
I have 6 other plugs :
C
Z
F
M
R-
R+
I understand there is RS232 between R+ and R-.

When I check the voltage on this 2 plugs I measure 9V. Is it normal ?
I tried to plug the Ground of the arduino on the R- and the Tx output of my arduino to the R+, then I send PELCO commands like :

Code: Select all

void  send_PELCO_cmd ( byte byte_2, byte byte_3, byte byte_4, byte byte_5, byte byte_6 ) {

byte check_sum = (byte)byte_2 + (byte)byte_3 +(byte)byte_4 + (byte)byte_5 + (byte)byte_6;
	
	emul_SERIE_ZOOM_cam.print(0xff);
	
	emul_SERIE_ZOOM_cam.print(byte_2);
	emul_SERIE_ZOOM_cam.print(byte_3);
	emul_SERIE_ZOOM_cam.print(byte_4);
	emul_SERIE_ZOOM_cam.print(byte_5);
	emul_SERIE_ZOOM_cam.print(byte_6);

	emul_SERIE_ZOOM_cam.print(check_sum);
	
	delay(10);

} 
And nothing is happen ?

Do you see what's going wrong please ?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Hexadecimal and Pelco D protocol

Post by adafruit_support_bill »

Usually, RS-232 requires a minimum of three lines: Ground Rx and Tx. If there is no data returned from the camera at all, they may use just two lines (Ground & Rx).

You should be aware that the Rx and Tx lines from the Arduino do not operate at RS-232 line levels. You will need a TTL to RS-232 level converter. There are chips that perform the conversion, or you may prefer to use a pre-assembled cable such as one of these: http://www.superdroidrobots.com/shop/ca ... p?catid=42

neoirto
 
Posts: 19
Joined: Sat Mar 06, 2010 7:52 am

Re: Hexadecimal and Pelco D protocol

Post by neoirto »

Thanks for your quick reply !

I see... So I need a 5V TTL to RS232 12V Cable converter, is that correct ? I don't need a DB9 connector so what kind of converter is it ?

The voltage of 9V between R+ and R- is ok ? I just plug GND to R- and Tx to R+ with that cable and it's ok ?

:wink:

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Hexadecimal and Pelco D protocol

Post by adafruit_support_bill »

There are a bunch of chips out there. Maxim's are pretty common. There are data sheets and app-notes here: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1798/t/do

If you search for "ttl rs-232 level converter" you will find all sorts of products and projects.

RS-232 levels vary, but 9v is within the typical range.

I'm not sure about the R+ and R- designations though. It could be Rx and Ground as you say, or it might be Rx and Tx (with the third wire to ground). You might try to get some more specific data from the vendor.

neoirto
 
Posts: 19
Joined: Sat Mar 06, 2010 7:52 am

Re: Hexadecimal and Pelco D protocol

Post by neoirto »

Ok,

Your true, there is plenty of converters for ttl to rs232. I believe I will try first to control with my PC-serial to be sure of the way to plug it, then I'll buy a converter...

Thanks again :wink:

jimmycdn
 
Posts: 1
Joined: Sun Jun 02, 2013 4:16 pm

Re: Hexadecimal and Pelco D protocol

Post by jimmycdn »

Hi,
So what was the conclusion of that post on Pelco D Protocol?
Looking forward to hear from you,
cheers,

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”