網路上收集資料

以下來自 https://www.hanmin.com.tw/pelco%E6%98%AF%E4%BB%80%E9%BA%BC/


在監控領域介面開發中,我們需要用到一些常用的協議,而PELCO的監控器材在目前市場上有很廣泛的應用。PELCO有自己的傳輸控制協定,當它的產品配套使用時,可以互相相容。但在某些情況下,由於工程的需要,要求用其他設備(比如電腦或RS485搖桿)來控制PELCO的矩陣或鏡頭,這就要求充分瞭解PELCO的傳輸協議。

常用的兩種協議:PELCO-D協定和PELCO-P協定。
PELCO-D協議解析
PELCO-D協定一般用於矩陣和其他設備之間的通信。它的格式如下:

Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
同步字 地址碼 命令字1 命令字2 數據1 數據2 校驗碼

所有的值都是用的16進制表示。
同步字通常都是0xFF。
位址碼是指與矩陣通信的那台設備的邏輯位址,可以在設備中設置。
命令字1和命令字2設置如下:

  Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
命令字1 Sence碼 為0 為0 自動/手動掃描 攝像機打開/關閉 光圈關閉 光圈打開 焦距拉近
命令字2 焦距拉遠 視角變寬 視角變窄 為0

Sence碼與Bit4和Bit3有關。在Bit4和Bit3為1的情況下,如果Sence碼為1,則命令就是自動掃描和和攝像機打開;如果Sence碼為0,則命令就是手動掃描和攝像機關閉。當然如果Bit4或Bit3為0的話那命令就無效了。
資料1表示鏡頭左右平移的速度,數值從0x00(停止)到0x3F(高速),另外還有一個值是0xFF,表示最高速。
資料2表示鏡頭上下移動的速度,數值從0x00(停止)到0x3F(最高速)。
校驗碼是指Byte2到Byte6這5個數的和(若超過255則除以256然後取餘數)。
PELCO-P協議解析
PELCO-P協議一般採用RS-485傳輸,串列傳輸速率為4800,1位元起始位
和停止位元,8位元資料位元,無校驗。其格式如下:

 

Byte Value Function
1 0xA0 起始碼
2 0x00 to 0x1F 地址碼
3 Data byte 1 數據位元1
4 Data byte 2 數據位元2
5 Data byte 3 數據位元3
6 Data byte 4 數據位元4
7 0xAF 停止碼
8 0x00-0xFF 校驗碼

起始碼是固定值0xA0。
位址碼是設備的邏輯位址,可由接收設備上的DIP開關來設定。
資料位元1到4的意義如下:

  Bit number
7 6 5 4 3 2 1 0
數據位元1 0 攝像機打開 自動掃描 攝像機打開/關閉 光圈關閉 光圈打開 焦距拉近 焦距拉遠
數據位元2 0 視角變寬 視角變窄 0
數據位元3   平移速度0x00(停止)到0x3F(高速)以及0x40(最高速)
數據位元4   上下移動速度0x00(停止)到0x3F(最高速)

停止碼是固定值0xAF 。
校驗碼是Byte2 到Byte6 這 5 個數的異或值(XOR)。
位址碼是從0編起的,所以位址碼0x00表示第一台設備。

PELCO-D和PELCO-P協議另有一些特殊命令,可對設備進行一些高級控制。

 

以下來自  https://www.cxybb.com/article/u014436243/107639901

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

 

 

arrow
arrow
    全站熱搜

    Mamason 發表在 痞客邦 留言(0) 人氣()