Go To:
Home Page

Useful Information and Lessons Learned


On this page you will find a variety of useful information we learned throughout the semester as well as some lessons we learned from our mistakes. We hope you find this helpful.

Communication Diagram

RobotDiagram.jpg

Using a Voltage Regulator

Some things, like the Arduino Uno or a Servo, need exactly 5 volts input at all times.
If you have batteries, though, they may put out something different like 9V.
One solution is a voltage regulator:
It takes an input voltage greater than 5, and converts it down to 5V.

Use the regulator’s datasheet to see which pin is which
Here is a simple circuit using a voltage regulator to convert 9V down to 5V:


i surely hope you can't see this!?

What is a Power Rail? A Ground Rail?

Often, a lot of circuit components need to be connected to +5V or Ground.
As a result, it can simplify wiring to attach all of these wires to the horizontal rails which span the length of the breadboard.


i hope i get it!?

More information can be found here.

Go To:
Home Page

Tips on Coding

Do not proceed to debugging algorithm, until you know your line sensors and wall sensors are reliable. Depending on the way you implement what the robot does at each intersection, the robot might skip or ‘double read’ the intersection. Discrepancy between what the robot actually does and what algorithm supposes it does makes the debugging process extremely difficult.

Use Print Statement! We uploaded our final code with the print statements that we heavily relied on. The following code block shows a snippet of our print statement strategy.

// Search Loop
  if (!isRemote) {
    Serial.write("Exploring.......");
    Serial.write("Current Location: ");
    Serial.println(currentLocation);
    
    ... more logic
    
  // Backtrack Loop
  else {
    Serial.write("Backtracking.......");
    Serial.write("Current Location: ");
    Serial.println(currentLocation);

Variable type matters. It is best to choose the tightest variable in terms of memory. If the integer value does not have sign and does not need to go over 255, use uint8_t. But, this practice often led us to use uint8_t for temporary variable that stores the grid’s 16 bits value.

Be sure to agree on the concept of “Absolute direction” and “Relative direction.” Absolute direction means where the robot is currently facing in the frame of starting point on the bottom right corner where it faces north. Relative direction means which way the robot is turning (left, right, backward). These direction concepts should be synchronized not only inside the algorithm code itself, but also with the state machine, serial communication, and FPGA. Here’s an example of how to determine the relative direction when the robot is moving from grid (x,y) to (x+1,y).

void getDirection(uint8_t currentLoc, uint8_t nextLoc) {
  int numb= nextLoc - currentLoc; // Location = Linear grid #
  if (absoluteDir == EAST)  { // Currently facing East
      if (numb == 1) dir = NORTH;  // Moving to Absolute East -> go Straight
      else if (numb == -1) dir = SOUTH;  // Moving to Absolute West -> turn 180
      else if (numb == 4) dir = EAST;  // Moving to Absolute South -> turn Right
      else dir = WEST;  // Moving to Absolute North -> turn Left
  }