Getting to know the Rover
Programming hardware can be very difficult because of real world inaccuracies. Varying power, processing speed, and slipping wheels, are just a few of the things that can make hardware’s behavior unpredictable. Often times limitations prevent the system from being further improved, requiring the software to compensate. While your Lego Rover has been designed to be easily controllable, this problem will introduce you to some of the limitations that are still present.
The code below has letters representing where new lines should be added for the various parts of this problem. Sometimes there are hints*.
with Lego;
use Lego;
procedure RoverDirection is
Left_Wheel : constant Output_Port := Output_A;
// A
// B
// B
// D
begin
// B – CONFIG SENSOR
// B – CONFIG SENSOR
// D – CONFIG SENSOR
Output_Power(Output => Left_Wheel,
Power => Power_High);
// A
// B – CLEAR SENSOR
// B – CLEAR SENSOR
Output_On_Forward(Left_Wheel); // A
& C– MODIFY
// A & C
Wait(1000); // C–
MODIFY
Output_Off(Left_Wheel);
// A
// D - DISPLAY LIGHT SENSOR VALUE ON LCD,
Hint: “Display_Sensor_1”
end RoverDirection;
* You might need to refer to “Ada_Mindstorms_2.0_Manual” and “NQC_Guide” to figure out some lines. If you used the windows installer, these are available at:
Start->Programs->Unified C&P.
Otherwise, please go to the Unified C&P Website.
Correct the code so that both wheels move and the rover moves forward. (The black face of the RCX points forward). There are many ways to change the direction of rotation of the motors and turn them on and off. Feel free to look in Lecture C4 and/or the Manual for other ways.
Use the View button to check the ending value of sensor port 1 and sensor port 3 once the rover is done moving forward for 1000 hundredths of a second. What values do they report when your rover moves forward? Did your rover move perfectly forward in a straight line? What could be done to correct this?
Rewrite the code above so your rover does a 90 degree point turn. What values do they report? Did your rover turn perfectly about its center? What could be done to correct this? Is using “Wait” really the best way to measure the turn, or is there a better way? Describe it.
Rewrite the code above so the light sensor is turned on and the value of the light sensor is displayed on the screen. You may comment out the lines that make the motors turn on. Hold the rover on top of something dark and then something light. What values does this sensor give for light colors? Dark colors? What is the range of values? Does the sensor value ever fluctuate?
Turn in: Each team member needs to turn in a hardcopy of the team’s code for Part D as a “Listing” and the short answers to each of the questions above.