Both sensors will be placed at the front of the car, each slightly angled to face either the left or right side. Placing both ToFs at the front expands the car's field of view. However, the car may miss side obstacles if they are not initially visible from the front, for example dynamic obstacles approaching from the side.
To use two ToF sensors, I will use the xshut pins ( pins 7 and 8 on the MCU) to change the address of one sensor from 0x29 to 0x30 while it is powered. The sensor configuration code is shown below.
The displayed I2C address is 0x29, which matches the expected value because 0x29 is 0010 1001 in binary. An I2C address consists of bits 1-7 representing the unique address of the slave device, and a Read/Write bit at bit 0. The last bit being 1 indicates that we are reading from the ToF sensor, which is expected.
Using the short distance mode increases immunity to ambient light and noise. However, it limits the detection range. The long mode allows detecting objects up to 4 m but is more susceptible to noise. The medium mode is a compromise between the two. For the RC car, the short range is sufficient since 1.3 meters is enough for the car to react to obstacles, and the higher noise immunity improves performance.
The sensor was tested in rooms with high artificial light, low artificial light, and a mix of natural and artificial light. Errors start increasing linearly at about 60 cm and rise drastically near the maximum range of 130 cm. The precision graph shows the sensor is accurate except in dark environments.
The average of 10 readings shows a ranging time of approximately 97.6 ms. Ranging time did not increase with different modes.
In the sped up code, the time between consecutive readings of A and B ToF sensor svaries between 10–25 ms, and consecutive A and B readings vary between 100–200 ms. The limiting factors in the transmission speed include Serial print delays and the intrinsic time required to collect and validate data.
The color tests show that darker materials appear closer due to light absorption. Very light materials, like white, may over-report distances slightly due to placement discrepancies during measurement.
Texture did not significantly affect measurements. Velvet overestimated distance by almost 2 cm, but other materials had minimal impact on light scattering.
Besides Time of Flight sensors, there are Amplitude-based IR sensors and IR triangulation. Amplitude-based IR has a high sampling rate and small size but is sensitive to ambient light. IR triangulation is less sensitive to surface color/texture but has a larger form factor and lower sampling rate.
Class notes were used for information on IR distance sensors, and Gemini was used to process ToF sensor characterization data.