Product purchase:https://item.taobao.com/item.htm?ft=t&id=900569256900
Message format of Pelco-D (7 bytes)
Imagine you are writing a command letter with7 words, where each word has the following meaning:
| Byte order | Function | Plain explanation | Example (hexadecimal) |
|---|---|---|---|
| 1 | Start marker | Equivalent to the "urgent!" mark on the envelope, telling the camera: "Attention, a command is coming!" | 0xFF(Fixed value) |
| 2 | Recipient address | Camera number (e.g., Camera 1, Camera 2) | 0x01(Camera 1) |
| 3 | Action command | Control direction: left, right, up, down | 0x04(Turn left) |
| 4 | Auxiliary function | Control zoom (enlarge/reduce), focus (clear/blur), etc. | 0x20(Enlarge) |
| 5 | Horizontal speed | Speed of turning left/right (0=not moving, 255=fastest) | 0x3F(Medium speed) |
| 6 | Vertical speed | Upward/downward speed (as above) | 0x00(Stationary) |
| 7 | Verify password | The camera will check this password to ensure the command has not been tampered with | Automatic calculation |
Let's take a practical example 🌰
Suppose you want to makeCamera 1 turn leftat a medium speed (for example0x3F), the message is as follows:
FF 01 04 00 3F 00 BC- start marker:
FF(fixed and unchanged) - address:
01(Camera 1) - direction command:
04(turn left) - auxiliary function:
00(no zoom, no focus adjustment) - horizontal speed:
3F(medium speed) - vertical speed:
00(No change in the top and bottom) - Verify password:
BC(Calculated from the first 5 digits)
Key explanation
- How is the verification password (check code) calculated?
- Step 1: Add the 5 digits of address, direction, auxiliary function, horizontal speed, and vertical speed.
Example:0x01 + 0x04 + 0x00 + 0x3F + 0x00 = 0x44 - Step 2: Take the complement of this result and add 1 (similar to the negative number in mathematics).
For example:0x44→ The complement is0xBB→ Add 1 to become0xBC. - The final verification code is
0xBC.
- . Why do we need a verification code?
It's like the "tamper-proof seal" on a delivery package. After receiving an instruction, the camera will recalculate the verification code. If it doesn't match the one in the message, it indicates that the instruction may have been interfered with during transmission, and the camera will directly ignore it.
Common operation comparison table
| Action | Instruction (byte 3) | Example |
|---|---|---|
| Turn left | 0x04 | FF 01 04 00 3F 00 |
| Turn right | 0x02 | FF 01 02 00 3F 00 |
| Turn up | 0x08 | FF 01 08 00 00 3F |
| Turn down | 0x10 | FF 01 10 00 00 3F |
| Zoom in | 0x20(Byte 4) | FF 01 00 20 00 00 |
| Zoom out | 0x40(Byte 4) | FF 01 00 40 00 00 |
In a nutshell
The Pelco-D protocol is like sending a7-word secret commandto the camera, where the first six words tell it "what to do", and the last word is a "security code" to ensure the command is delivered safely!
Leave a Reply