In the first stage of our project, I created a 3D model for mounting Ultrasonic Ping sensors on the Mbot, taking into account the hardware that was already in place. The main difficulty was coming up with a design that would enable the integration of these sensors without interfering or disrupting the already-installed parts.
image source: https://pinout.xyz/pinout/wiringpi from this website
fig(1) showing GPIOS and there wiring pi
Code Explanation:
The core of our project involved writing C++ code to interface with the Ultrasonic Ping sensors. I used the wiringPi
library. The code was structured to trigger the sensors and measure the time taken for the echo to return, thereby calculating the distance to an obstacle. Each sensor functioned independently, providing comprehensive coverage around the Mbot. The image above was really helpful in the process.
Initially, the program sets up the GPIO pins, configuring the trigger pins as outputs and the echo pins as inputs. For each sensor, a high signal is sent through the trigger pin, followed by a low signal, initiating the ultrasonic pulse. The program then waits to detect the signal’s return on the echo pin. By recording the time between sending and receiving the pulse, the program calculates the distance to the nearest object. These steps are encapsulated in functions dedicated to each sensor, and the main loop of the program calls these functions repeatedly to print out the distance measurements.
Pseudocode
Initialize GPIO pins for each ultrasonic sensor
For each sensor:
Send a HIGH signal to the trigger pin
Wait for the echo pin to go HIGH
Record the time until the echo pin goes LOW
Calculate the distance based on the time elapsed
Output the calculated distance
Fabrication choice and process
A critical phase of the project was designing a mounting plate for the sensors. Using 3D modeling software, I created a detailed cover for the model in Autodesk inventor. It was also hard to come up with the design because this was specifically used only for the robot integration with the sensors. The screenshot of the 3D model provides a clear view of the layout and positioning of the sensors. Then, I 3D printed the sketch. I had difficulty in mounting it to the robot because only two sides of the robot had places where I could mount the sensors. I had to figure out how to add the third sensors so that the sensors can detect the obstacles in every direction. I solved it by putting two sensors sideways but in different directions.
fig(2) : Autodesk inventor design for sensors mounting in the robot
Challenges
I encountered many challenges in our effort to improve the Mbot with a Low-Lying Obstacle Avoidance System, especially when integrating several ultrasonic sensors. A major obstacle was reliably detecting obstacles, which required consistent accuracy in sensor readings. Two of the ultrasonic sensors produced trustworthy data and operated as planned. Nevertheless, I had issues with the third sensor, which wasn’t working properly. Following careful analysis, I postulated that a connection issue on the breadboard may be the cause of the problem. This demonstrated how crucial it is to pay close attention to hardware connections, particularly in intricate circuits.
I also had a challenge of connecting the different components of the sensors to the Rasperrby pi GPIO’s because I didn’t have much experience working on it. However, The website really helped me along with TA to work on this project. It was a really rewarding experience as I got to learn about the hardware part of the side where I never had explored. I found it really interesting and will try to work more on the projects like this.
Sources
Wiringpi at raspberry pi gpio pinout. WiringPi at Raspberry Pi GPIO Pinout. (n.d.). https://pinout.xyz/pinout/wiringpi