Hello .I have a problem . I need more information about Ping-Protocol .You can send a simple example to connect PING-SONAR-R2-RP .but I need a C Library .You have a C++ Library in your web site .But I need a C library .because I used AVR microcontroller with AVR studio .
For a example a need to request a distance_simple …How to ma ke a format message to send a sonar sensor
Byte 0 :“B” 0x42
Byte 1 : “R” 0x52
Byte 2-3 0x0005
Byte 4-5 0x1211
Byte 6 0x00
Byte 7 0x00
Byte 8-12 ?
Byte 13 check sum
The message ID of general_request is 6, so this value should be used in message_id field.
Usually the master [parent], your AVR, will use the ID 0 and the slave [worker], in that case Ping, will boot with ID 1, you can also use 0 as dst_device_id to do a broadcast. This values should be used in src_device_id and dst_device_id
respectively.
Since the payload of general_request is two bytes, you should use this value in payload_length, in your case 0x04BB for distance_simple (ID 1211).
Byte
Value
Type
Name
Description
0
‘B’
u8
start1
‘B’
1
‘R’
u8
start2
‘R’
2-3
0x0002
u16
payload_length
Number of bytes in payload.
4-5
0x0006
u16
message_id
The message id.
6
0x00
u8
src_device_id
The device ID of the device sending the message.
7
0x00
u8
dst_device_id
The device ID of the intended recipient of the message.
8-9
0x04BB
u8[2]
payload
The message payload.
10-11
0x015B
u16
checksum
The message checksum. The checksum is calculated as the sum of all the non-checksum bytes in the message.
With the created package, you should send the bytes in little-endian format: 0x42, 0x52, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0xBB, 0x04, 0x5B, 0x01
The return from the sensor will be: 0x42, 0x52, 0x05, 0x00, 0xBB, 0x04, 0x00, 0x00, 0x5B, 0x1D, 0x00, 0x00, 0x64, 0x34, 0x02
And you can unpack the information using the same logic behind the pack method.
The message distance_simple returns a message with a payload of 5 bytes, where the first 4 is the distance and the last one the confidence, you can check that in the documentation here.
Byte
Value
Type
Name
Description
0
‘B’
u8
start1
‘B’
1
‘R’
u8
start2
‘R’
2-3
0x0005
u16
payload_length
Number of bytes in payload.
4-5
0x04BB
u16
message_id
The message id.
6
0x00
u8
src_device_id
The device ID of the device sending the message.
7
0x00
u8
dst_device_id
The device ID of the intended recipient of the message.
8-11
0x00001D5B
u32
distance
Distance to the target.
12
0x64
u8
confidence
Confidence in the distance measurement.
13-14
0x0234
u16
checksum
The message checksum. The checksum is calculated as the sum of all the non-checksum bytes in the message.
The conversion of distance and confidence from hexadecimal to decimal is 7515mm (7.515M) and 100% respectively.
You can also check the checksum to be sure that the message is not corrupted, and the message_id to check if the message is the one that you are waiting for.
Note: You should use C++ and not C, my avr-gcc version is 9.1.0 and supports C++17.
Helllo .I am working in a echo sonar to detect fishes.I need to known the distance from sensor to fishes .I going to use The message profile (Message id:1300) . This Message return array profile_data . What is the profile data ? Can I detect fishes or another objects from the profile_data message ?
An array of return strength measurements taken at regular intervals across the scan region.
About the fish detection, probably it’s possible, but it may be necessary to tune the gain and disable the auto operation mode. Some tests need to be done to be sure.
Hello .I have a question . You can see it in the output. It is in data["profile_data"] . 'profile_data': "\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd'0\x08\x00\x01\x01\x08\x01\x00\x01\x00\x02\x04\x03\x06\x08\x10\x03\x00\x01\x00\x00\x00\x00\x03\x01\x01\x01\x03\n\x03\x03\x01\x00\x03\x08\x03\x03\x00\x00\x00\x02\x02\x05\x00\x00\x00\x00\x01\x05\x01\x04\x04\x06\x06\x00\x00\x00\x00\x01\x00\x02\x02\x02\x02\x00\x00\x02\x03\x00\x00\x00\x00\x00\x03\x04\x03\x00\x00\x00\x00\x03\x02\x05\x04\x04\x04\x00\x01\x00\x00\x00\x00\x00\x00\x03\x03\x03\x01\x00\x00\x00\x00\x00\x00\x00\x03\x05\x04\x02\x00\x00\x01\x02\x0b\x0c\x04\x07\r+?5.\x16\t\x02\x07\x01\x01\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x00\x00\x04\x02\x03\x05\x00\x00\x01\x01\x00\x00\x03\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00.\xfd8\x00"
Hello.I have a question about message profile (1300) . The python library code do not return profile_data_length (The length of the proceeding vector field) . I need to know that minimal distance(mm) between profile_data [0] ,profile_data [1],profile_data[2] …,profile_data[n]. because .I am goint to graph profile_data vs time to detect objects .
Check the profile message documentation.
You can use scan_start and scan_length to calculate the “position” of each point in the profile_data array.
Type
Name
Description
Units
u32
scan_start
The beginning of the scan region in mm from the transducer.
mm
u32
scan_length
The length of the scan region.
mm
From your previous result, with the values: ‘scan_start’: 0, ‘scan_length’: 1000, this 200 points are mostly equally spaced between this distance.
So profile_data[0] represents 0mm, profile_data[1] represents 5mm and etc.
I’m coding this protocol (1300). I don’t see the number of profile_data data specified in the protocol. What rules does he use to determine the number of data? What is the maximum and minimum limit?
Most of the other protocols have been implemented. From Ping view, parameters can be set and basic information such as version number, temperature, voltage can be obtained.
The length of the profile array is in profile_data_length, you can check that in the documentation here, for Ping1D this number is fixed in 200 and can not be controlled.
Another question is how to respond if you send 1212 and 1300 when Ping is disabled. My current processing is not to respond. The debugging information of Ping view will report that a packet has been lost and no other errors have been seen. Can this be done?
After trying to get the waterfall map, distance determination and gain adjustment have not been added yet, but the protocol is basically fully available.
Using a 40K sensor in the air, the measuring distance can reach about 6 meters.
Hi, right now Ping will answer 1212-distance message with the last valid distance calculated by the sensor in the last time that the sensor was enabled. For the 1300-profile the sensor will not reply. Since this messages are Ping specific, future updates of the sensor firmware can change this behavior.
Yes, this can be done. We are working heavily in ping-viewer, so stay tuned.