SLAAEM0 June   2024 MSPM0C1104 , MSPM0C1104 , MSPM0L1105 , MSPM0L1105 , PGA460 , PGA460

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
  5. 2Hardware Introduction
  6. 3Software Introduction
    1. 3.1 MCU Initialization
    2. 3.2 PGA460 Initialization and Configuration
    3. 3.3 Distance Detection
  7. 4Evaluation Steps

Distance Detection

After the initialization and default configuration update of the PGA460, the system is able to continuously execute the burst-and-listen command to retrieve the resulting measurement data. Figure 3-7 illustrates the operational process of the PGA460.

PGA460, MSPM0  PGA460 Run Operation Figure 3-7 PGA460 Run Operation

The operation includes four steps, the first step is to send running commands from MCU to PGA460, as shown in Figure 3-8. In this function, preset 1 (P1) or preset 2 (P2) can be selected, if a Burst & Listen command or Listen Only command is issued. Here, preset 1 (P1) was chosen.

PGA460, MSPM0  UltrasonicCmd Function Figure 3-8 UltrasonicCmd Function

The second step is to wait for some time until the distance detection is finished. The decision was to wait for 200ms. Here, one cycle points to the CPU cycle, which runs with 24MHz.

The third step is to convert time to distance. The PGA460 device captures the interrupt time and outputs the distance equivalent, width, and peak amplitude for the returning echoes when the threshold is intersected. In this solution, only distance measurement result is needed. To solve for the time-of-flight, use velocity = distance/time. Because the speed of sound is typically at a value of 343m/s at room temperature, and the PGA460 device outputs the round-trip time at which the threshold is intersected in 1-μs resolution after bursting. The distance to the object is computed as the product of velocity and one-way time. Use Equation 1 as the PGA460-specific equation to solve for distance in meters.

Equation 1. d i s t a n c e m = 343 m / s 2 * o b j M S B 1 8 + o b j L S B 2 * 0.000001 + 343 m / s 2 * P u l s e s * 1 F r e q u e n c y

As this demo only shows the basic function of PGA460, be sure to keep the digitalDelay to be 0, as shown in Figure 3-9. For more accurate distance detection, you should change its value according to your real setting.

PGA460, MSPM0  Digital Delay
                    Configuration Figure 3-9 Digital Delay Configuration

The final step is converting a measurement result of double type to a string type and send it to PC from UART in uartSend function with 9600 baud rate.