PELCO D、P通讯协议
一、PELCO协议介绍
1、PELCO主控与前端解码器是通过RS422\RS485通信格式传输。
2、除PELCO原装设备支持RS422和RS485兼容接口,国内大部分厂家主控和接收设备仅支持RS485接口,RS485接口是半双工通信模式,即发送端发过去的控制命令,只管发出去,不管你收不收得到,有的厂家连续发,有的间隔发,总类很多。停止命令往往发1、2条。如PELCO\PANASONIC、三星等大厂做的通信接口,主控发出去命令,接收端收到命令返回SCK 命令给主控,叫回答命令,告知发送端我已收到命令,不用再发了,这就是RS422通信模式的一种用途。
3、PELCO协议内容包括云台控制命令、摄像机控制命令、辅助控制命令、预置位设置和调用命令。注意:网上PELCO协议版本众多,建议看家选择英文版本,中文版本很多错误。
4、Pelco P protocol details are proprietary, non-public documents. In almost all cases, Pelco's publicly available ASCII, G, or D protocols can be used in place of Pelco P with the appropriate translator. Pelco Product Support technicians may be able to assist you in obtaining the use of these protocols for your application. ASCII, G, and D protocols can be obtained be filling out our online registration form located. For further assistance please contact Pelco Product Support at (800)298-9100 or (559)292-1981.
二、PELCO-D协议
数据格式:1位起始位、8位数据、1位停止位,无效验位。波特率:2400bps.
命令格式:
1.该协议中所有数值都为十六进制数
2.同步字节始终为FFH
3.地址码为摄像机的逻辑地址号,地址范围:00H–FFH
4.指令码表示不同的动作,在有关预制点的操作时,数据2表示预制点值
5.数据1、2分别表示水平、垂直方向速度(00-3FH),FFH表示“turbo”速度
6.校验码 = MOD[(字节2 + 字节3 + 字节4 + 字节5 + 字节6)/100H]
Sence码与Bit4和Bit3有关。在Bit4和Bit3为1的情况下,如果Sence码为1,则
命令就是自动扫描和和摄像机打开;如果Sence码为0,则命令就是手动扫描和摄像机关闭。当然如果Bit4或Bit3为0的话那命令就无效了。
常用命令列表:
关于云台自动功能如何实现,云台的自动功能是做到解码板电路,有多种硬件电路方法,也有软件检测限位开关或者光耦中断来控制左和右自动扫描。但上面协议表是没有自动命令,在P协议里AUTOPAN命令是CALL 99号预置位。在D协议里是没有定义,编程者可以定义CALL #NO来实现。
D协议特殊命令控制表:
以地址码0x01为例:
{0xff,0x01,0x00,0x08,0x00,0xff,0x08,}
协议中所有数值都为十六进制数
始终为A0H
3.地址码为摄像机的逻辑地址号,地址范围:00H–1FH
4.指令码表示不同的动作
5.数据码1、2分别表示水平、垂直方向速度(00-3FH),在有关预制点的操作时,数据码2表示预制点值
始终为AFH
7.校验码(XOR sum of Bytes 2-6) = 字节2 ^ 字节3 ^ 字节4 ^ 字节5 ^ 字节6
常用命令列表:
P协议特殊命令控制表:
以地址码0x01为例:
{0xa0,0x01,0x00,0x08,0x00,0x30,0xaf,0x39,} The protocol uses no parity, one start bit, eight data bits, and one stop bit. The recommended baud rate is 4800 (4800, 8, N, 1, 1).
MESSAGE FORMAT
Byte 1 is always $A0
Byte 2 is the receiver address, set by DIP switch in the receiver
Byte 3-6, see below
Byte 7 is always $AF
Byte 8 is an XOR sum of Bytes 1-7
The protocol is “zero indexed” so that the hexadecimal address sent in the protocol for the first receiver is $00 which corresponds to address 1.
The bits within the “Data bytes” are broken up into two main groups. For Pan and Tilt commands, the functions are determined as follows:
PAN AND TILT COMMANDS
EXTENDED COMMAND SET
The extended command set will have bit 0 of data byte 2 set and will follow the format in the following table:
The receiver will respond with an ACK.
To accommodate features of new systems and maintain compatibility with our old systems, some functions have been added through the use of some of the unused preset functions. These are:
Preset Number Function
99Begin Auto-scan
98Begin Frame Scan
97Begin Random Scan
96Stop Scan
95Enter Menu Mode
94Remote Reset