The Self-Driving Toy Car using ATmega1284 microcontroller

“A car that can track its own location and calculate the direction and distance needed to get to a final destination given by user inputs.”
Elevator Pitch

For our final project, we built a self-driving car that takes in inputs for a final destination and drives itself from its initial location to the final destination. The idea for this final project requires an LCD to display the location that the car is already at and allows a user to input coordinates for where he or she would like the car to drive itself to. By using a GPS receiver, the car can track its initial location and use the compass to direct where it should go, constantly updating its GPS location. This idea was chosen because of an interest in GPS and because we both wanted to try something different from our usual lab assignments and something new outside our scope of knowledge.
Self-Driving Toy Car

High Level Design

Goal

The goal of our project was to design and fabricate a low cost self-driving toy car. The rationale behind this project was to utilize every day materials for a low cost self-driving car that could be used to help take a person from point A to B. Since commercial GPS units are relatively straightforward devices, the main goal for this was to use its data and be able to extract needed information from it.
This self-driving toy car was done by having the central unit connected to a GPS receiver and compass send information to the microcontroller to determine where the car is and continue to send coordinates in order to see whether or not it is making progress towards the final destination. With the central unit receiving information, the compass will have its data also read by the MCU to see the direction the car is facing and to help determine which turns the car needs in order to arrive at its final destination.

Societal Impact

There are always alternatives to ease a person’s drive from here to there. Starting with cruise control, which only monitors one’s speed, and then leading to recent self parking cars or Roombas or self driving cars, there has been a growing field and research into self operating systems. This societal impact also had an affect on what led us to this idea of a project.

Background Math

Background math required geometry to figure out the angle and also which direction the car should move towards. In addition to this, there was additional arithmetic needed to understand the movement of the car and the algorithms used to find the angle and using that to move the car closer to its final destination.

Block Diagram

The logical structure of this car can be seen in the block diagram below. This displays the main set up of the core control of the toy car.
The microcontroller used was the ATMEGA1284. This acted as the main source to handle the compass, GPS, LCD and car motor. The arrows point to the direction that is being used. The microcontroller uses the GPS coordinates and compass angle from the respective devices as input and then outputs to the motor and LCD the results. However, in order to do obstacle avoidance, we added an additional board, the Raspberry Pi Board.

Tradeoffs and Issues

Issues that arose were the powering supplies and the electromagnetic interference that could be caused inside certain buildings and the lack of signal for the GPS receiver. The powering supplies, if not maintained at a certain voltage or above, would prove to not provide enough power to the motor to give it enough thrust to continue movement. In addition to that, by calling several components off the three 1.5 V batteries, the batteries quickly deteriorated or were not distributed correctly. In order to remedy this, we used the Raspberry Pi Board voltage sources to pull the GPS off the 3.0 V from the three 1.5 V batteries below that was also connected to the motor and compass. This alleviated the stress on those batteries and provided smoother route movements in the code.
Another tradeoff was that because the GPS needed a 3.3 V supply at its optimal value and the Raspberry Pi Board provided exactly that, we decided to add that extra weight for the Raspberry Pi Board battery in order to have this source. In addition to having this extra component, this leads us to having more applications be built upon this system onto the Raspberry Pi Board specifically such as obstacle avoidance.
Lastly another issue that arose while testing was the compass angle. Since the compass needs to be on a flat surface or an evenly inclined surface, any bumps that the car runs over may alter the compass angle temporarily. By having the LCD refresh and since the compass is running in a while loop, this should be fixed within milliseconds.

Patents/Copyrights/Trademarks

No existing patent or copyrights or trademarks exist that are relevant to our project currently.

Program & Hardware Design

Software

The code was broken up into several portions. The software coding needed was used to extract the GPS coordinates (latitude, longitude), compass direction, and motor instructions. In addition to this, other portions of the code included displaying the current location and wanted destination on the LCD screen and also code to take the Raspberry Pi Board details of obstacle avoidances.
The purpose of the compass was to retrieve the angle in respect to north in order to determine the way the car was pointed and which way it should start to move in order to achieve its desired location. We went through a series of case statements to be switched around depending on the instruction the compass is sending. By hardwiring the compass to determine the direction of specific ports (i.e. CLK is an input), we had to send a series of commands so that the MEGA1284 would know whether or not the data was valid. Following the data sheet, we set up different statements that would send a COMPASS_RESET command, COMPASS_START_M command, and COMPASS_READ_M command. The compass requires an input of 30 bits with the first 4 bits being command and the second 4 bits being a response to check the status and the last 22 being the x and y values to be used to find the angle. The last 22 bits with the first 11 being x and the last 11 being y were then used to find the angle with arctan. Modifications were made to the angle to make it read 0 degrees north, 90 degrees when facing east, 180 degrees facing south, and 270 degrees facing west. By combining this with the LCD, our results are then posted to the LCD to see where the angle is and is consistently updated.
In order to obtain a current location, a GPS receiver was used. However, the GPS receiver retained its details in NMEA format. Therefore a NMEA parser was needed to only extract the needed details such as latitude and longitude for the purpose of this project. This parser was borrowed from Chris Anderson and Jordi Munoz with the information found here.
 
For more detail: The Self-Driving Toy Car using ATmega1284 microcontroller


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top