Spring 2017 Velociraptor: Counting the Number of Dots Encountered
Authors
By: Oscar Ramirez (Mission, Systems, & Test)
-Body
Edited and Approved By: Jesus Enriquez (Project Manager)
-Introduction & Conclusion
Table of Contents
Introduction
One of the other challenges that we faced on top of choosing and configuring a color sensor was the challenge of interfacing the Arxterra app custom telemetry with the count dots command. This post covers the strategy and solution we came up with in order to solve this issue.
Requirement L2-1: The Velociraptor shall be able to count the number of dots it encounters in the Custom Maze using an SMD LED to indicate that it counted a dot
Requirement L2-2: The 3DoT shall send custom telemetry to the Arxterra Control Panel via Bluetooth
Detecting the Red Dots
After configuring our TCS34725 color sensor we needed to implement this into our main code and not just detect the red dots inside the maze, but also count them and find some sort of way to display them. Implementing the red dot detection into the main code was not an issue but displaying the number of counted dots proved to be more of a challenge. A seven-segment display would not be ideal since it would require numerous digital pins on our Arduino and we would also need two seven segment displays to count a practical amount of dots. A much simpler solution would be first counting the dots and display the counted dots by blinking an LED equal to the number of dots counted. For example if we were to collect 14 dots the LED would blink 14 times. To enable this dot count, I created a custom Boolean command that once switched to “ON” would blink the LED the same number of times that are equal to the total dots. Creating a counting dot subroutine and inserting this logic was simple. First I copied the dot counter into a dummy variable so that the value of the counter would remain unmodified. Taking this dummy variable that has the total number of dots that we want to count, I inserted it into a while loop that begins by decrementing it by one and then flashing the LED once. This process repeats until the value of the dummy variable is equal to zero and the LED has flashed the same number of times equal to the total dots counted.
Figure 1: Our custom command that toggles the current red dot count
CountDotsHandler:
void countDotsHandler (uint8_t cmd, uint8_t param[], uint8_t n)
{
d=c; // copying number of dots to dummy variable
if (d>0) // counting the number of dots by derementing d
{
while (d>0)
{
d=d-1; // subtracting each dot one by one and setting LED to HIGH for each dot
digitalWrite(8, HIGH);
delay(250); // 250ms delay between LED flashes
digitalWrite(8, LOW);
delay(250); // repeating loop until all our dots are counted
}
}
}
Conclusion
This test for us worked fairly well off the robot and the only challenging aspect of this that we came across was that we did not test the robot for a static walk performance in order to predict about how long we should allow the LED to stay on as it encounters each dot. For the future, the best recommendation is to focus on getting the robot to walk first and foremost.