Pelco-D 是一种用在CCTV产业上颇受欢迎的PTZ(Pan水平/Tilt竖直/Zoom放大)相机控制协议。
Pelco-D的格式
Pelco-D包含7字节(本文中所有字节数据都是16进制,除非特别声明)
Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 |
---|---|---|---|---|---|---|
Sync | Camera Address | Command 1 | Command 2 | Data 1 | Data 2 | Checksum |
- Byte 1 (Sync) - 同步字节, 固定为 FF
- Byte 2 (Camera Address) - 被控制相机的逻辑地址 (地址1 表示为 01)
- Byte 3 & 4 (命令1 和 2) 如下表所示
- Byte 5 (Data 1) - 水平速度, 值从 00 (停止) 到 3F (高速) 和 FF 涡轮增压速度 (设备水平移动的最大速度)
- Byte 6 (Data 2) - 竖直速度, 值从 00 (停止) 到 3F (最大速度)
- Byte 7 (校验和) - 字节和 (不包含同步字节), 然后对100 (十进制数256)取余
命令1 and 2 详情
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 | |
---|---|---|---|---|---|---|---|---|
Command 1 | Sense | Reserved | Reserved | Auto / Manual Scan | Camera On/Off | Iris Close | Iris Open | Focus Near |
Command 2 | Focus Far | Zoom Wide | Zoom Tele | Tilt Down | Tilt Up | Pan Left | Pan Right | Fixed to 0 |
示例 (命令 2):
水平左转 - 0 0 0 0 0 1 0 0, 这等于 04
一些其它指令:
Command | Byte 3 | Byte 4 | Byte 5 | Byte 6 |
---|---|---|---|---|
Go to Preset | 00 | 07 | 00 | 01 to FF |
Set Zoom Speed | 00 | 25 | 00 | 00 to 33 |
Set Focus Speed | 00 | 27 | 00 | 00 to 33 |
Alarm Ack. | 00 | 19 | 00 | Alarm no. |
一些常用的控制指令:
Function | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 |
---|---|---|---|---|---|---|---|
Up | 0xFF | Address | 0x00 | 0x08 | Pan Speed | Tilt Speed | SUM |
Down | 0xFF | Address | 0x00 | 0x10 | Pan Speed | Tilt Speed | SUM |
Left | 0xFF | Address | 0x00 | 0x04 | Pan Speed | Tilt Speed | SUM |
Right | 0xFF | Address | 0x00 | 0x02 | Pan Speed | Tilt Speed | SUM |
Upleft | 0xFF | Address | 0x00 | 0x0C | Pan Speed | Tilt Speed | SUM |
Upright | 0xFF | Address | 0x00 | 0x0A | Pan Speed | Tilt Speed | SUM |
DownLeft | 0xFF | Address | 0x00 | 0x14 | Pan Speed | Tilt Speed | SUM |
DownRight | 0xFF | Address | 0x00 | 0x12 | Pan Speed | Tilt Speed | SUM |
Zoom In | 0xFF | Address | 0x00 | 0x20 | 0x00 | 0x00 | SUM |
Zoom Out | 0xFF | Address | 0x00 | 0x40 | 0x00 | 0x00 | SUM |
Focus Far | 0xFF | Address | 0x00 | 0x80 | 0x00 | 0x00 | SUM |
Focus Near | 0xFF | Address | 0x01 | 0x00 | 0x00 | 0x00 | SUM |
Set Preset | 0xFF | Address | 0x00 | 0x03 | 0x00 | Preset ID | SUM |
Clear Preset | 0xFF | Address | 0x00 | 0x05 | 0x00 | Preset ID | SUM |
Call Preset | 0xFF | Address | 0x00 | 0x07 | 0x00 | Preset ID | SUM |
Query Pan Position | 0xFF | Address | 0x00 | 0x51 | 0x00 | 0x00 | SUM |
Query Pan Position Response | 0xFF | Address | 0x00 | 0x59 | Value High Byte | Value Low Byte | SUM |
Query Tilt Position | 0xFF | Address | 0x00 | 0x53 | 0x00 | 0x00 | SUM |
Query Tilt Position Response | 0xFF | Address | 0x00 | 0x5B | Value High Byte | Value Low Byte | SUM |
Query Zoom Position | 0xFF | Address | 0x00 | 0x55 | 0x00 | 0x00 | SUM |
Query Zoom Position Response | 0xFF | Address | 0x00 | 0x5D | Value High Byte | Value Low Byte | SUM |
参考文章:
- PELCO-D PROTOCOL TUTORIAL
- PELCO-D protocol command list
- How to Troubleshoot PTZ Control Issues (pelco官网文档,比较全面,但是国内访问加载有问题)