Lab 3: System Integration and Radio Communication

Objective

-Integrate components in labs 1, 2 and milestones 1, 2
+Robot that can start on a 660Hz tone
+Navigate small test maze autonomously
-Work on radio component to communicate maze information between the robot and base station

Radio Communication

The first part of the lab was to use radio communication to send information from our robot Arduino to our Base Station Arduino. Once we got the GUI and sample radio code downloaded, we were able to get the example code working.

We were able to decide on an encoding for maze information and also decode those messages. We use 16 bits, the least four significant bits encode the color and shape of any treasure that is present. The next four bits each represent a wall in one of the four cardinal directions. The next seven bits encode the coordinates. To encode the coordinates, we use a single number. When that number is divided by n in (we assume the maze is size n-by-n), the remainder is the x-coordinate and the quotient is the y-coordinate. The final bit indicates whether or not another robot is detected.

We created byte encodings of a maze in an array and loop through it to simulate traversing it using right hand wall following. We use bit masks and switch statements to decode each message, and then write the corresponding message to the GUI. While testing, we actually encountered a few problems with the GUI. First was that there were no sprites for treasures, so any cells that was supposed to have a treasure did not load. The second was that the last entry of the message sent to the GUI was parsed with a “\r\n” at the end of the parameter. This caused the parameter to be read as True, even if it was intended to be False. The meant that after we removed treasures from our maze, the last parameter was the west wall. Each cell in the GUI was drawn with a west wall even when we wrote false. To work around this, we added “robot=false” to the end of each message. If this bug is not fixed by the course staff, we will go into to Python code and correct the parsing. There was also an issue where the display would break and we would have to refresh the web browser. We were not able to identify the cause of this bug. The video below shows the traversal of our fake maze.

Once we got two radios again, we separated out our code to have one transmitter (the robot) and one receiver (the base-station). Again we had the transmitter loop through an array of integers, and each time we attempt to send the message. Because we want to receive each message exactly once, if there is no response from the base-station we keep trying to send it until the response is received. The video below shows one Arduino transmitting the messages and the other receiving and writing to the GUI.

Since our group has 2 fake Arduinos, we are unable to demonstrate the radios working with the robot traversing through the maze.

Robot Integration

For this part of the lab, the main task was to combine what we had working in milestone 2 with starting at a 660 Hz tone. We also had to add a left wall sensor to our robot as we did not have time to include one for milestone 2.

With this new sensor attached, we adjusted our right wall following logic to check for left walls if there is a wall and front and to the right. If there is no left wall we turn left, otherwise (meaning there are walls on all three sides), we make a 180 degree turn.

To add be able to detect the 660Hz tone, we added the circuitry from lab 2 to our robot. Because all of the analog input pins on the Arduino were occupied (2 line sensors, IR sensor, 3 wall sensors), we added a mux to increase the number of analog inputs we can have. By feeding the output of the microphone circuit and the IR to an 8 to 1 mux and using 3 digital output pins to select which mux input to use, we were able to integrate everything. We then only enter the loop() function if the microphone circuit is able to detect above a threshold in bin 5 of the fft of the microphone output. After the initial start sequence, the mux select is set to 1 so that the IR sensor reading is the input the Arduino. In this way, all aspects of the robot are able to work as intended.

Begins at the start tone and updates the GUI.