Saturday, March 9, 2013

Build Instructions for Drop7 Robot

Hardware

I tried out the Lego Digital Designer software to create some build instructions for the Drop7 robot. It was very easy to use and works really well.  If only the NXT-G software were as solid as the LDD software :)

Here is a zip file with the .lxf file that you view in Lego Digital Designer.  LDD wouldn't let me attach the gear racks and it wouldn't let me attach the sliding platform to the track.  Other than that the instructions should be accurate.



Software

Here is the BricxCC code that tells the robot which way to move and how long to pause after touching the iPad.

task main() {
   // This sequence will get you to the x29 chain at the end of Level 2.
   unsigned char column_drop[] = {1,3,3,2,3,5,5,6,3,7,6,5,4,2,3,1,7,4,1,6,5,2,7,1,2,3,2,3,2,4,6,6,3,2,4,3,1,4,3,7,4,5,5,6,6,3,1,5,2,3,2,7,2,7,5,3,7,5,6};
   unsigned int column_delay[] = {1600,1600,1600,0,0,1000,0,0,0,0,0,0,17600,0,0,0,0,0,0,0,3200,0,18500,4100,0,0,0,0,0,2500,1000,0,0,0,0,1600,1600,0,0,0,0,1000,1600,1000,0,1600,1600,0,0,0,1600,0,0,1600,0,0,0,1600};

   unsigned int i;
   unsigned char prev_column = 4;
   unsigned char curr_column = 0;
   unsigned int degrees = 0;

   for (int i = 0; i < ArrayLen(column_drop); i++) {
     curr_column = column_drop[i];
     degrees = 0;

     TextOut(0, LCD_LINE1, "DROP: ", true);
     NumOut(50, LCD_LINE1, curr_column);

     if (prev_column) {
        if (curr_column > prev_column) {
           degrees = (curr_column - prev_column) * 120;
           TextOut(0, LCD_LINE2, "RIGHT: ");
           NumOut(50, LCD_LINE2, curr_column - prev_column);
           TextOut(0, LCD_LINE3, "DELAY: ");
           NumOut(50, LCD_LINE3, column_delay[i]);
           RotateMotor(OUT_B, -50, degrees);

        } else if (curr_column < prev_column) {
           degrees = (prev_column - curr_column) * 120;
           TextOut(0, LCD_LINE2, "LEFT: ");
           NumOut(50, LCD_LINE2, prev_column - curr_column);
           TextOut(0, LCD_LINE3, "DELAY: ");
           NumOut(50, LCD_LINE3, column_delay[i]);
           RotateMotor(OUT_B, 50, degrees);
        } else {
           // Same column...do nothing
        }
      }

      // Touch the iPad, (motor, power, degrees)
      RotateMotorEx(OUT_C, 40, 25, 0, 0, 1);
      Wait(100);
      RotateMotorEx(OUT_C, 20, -25, 0, 0, 1);

      if (column_delay[i]) {
           Wait(column_delay[i]);
      }
      prev_column = curr_column;
   }
}

No comments:

Post a Comment