SLAAEM0 June 2024 MSPM0C1104 , MSPM0C1104 , MSPM0L1105 , MSPM0L1105 , PGA460 , PGA460
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.
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.
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.
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.
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.