How Can We Help?

Print

Read and retrieve data from a TF-Luna LiDAR distance sensor via the ACE’s RS232/485 port

 

Here, we are going to see how to extract data from a HEXA frame. An example with a LiDAR sensor

This radar has a TTL serial output. A TTL to RS232 converter will need to be added to connect it to an ACE RS232.

Data and its analysis

This LiDAR send by default every 10 ms this data frame:

  • Dist: Distance in cm
  • Amp: Signal strength indicator
  • Temp: Celsius temperature = Temp / 8 – 256℃

In this example, we will see how to extract the data Dist Amp Temp position 2 to 7 in the data frame.

Example for Dist:

 

The data is composed of 2 bytes, position 2 and 3.

For a distance of 157 cm, we receive this data : 59599D003C07780913. We want to extract the value in bold: 9D 00

  • 9D in HEXA (base 16) = 157 in DEC (base 10) : It is the least significant bit (LSB)
  • 00 in HEXA (base 16) = 0 in DEC (base 10) : It is the most significant bit (MSB)

If we apply the weight to the MSB: [ 157 ] + [0 * 256 ] = 157, the number we want as result!

If the distance was 587, it would be : [ 75 ] + [2 * 256 ] = 587

The first start code of the data frame is 59 in HEXA = 89 in DECIMAL

Data analysis on PC with the realterm software

 

vBuilder: Listen the ACE serial port

  • listens to the serial port waiting to receive the “Start Character” 89 (59 in HEXA)
  • counts the number of bytes received
  • stores the data frame in the receive array RX[ ], of a length determined by the number of bits received Bytes Received
  • Minimum Break determines the minimum silence time to be taken into account in order to consider that the whole frame has been received (Time between 2 frames)

Check the data frame

After receive the data frame, we can check if the 1st and 2nd character are 89

If this is correct, we can move on to step 2.

Calcul each value, Dist, Amp and Temp

Temp : Température Celsius = Temp / 8 – 256℃

Try the subroutine

You can download the program Here