ECE3400

Light Following Robot – Part 1

In this part I first set up the circuit for two light sensors using voltage divider following the diagram below:

After this I calculated the Normalized Measurement for left and right sensors following the equation below:


Here is an example of the calculated values for the sensors when they are placed on the table with no specific interference:


Light Following Robot – Part 2

In this part we used the H-bridge to connect our Arduino Nano Every with the motor and control it by sending PWM signals. First we tested out the H-bridge. Following the diagram we connected both motors to the H-bridge's outputs:


We then connected 2 GPIO pins that can send PWM signals to the Enable pin on the H-bridge and 2 other free GPIO pins to the input for two motors. The picture below shows the connection:


We incorporated the photosensors and designed it so that the robot spins around in circles when no flash light is applied or the surrounding is too bright. One thing we noticed was that the two motors are not the same even when same speed are applied to them and we need to test what are the correct values to set for them to move in straight line. We also set the LED blinking to notify the user when it is moving in straight line or not. When using flash light to shine briefly on either side, the LED will be off and the robot will turn towards the direction where your light is until it faces the light source. When the robot is facing the light source, it moves forward and when your light source is turned off, it spins around in circles again with the LED turned on. The picture below shows when the robot is moving forward when the light source shines equally on both sensors.

Part 3

Lab 3 was separated into 3 parts. For the first part we learned how to use LTSpice by drawing a low pass RC circuit and a high pass RC circuit. Pictures below shows the low pass filter and its cutoff frequency: image low-pass Pictures below show the high pass filter and its cutoff frequency: image high-pass In this section we learned how to use LTSpice to simulate circuit and use the data it provides. Then we built the microphone circuit without amplification following the picture below: image circuit

We then characterize the circuit using Arduino and MATLAB. For the Arduino part, NANO collects sound from the microphone we built and we manually code the ADC and convert the ADC value read in to a signed 16 bit number so that we can use it for MATLAB. For MATLAB, we play a sound with increasing frequency at around 500Hz for around 2 seconds and take the data from Arduino's serial port. We then perform Fourier analysis so that we can plot the data out. We then will have a time domain graph and a frequency domain graph.

For the second part, we built the amplified circuit following the picture below: image pic

We the get the amplified signal shown below. Here we can clearly see that the peak is at around 500Hz. 4

Then we test our low pass and high pass circuits. To do so we need to take system's frequency response data simulated by our LTSpice module which is considered to be the theoretical result. We compare the experimental frequency response with the theoretical one to see how much is amplified. The experimental data is the ratio between the output signal's spectrum divided by input signal's spectrum. Here we encountered a problem because the microphone is so fragile, it made it hard to make sure other environments stay exactly the same when we are collecting data. The picture below shows the compared result for low pass, high pass, and bandpass circuits: low_pass high_pass band_pass

Last part we practiced to do FFT on Arduino. We will set ADC in free-running mode and use interrupts on TCA to read in data and output it to the Serial Monitor. We then test it with MATLAB by using it to play the sound and plot the data from serial port but this time without doing FFT. Pictures below show spectrums for sound frequency of 500 Hz, 700 Hz, and 900 Hz: 500 700 900

Part 4

In lab 4 we combined all we had so far and with the Ultrasonic sensor to make a light following robot that can sense object within certain distances and stop if it gets too close. In the first part we tried to play with the Ultrasonic sensor and measure how accurate it is for certain distances. We tested out 2, 4, 6, 8, 10, 15, 20, 30, 40, 50 cm and plotted a graph to show the accuracy. From the graph below we can tell that the sensor not as accurate when it is reaching 50 cm. So in the demo we tried not to exceed that distance when we place obstacles. US Measurement Then we try to combine the moving wheels with the sensor and have our robot move in circle and make the LED blink to indicate that it senses an object. They layout is similar to the graph below but we make the distance shorter while keeping the proportion since the sensor is not as sensitive when it reaches 50 cm. We made our distance 5-6cm and the other one 12-15cm. image This time we also added the sound detection to it. So the robot will start spinning when it detects a 550Hz sound.

The second part of the lab, we took away the sound detection part but add light sensing detection to it and follow the path shown below: image So this time we not only shine the LED to indicate we encounter obstacles, the robot will stop if it is 5 cm away from an object. Like before we use flash light to guide the robot: it moves left and right when the light is on the corresponding side and it moves straight when the light is right in the middle. So we started with moving directly into object 1 and then when it is less than 5 cm the robot stops. Then we tried to lure it to the left and it won't work and lure it to the right to make it move again. Then we guide our robot to the second object where it stops again within 5 cm and this time we make it run back to the other side of object 1 and see it stops again. Then we have it spin 360 degree to move towards object 3. The same thing happens and we make sure it doesn't go further even when we have the flash light in the middle. Just like what the picture shows below: 61870c134e2fe4a5f5f60e5c7e963ca