P8864-SMD 串口通信指令集
目录
1. Commands and responses ......................................................................................................... 3
1.1 Command format ........................................................................................................................ 3
1.2 Response format .......................................................................................................................... 3
1.3 CRC calculatio ............................................................................................................................... 3
1.4 SET_POWER[0x40] ....................................................................................................................... 4
1.5 GET_DISTANCE_AMPLITUDE [0X22] .............................................................................. 5
1.6 SET_INTEGRATION_TIME_DIS[0X00] ................................................................................... 5
1.7 SET_DLL_STEP[0x06] ................................................................................................................... 6
1.8 GET_TEMPERATURE[0X4A] ...................................................................................................... 6
1.9 GET_DISTANCE[0x20]................................................................................................................. 6
1.10 GET_DCS[0x25] ........................................................................................................................... 6
1.11 GET_FIRMWARE_VERSION[0x49] ....................................................................................... 7
1.12 GET_DCS_DISTANCE_AMPLITUDE[0x23]......................................................................... 7
1.13 GET_CHIP_INFORMATION[0X48] ....................................................................................... 8
1.14 GET_INTEGRATION_TIME_DIS[0x27]_ .............................................................................. 8
1.15 SET_TEMPERATURE _slope[0X08] ...................................................................................... 8
1.16 SET_TEMPERATURE _compenstate[0X09] ...................................................................... 9
1.17DRUN_COMPENSATION[0X41]PENSATION .................................................................... 9
1.18 GET_REGION_LENGTH_WIDTH[0x57] ............................................................................... 9
1.19 GET_REGION_DISTANCE_AMPLITUDE _64[0X28] .......................................................... 10
1.20 GET_REGION_DISTANCE_AMPLITUDE [0X29] .................................................................. 10
1.21 SET_ADAPTIVE _INTEGRATIN[0X55] ............................................................................... 11
2
1. COMMANDS AND RESPONSES
1.1 COMMAND FORMAT
The command packet has a fixed length of 14 Bytes: A start byte (value 0xF5), followed by 1 byte command ID (CMD), 8
bytes of parame -
ters corresponding to the command and 4 closing bytes with a 32bit CRC.
1.2 RESPONSE FORMAT
The answer packet has variable length: A start byte (value 0xFA), followed by 1 byte type definition, 2 byte length
definition n, n bytes data
and 4 closing bytes with a 32bit CRC.
1.3 CRC CALCULATIO
The Cyclic Redundancy Check (CRC) calculation includes all bytes of the packet except the CRC itself. Examples are listed
in the command list.
CRC specification:
■ Bytewise CRC32
■ Init value: 0xFFFFFFFF
■ Xor value: 0x00000000
■ Polynom: 0x04C11DB7
3
CRC calculation function:
uint32_t CrcCalc::calcCrc32(const uint8_t *data, const uint32_t size)
{
uint32_t crc = initValue;
for(uint32_t i = 0; i < size; i++)
{
crc = calcCrc32Uint8(crc, data[i]);
}
return crc ^ xorValue;
}
uint32_t CrcCalc::calcCrc32Uint8(uint32_t crc, uint8_t data)
{
int32_t i;
//This shift is done to make it compatible to the STM32 hardware CRC
crc = crc ^ (data << 24);
for (i = 0; i < 8; i++)
{
if (crc & 0x80000000)
{
crc = (crc << 1) ^ polynom;
}
else
{
crc = (crc << 1);
}
}
return (crc);
}
1.4 SET_POWER[0X40]OWER [0x40]
Puts the device in power-up or power-down mode and returns after tPROC acknowledge. Before any acquisition
commands, power must beenabled.
Parameter byte 0: 0x01
Command e.g. | 0xF5 | 0x40 | 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0x9C 0xD7 0xD6 0x91 | (power enable)
Response type 0x00: Acknowledge
Response e.g 0xFA | 0x00 | 0x00 0x00 | (0 bytes) | 0xB2 0xAB 0xFC 0xE8 |
4
1.5 GET_DISTANCE_AMPLITUDE [0X22]DISTANCE_AMPLITUDE [0x22]
Starts a new distance and TOF amplitude acquisition and returns after tPROC the result or status. The amplitude is a
quality indicator for the distance result.
Parameter no, all bytes 0x00
Command e.g. | 0xF5 | 0x22 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xE3 0x1A 0x29 0x7B |
Response type 0x05: Data
Response data 64 x 4 bytes distance followed by 64 x 4 bytes amplitude, total: 2x 256 bytes = 512 bytes
Readout order each: Starts at row 0, pixel 0 … pixel 7 and ends with row 7, pixel 7.
Distance byte 0..3 each: Distance, 0.1mm/LSB or status, 32 bit unsigned integer. Zero according the note
of Figure 4. Range: 20 MHz modulation frequency, 0 … 7.5m: 0 … 75'000d
Amplitude byte 0..3 each: TOF amplitude or status, 32 bit unsigned integer.
Response e.g. | 0xFA | 0x05 | 0x00 0x02 | 0x24 0x0F 0x00 0x00 … 0x63 0x10 0x00 0x00 … (2x 256 bytes
total) | CRC (4 bytes) |(distance 387.6mm ... amplitude 4'195 LSB)
1.6 SET_INTEGRATION_TIME_DIS[0X00]TEGRATION_TIME_DIS [0x00]
Sets the integration time for distance measurements and returns after tPROC acknowledge. The integration time is stored
and used as long power is on or until a new time is set. Range: 1 … 1'600 µs. After power-up, default is 125 µs.
Parameter byte 1, 2: Integration time in microseconds, 16 bit unsigned integer
others: 0x00
Command e.g. | 0xF5 | 0x00 | 0x00 0x1E 0x00 0x00 0x00 0x00 0x00 0x00 | 0xD9 0x85 0x1A 0x99 | (30µs integration
time)
Response type 0x00: Acknowledge
Response data 0 bytes
Response e.g | 0xFA | 0x00 | 0x00 0x00 | (0 bytes) | 0xB2 0xAB 0xFC 0xE8 |
5
1.7 SET_DLL_STEP[0X06]_STEP [0x06]
Sets the number of DLL steps for artificial phase/distance shifting and returns after tPROC acknowledge. 1 step is around
2.15ns / 315mm.
Parameter byte 0: Number of DLL steps
others: 0x00
Command e.g. | 0xF5 | 0x06 | 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xD2 0x7E 0x43 0xD5 | (Number of steps =
1)
Response type 0x00: Acknowledge
Response data 0 bytes
Response e.g. | 0xFA | 0x00 | 0x00 0x00 | (0 bytes) | 0xB2 0xAB 0xFC 0xE8 |
1.8 GET_TEMPERATURE[0X4A]ATURE [0x4A]
Returns after tPROC the chip temperature during last distance acquisition. Temperature information is useful for error
compensation of the measured distance.
Parameter no, all bytes 0x00
Command e.g. | 0xF5 | 0x4A | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0x18 0x41 0xF5 0xA4 |
Response type 0xFC: Data
Response data 2 bytes: Temperature, 0.01 ºC / LSB, 16 bit 2's complement signed integer.
Response e.g. | 0xFA | 0xFC | 0x02 0x00 | 0x47 0x13 | 0x4F 0xEE 0x12 0x1F | (temperature 49.35°C)
1.9 GET_DISTANCE[0X20]DISTANCE [0x20]
Starts a new distance acquisition and returns after tPROC the result or status.
Parameter no, all bytes 0x00
Command e.g |0xF5 | 0x20 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0x98 0x53 0xE9 0x9B |
Response type 0x03: Data
Response data 64 x 4 bytes: Distance, 0.1mm/LSB or status, 32 bit unsigned integer. Zero according the note of
Figure 4.Readout order: Starts at row 0, pixel 0 … pixel 7 and ends with row 7, pixel 7.
Range: 20 MHz modulation frequency, 0 … 7.5m: 0 … 75'000d
Response e.g. | 0xFA | 0x03 | 0x00 0x01 | 0x28 0x0F 0x00 0x00 … (256 bytes total) | CRC (4 bytes) | (distance
388.0 mm)
1.10 GET_DCS[0X25]
Starts a new acquisition and returns after tPROC DCS values only.
Parameter no, all bytes 0x00
Command e.g. |0xF5 | 0x25 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xBF 0x76 0xA8 0xAC |
6
Response type |0x07: Data
Response data 64 x 2 bytes DCS0 followed by 64 x 2 bytes DCS1, 64 x 2 bytes DCS2 and 64 x 2 bytes DCS3
Readout order each: Starts at row 0, pixel 0 … pixel 7 and ends with row 7, pixel 7.
byte 0, 1 each: DCSx, 16 bit 2's complement signed integer. Range: -2'048 … +2'047 LSB
Response e.g. | 0xFA | 0x07 | 0x00 0x02 | 0x12 0x00 … 0x12 0x00 … 0x10 0x00 ... 0x12 0x00 … (512 bytes
total)| CRC (4 bytes) |(DCS0(r0,c0) = 18, DCS0(r0,c1) = 18, DCS0(r0,c2) = 16, DCS0(r0,c3) = 18)
1.11 GET_FIRMWARE_VERSION[0X49]FIRMWARE_VERSION [0x49]
Returns after tPROC the firmware version of the TOF>frame 611: Version. Sensor type. Subversion (V.s.s)
Parameter no, all bytes 0x00
Command e.g. | 0xF5 | 0x49 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0x05 0xA2 0x35 0xB6 |
Response type 0xFE: Data
Response data 4 bytes
byte 0, 1: Subversion s, 16 bit unsigned integer
byte 2,: Sensor type s, 8 bit unsigned integer
byte 3,: version V, 8 bit unsigned integer
Response e.g. | 0xFA | 0xFE | 0x04 0x00 | 0x01 0x00 0x08 0x03 | 0x35 0x33 0x03 0x46 | (Version 3.8.1)]
1.12 GET_DCS_DISTANCE_AMPLITUDE[0X23]
Starts a new acquisition and returns after tPROC DCS, distance and amplitude values as a set.
Parameter no, all bytes 0x00
Command e.g. | 0xF5 | 0x23 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0x85 0xB0 0x29 0x89 |
Response type 0x08: Data
Response data 64 x 2 bytes DCS0 followed by 64 x 2 bytes DCS1, 64 x 2 bytes DCS2, 64 x 2 bytes DCS3,
64 x 4 bytes distance and 64 x 4 bytes amplitude Readout order each: Starts at row 0, pixel 0 … pixel 7 and ends with
row 7, pixel 7.
DCSx byte 0, 1 each: DCSx, 16 bit 2's complement signed integer. Range: -2'048 … +2'047 LSB
Distance byte 0..3 each: Distance, 0.1mm/LSB or status, 32 bit unsigned integer. Zero according the note of
Figure 4. Range: 20 MHz modulation frequency, 0 … 7.5m: 0 … 75'000d
Amplitude byte 0..3 each: TOF amplitude or status, 32 bit unsigned integer.
Response e.g | 0xFA | 0x08 | 0x00 0x04 | 0x26 0x00 … 0x7A 0x00 … 0xEE 0xFF … 0xA5 0xFF … 0x36 0x3d
0x00 0x00 ….0x6E 0x00 0x00 0x00 … (1'024 bytes total) | CRC (4 bytes) | (DCS0(r0,c0) = 38, DCS1(r0,c0) = 122,
DCS2(r0,c0) = -18, DCS3(r0,c0) = -91, distance = 15'670, amplitude = 110)
7
1.13 GET_CHIP_INFORMATION[0X48]ET_CHIP_INFORMATION [0x48]
Returns after tPROC the STM32 Chip ID
Parameter no, all bytes 0x00
Command e.g. | 0xF5 | 0x48 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0x63 0x08 0x35 0x44 |
Response type 0xFD: Data
Response data 12 bytes
byte 0, 3: Chip ID
byte 4, 7:
byte 8, 11:
Response e.g. | 0xFA | 0xFD | 0x0C 0x00 | 44 00 1C 00 04 51 39 33 31 38 37 39 | B1 EC 7E 30 |
1.14 GET_INTEGRATION_TIME_DIS[0X27]_INTEGRATION_TIME_DIS [0x27]
Returns after tPROC the selected or used integration time for distance measurements.
Parameter no, all bytes 0x00
Command e.g. | 0xF5 | 0x27 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xC4 0x3F 0x68 0x4C |
Response type 0x09: Data
Response data 2 bytes: Integration time in microseconds, 16 bit unsigned integer
Response e.g. | 0xFA | 0x09 | 0x02 0x00 | 0x5E 0x01 | 0x83 0xF9 0x91 0xF0 | (350µs)
1.15 SET_TEMPERATURE _SLOPE[0X08]TEGRATION_TIME_DIS [0x00]
Parameter byte 1, 2: Integration time in microseconds, 16 bit unsigned integer
others: 0x00
Command e.g. | 0xF5 | 0x08 | 0x00 0x3B 0x05 0x00 0x00 0x00 0x00 0x00 | 0xB9 0x99 0x3F 0xDE | (value =1339)
Response type 0x00: Acknowledge
8
Response data 0 bytes
Response e.g | 0xFA | 0x00 | 0x00 0x00 | (0 bytes) | 0xB2 0xAB 0xFC 0xE8 |
// compensate
1.16 SET_TEMPERATURE _COMPENSTATE[0X09]TEG
Parameter 0x00 = temperature Compensation enabled;
0x01 = temperature Compensation disabled
others: 0x00
Command e.g. | 0xF5 | 0x09 | 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xBB 0x11 0x80 0x8C | (disable temperature
compensation)
Response type 0x00: Acknowledge
Response data 0 bytes
Response e.g. | 0xFA | 0x00 | 0x00 0x00 | (0 bytes) | 0xB2 0xAB 0xFC 0xE8 |
1.17DRUN_COMPENSATION[0X41]PENSATION [0x41]
Enables or disables the Distance Response Non-Uniformity (DRNU) compensation Output original distance and returns
after tPROC acknowledge.
Parameter 0x00 = Compensation enabled;
0x01 = Compensation disabled
others: 0x00
Command e.g. | 0xF5 | 0x41 | 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xFA 0x7D 0xD6 0x63 | (disable compensation
and Adaptive integration time)
Response type 0x00: Acknowledge
Response e.g. | 0xFA | 0x00 | 0x00 0x00 | (0 bytes) | 0xB2 0xAB 0xFC 0xE8 |
1.18 GET_REGION_LENGTH_WIDTH[0X57]
Return the length and width of the region,default 8*8
Parameter no,all bytes 0x00
Command e.g | 0xF5 | 0x57 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xD7 0x7C 0xB3 0x05 |
Response type 0x0C:Data
Response data 2bytes length and width of the region ,8 bit unsigned integer
9
Response e.g. | 0xFA | 0x0C | 0x02 0x00 | 0x05 0x06 | 0x58 0x42 0x62 0x47 | (length = 5;width = 6)
1.19 GET_REGION_DISTANCE_AMPLITUDE _64[0X28]
Starts a new distance and TOF amplitude acquisition and returns after tPROC the select region result or status. The
amplitude is a quality indicator for the distance result.
Parameter no, all bytes 0x00
Command e.g. | 0xF5 | 0x28 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xAD 0x50 0xAB 0x15 |
Response type 0x0A: Data
Response data 64 x 4 bytes distance followed by 64 x 4 bytes amplitude, total: 2x 256 bytes = 512 bytes Readout
order each, Starts at row 0, pixel 0 and ends with row length, pixel width,other is 0.
Distance byte 0..3 each: Distance, 0.1mm/LSB or status, 32 bit unsigned integer. Zero according the note of
Figure 4. Range: 20 MHz modulation frequency, 0 … 7.5m: 0 … 75'000d
Amplitude byte 0..3 each: TOF amplitude or status, 32 bit unsigned integer.
Response e.g. | 0xFA | 0x0A | 0x00 0x02 | 0x24 0x0F 0x00 0x00 … 0x63 0x10 0x00 0x00 … (2x 256 bytes total) | CRC
(4 bytes) |(distance 387.6mm ... amplitude 4'195 LSB)
1.20 GET_REGION_DISTANCE_AMPLITUDE [0X29]
Starts a new distance and TOF amplitude acquisition and returns after tPROC the select region result or status. The
amplitude is a quality indicator for the distance result.
Parameter no, all bytes 0x00
Command e.g. | 0xF5 | 0x29 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0xCB 0xFA 0xAB 0x15 |
Response type 0x05: Data
Response data length * width x 4 bytes distance followed by length * width x 4 bytes amplitude, total: 2*length *width
x4 bytes Readout order each: length ,width , Starts at row 0, pixel 0 and ends with row length, pixel width.
Distance byte 0..3 each: Distance, 0.1mm/LSB or status, 32 bit unsigned integer. Zero according the note of
Figure 4. Range: 20 MHz modulation frequency, 0 … 7.5m: 0 … 75'000d
Amplitude byte 0..3 each: TOF amplitude or status, 32 bit unsigned integer.
10
Response e.g. | 0xFA | 0x0B | 0xF0 0x00 | 0x24 0x0F 0x00 0x00 … 0x63 0x10 0x00 0x00 … (2x5x6x4 = 240 bytes
total) | CRC (4 bytes) |(distance 387.6mm ... amplitude 4'195 LSB)
1.21 SET_ADAPTIVE _INTEGRATIN[0X55]TEG
Parameter 0x00 = adaptive integration enabled;
0x01 = adaptive integration disabled
others: 0x00
Command e.g. | 0xF5 | 0x55 | 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | 0x66 0XE9 0XD2 0xBE | (disable temperature
compensation)
Response type 0x00: Acknowledge
Response data 0 bytes
Response e.g. | 0xFA | 0x00 | 0x00 0x00 | (0 bytes) | 0xB2 0xAB 0xFC 0xE8 |
11