Design requirements: This lab assumes that the two motors are wired to output ports A and C. Further, each motor is attached to a means of locomotion (legs, treads, feet, etc.).
Next, take the gray serial cable and IR tower (from the lego kit) and attach them to serial port 1 of your computer (it's the left most connector as you face the computer's row of connectors). Set the robot so that it's IR port is facing the IR tower. Now, type:
nqc -firmware firm0309.lgoin the terminal window. If you were successful, the robot will make a series of beeps, and you will see in the terminal window:
Downloading firmware:................................................... ............................... Current Version: 00030001/00030009The robot must be turned on to download the firmware or programs.
nqc -d tankbot1.nqcin the terminal window. If you were successful, the robot will make a series of beeps and you will see in the terminal window:
Downloading Program:....complete Battery Level = 8.1 VThe battery level may differ, depending on how new the batteries are.
Take the robot out to the hallway, place it on the floor, and click on run. This simple program (loaded in Program 1) will go forward forever. After you make sure it works, stop the program and turn off the robot to conserve the batteries.
cp tankbot1.nqc circles.nqcUsing the vi editor, modify the program circles.nqc so that it will go in a large circle, instead of straight. Follow the directions above to download the program to the robot. Test the program to find out the diameter of the circle.
[See p 59 of Unofficial Guide for useful output commands for the robot.]
cp circles.nqc turnInPlace.nqcWrite a program that will turn the robot in place. Your robot should rotate a full 360 degrees before stopping. Note that the strength of the batteries and the floor surface will affect how long you need to wait before completing a full turn and turning off the engines.
Use a constant to store the amount of time needed for a complete turn (see p 67) since future programs will use this number a lot.