ece4160

Lab 3: Time of Flight Sensors

Prelab

The expected I2C address for the TOF sensors was 0x52, according to their datasheet. Two sensors will be used, only one of which will have its XSHUT pin soldered to the Artemis because only one sensor needs to be shut down while the other one gets its address changed. This would be more efficient than utilizing the XSHUT pins of both sensors.

Two sensors were used in order for the robot to be able to sense objects in more than one direction, allowing for better mspping of its path. In order to cover the widest possible area of the robot’s motion, I would place one sensor on the front of the robot and one on its side. However, blindspots would still exist due to the angular sensitivity and limited range of the robot, which could impact situations such as performing turns.

Screen Shot 2023-02-20 at 5 46 57 AM

Lab Tasks

Screen Shot 2023-02-20 at 5 49 12 AM

I first connected one TOF sensor and the IMU to the Artemis. The TOF sensor address outputted when running Example1_wire_I2C.ino was 0x29, not 0x52 as expected. However, this makes sense because the number 0x29 consists of the read/write bit as the most significant bit followed by the address bits, and 0x52 shifted right by one position equals 0x29.

Screen Shot 2023-02-20 at 3 01 58 AM

The TOF sensor has two modes, setDistanceModeShort(), which has a shorter range of 1.3m and setDistanceModeLong() which has a longer range of 4m. I chose to use setDistanceModeShort() because the short range mode is less affected by ambient light than the long range mode, allowing for more accuracy in making quick decisions. For now, a range of 1.3m seems sufficient.

I first hooked up one sensor and ran Example1_ReadDistance.ino on the Artemis, and was able to successfully receive an output.

Screen Shot 2023-02-20 at 6 48 54 AM

By moving an object as far away from the sensor as I could, I was able to measure a maximum range of the TOF sensor was 2269 mm, which was higher than the expected range for the short range mode.

Screen Shot 2023-02-15 at 4 03 18 PM

For my accuracy and repeatability measurements, I took 50 points at each distance specified and used them to find the mean and standard deviation. The sensor was very accurate for a distance of 100mm and got less accurate as the distance increased. Its repeatability was high, as the maximum standard deviation was 1.485. The standard deviation increased as the distance measured increased.

Distance (mm) Mean (mm) Standard Deviation (mm)
100 101.9 0.9434
200 205.6 1.168
300 308.4 1.410
400 409.6 1.485

Unknown-11

I also found that the ranging time was 52 ms, using the code below and averaging the time measured across 10 cycles.

Screen Shot 2023-02-20 at 4 22 26 AM

I then hooked up the other sensor as well to the QWIIC breakout board and modified Example1_ReadDistance.ino, as shown below.

Screen Shot 2023-02-20 at 6 18 11 AM Screen Shot 2023-02-20 at 6 20 48 AM

Both sensors were able to output data parallelly as Distance 1 and Distance 2.

Screen Shot 2023-02-20 at 6 35 43 AM

I found the speed of the loop to be 91 ms by printing out the timestamp, by calling millis() as seen in the code and serial monitor output above, at the beginning of each loop and averaging the time between timestamps across 10 loops. The current limiting factor is the time it takes to print all of the data to the serial monitor.

I then sent data collected over 5000 ms to the Python end via Bluetooth. I created a command in ble_arduino.ino called GET_TOF for this purpose.

Screen Shot 2023-02-20 at 6 46 44 AM

The data received is plotted below. The lines are nearly flat because the sensors were not being moved around while the data was being collected.

Unknown-12