Skip to the content.

LAB 3

Lab 3

Write Up:

Lab 3 considered of four stages: connection layout, hardware assembly and soldering, IMU and TOF configuration + preliminary testing, and IMU and TOF fine-tuning.

The connection layout process involved designing a wiring scheme to connect the 2 TOF’s and IMU to the artemis board. In order to provide the same voltage to each sensor, the connections were set in parallel, splitting the current from QWIC connector amongst the three devices. Using the data sheet, the QWIC connector pin order was determined and the SDA and SCL were planned to be chained amongst all three sensors, resulting in all three sensors sharing a single SDA and SCL line. To manage the 2 TOF’s (since they have the same address), the XSHUT pin of one of the TOF’s was schemed to be wired the digital pin number 4 on the artemis.

The hardware and soldering stage involved several steps. The first step was to figure out a way to chain the various sensors in parallel. The solution invovled soldiering two wires together and outletting on of the wires to the current sensor while the other heads to the next sensor. The order followed was Artemis QWIC -> TOF_1 -> IMU -> TOF_2. Additionally, a wire stretching from digital pin 4 to the XSHUT pin of TOF_1.

For the configuration step, the address of the single TOF was read first using the WIRE_I2C example provided. The address read was 0x29 while the data sheet provided address was 0x52. This occurs because the address in the data sheet includes the Read/Write bit in the LSB spot. As such the initial address in binary is 01010010. When the LSB is removed, the address is 0101001 which in hex is 0x29 as seen. The Wire_I2C.cpp file was later abondened due to the ainability to read the address of more than two devices. To test the effectiveness of a single TOF, the Example1_Read Distance file. To test the IMU, the Example1_Basics file was utilized. The example file for the TOF worked by activating the I2C wire, creating a TOF object, beginning ranging, storing the recorded distance, and stopping ranging. The IMU example code worked in a relatively similar fashion where the I2C wire is activated, the sensor variable is created, and values aare read using provided library methods. The primary point of importance here is the ADD_VAL macro in the IMU exampl.e Sinc3 the ADR_JUMPER is wired on the artemis, the value is set to 0.

For the actual execution of the tasks, firstly, the various distance modes were experimented with. As suggested by the methods name, the short mode for the TOF worked very well with very small distances; however, there was a noticeable lack of stability when trying to detect longer distances. The inverse was true for the long mode. Since the robot is likely to run within a relatively confined space, the short mode would be more effective. This would allow sensing the distance from potential walls or barriers more accurately and effectively. In order to chane the address of a second TOF, setI2CAddress() method was utilized. THe change is documented here:

image

The code above shuts down TOF_1 and changes its address to 0x49 which is not an already occupied device address.

Secondly, the IMU task involved several steps. The inital reading from the IMU provided the accelerations across each axes, the rotation along each axis, the magnetometer data, and the measured temperature. The changes along the axes as the IMU was constantly tilted was clear. In order to determine the cutoff frequency and thus the alpha for complimentaary filters, taapping along the pitch and roll axes were used. The base pitch was calculated using the artctan2 of (accX/accZ), and the base roll was calculated using atan2 of a_y/a_z. By performing FFT data analysis on the base pitch and roll resulted in signficant noise for the roll and minimal noise for the pitch. The sampling frequency as noticed from time tracking was 8ms and thus with the maximal possible bandwidth being f_s/2 = 1/0.008/2 = 62.5 Hz. The taps were approximately timed for every seconds alternating in each direction. The pitch and roll taps and tests were done seperately.

Then initial results are included in the pictures below:

Screen Shot 2022-02-19 at 2 06 00 PM Screen Shot 2022-02-19 at 2 06 20 PM

Screen Shot 2022-02-19 at 2 17 00 PM Screen Shot 2022-02-19 at 2 17 08 PM

Since the Pitch has extremely minimal noise, the cutoff frequency considered was approximately 62 Hz. Using this cutoff frequency, the alpha determined was 0.76. Since the noise is extremely high, the cutoff frequency considered was aapproximately 35 Hz to cutoff a second wave of spikes starting after 35 Hz. The determined alpha was 0.637.

For the gyroscope, the values were recorded much more easily since calculations were minimal. The dt utilized was 8ms since that waas the sampling period. The initial data included a signficantly amount of drift. Unfortunately, this result could not be recorded since the Serial plotted does not work on the MAC. To avoid this drift and attain stability with minimal noise, a complementary filter with both the gyroscope reading and the accelerometer reading. Various alphas were tested, and the alphaa that minimized drift and noise was determined to be 0.75 for pitch and 0.7 for roll. The resulting FFT graphs from a repeated tap experiment are included below:

image

Screen Shot 2022-02-19 at 2 59 11 PM

The drift was also noticed to be signficantly lower though still present.

The amendments to the existing IMU:

image

image

image

Finally, the following two loom links involve the final results from values of the accelerometer and TOF.

TOF - EXECUTION

The TOF video shows four stages in this order: both sensors moving away from the surface, one sensor moving towards the surface, the other sensor moving towards the surface while the other is held constant, and both move towards the surface.

IMU - EXECUTION

The IMU video simply shows the change in pitch and roll.