Skip to content

Instantly share code, notes, and snippets.

@rjehangir
Created April 28, 2017 18:43
Show Gist options
  • Save rjehangir/a7b58013f09b4d8517affb7c40bb772f to your computer and use it in GitHub Desktop.
Save rjehangir/a7b58013f09b4d8517affb7c40bb772f to your computer and use it in GitHub Desktop.

Ping Protocol

Serial communication protocol for the Ping and other Blue Robotics products.

Table of Contents

Format

Byte Type Name Value
0 uint8_t start_byte_1 "B"
1 uint8_t start_byte_2 "R"
2-3 uint16_t length payload length in bytes (could be 0)
4-5 uint16_t message_id Message identifier
6 uint8_t src_device_id Ping device ignores packet unless: 1. dst_device_id == Ping's device ID,
7 uint8_t dst_device_id or 2. dst_device_id == 0xff (broadcast), or 3. src_device_id == 0 && dst_device_id == 0 (legacy)
8-n message specific payload bag of bytes. meaning depends on message
(n+1)-(n+2) uint16_t checksum (sum bytes 0-n) & 0xffff

General Messages [Name : ID]

Goto Bootloader [gen_goto_bootloader : 100]

Sends a device into bootloader mode for flashing firmware updates.

Get Version [gen_get_version : 101]

Gets information about the device and firmware version.

Type Name Value
u8 device_type 0=unknown, 1=echosounder, 2=mechanical scanning
u8 device_model See future table of models for each deviceType category (1=Ping)
u16 fw_version_major Major firmware version number
u16 fw_version_minor Minor firmware version number

Reset Device [gen_reset : 102]

Reboots the device.

Set Device ID [gen_device_id : 110]

Sets the ID of a device. Request this message from device 255 to get the address of all of the connected devices. Useful for recovery a lost device ID.

Type Name Value
u8 ID 1-254 are valid values (default value is 1)

Check for new data [gen_new_data : 112]

Useful for determining when a device has a new reading available.

Type Name Value
u8 is_new_data 0=no new data available, 1=new data available since last call to "gen_new_data"

Request [gen_cmd_request : 120]

Request a message from a device.

Type Name Value
u16 request_id Message ID requested

Sonar Messages

Set Sound Velocity [sonar_set_velocity : 1000]

Set the speed of sound in your application.

Type Name Value
u32 c_water Speed of sound in water - mm/sec (1,500,000 is default)

EchoSounder Messages

Simple Distance [es_distance_simple : 1100]

Just returns the distance and confidence without extra metadata.

Type Name Value
u32 distance Measured range mm
u8 confidence confidence of smoothed range, 0-100 (% of recent readings that were not outliers)

Distance [es_distance : 1101]

Full distance message including metadata.

Type Name Value
u32 distance Measured range mm
u8 confidence confidence of smoothed range, 0-100 (% of recent readings that were not outliers)
u16 pulse_usec Pulse length in µs
u32 ping number counts the pings since power up
u32 start_mm start range of returned profile
u32 length_mm end_mm = start_mm + length_mm
u32 gain_index Analog gain index

Profile [es_profile : 1102]

Full sonar profile data.

Type Name Value
u32 distance mm
u8 confidence Percent confidence, 0-100
u16 pulse_usec Pulse length in µs
u32 ping number counts the pings since power up
u32 start_mm start range of returned profile
u32 length_mm end_mm = start_mm + length_mm
u32 gain_index Analog gain index
u16 num_points Number of data points returned Note: Fixed at 200
u8 [num_points] data Echo data array

Range [es_range : 1110]

The range that an echosounder is scanning in.

Type Name Value
u32 start_mm
u32 length_mm

Mode [es_mode : 1111]

The mode setting for echosounders. Automatic or Manual.

Type Name Value
u8 auto_manual 1=auto, 0=manual

Rate [es_rate : 1112]

The rate that an echosounder is scanning at.

Type Name Value
u16 msec_per_ping 0=disable continuous ping, otherwise min msec_per_ping = 100 (10 pings/sec)

Gain [es_gain : 1113]

The sensitivity of the receiving transducer.

Type Name Value
u32 gain_index 0-8 are valid settings

Pulse Length [es_pulse : 1114]

The length of the emitted pulse in echosounders.

Type Name Value
u16 pulse_usec Device specific (in microseconds)

Voltage [es_voltage : 1115]

The supply voltage, in millivolts.

Type Name Value
u16 voltage 0 - 65535 (5000 nominal)

Mechanical Scanning Sonar Messages

Angle Profile [mss_angle_profile : 1201]

Returns the response data for a single angle.

Type Name Value
u16 angle Head angle in centidegrees (359 degrees = 35900)
u16 pulse_usec Pulse length in µs
u32 range_mm Range of returned profile
u32 gain_index Analog gain index (device specific)
u16 num_points Number of data points returned
u8[num_points] data Response data

Range [mss_range : 1210]

The range that the scanning sonar is scanning in.

Type Name Value
u32 range_mm

Mode [mss_mode : 1211]

The mode setting for the sonar. Automatic or Manual.

Type Name Value
u8 auto_manual 1=auto, 0=manual

Gain [es_gain : 1212]

The sensitivity of the receiving transducer.

Type Name Value
u32 gain_index Device specific gain setting

Sector Configuration [mss_sector : 1213]

Configures the desired sector for scanning.

Type Name Value
i16 train_angle -18000 to 18000 centidegrees
u16 sector_width 0 to 36000 centidegrees
u8 step_size Step size index (device specific)
u16 pulse_usec Pulse length in µs
u16 sample_size Number of data points to return (0 for auto)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment