Problem with NQC program on mindstorms RIS 2.0

I've created a simple line following program for my mindstorms robot to execute. It will run for a minute or so then the entire unit will
go blank. In other words the LCD display blanks out yet the robot continues to perform the last action it was doing before. So if the robot was turning to the left it will just continue spinning left. At this point all buttons are unresponsive, so the only way to remedy the situation is to remove a battery, then place it back. This then forces me to download the firmware.
This is getting annoying. I have set the turn off time to be infinite. I've tried versions r1 and r3 of nqc 2.5, both yield the same results.
Has anybody seen anything like this before?? Any help would be greatly appreciated. Here's the code:
//----------------------------------------------------------------------- // LineFollower //----------------------------------------------------------------------- // This program will make the Lego Mindstorms robot follow a simple // line path. //-----------------------------------------------------------------------
//----------------------------------------------------------------------- // Set up some basic definitions //----------------------------------------------------------------------- #define LEFT_EYE        SENSOR_1 #define RIGHT_EYE        SENSOR_3 #define LEFT    OUT_A #define RIGHT    OUT_C
#define CUTOFF    48
#define NORMAL_SPEED 4 #define FAST_SPEED 6 #define SLOW_SPEED 1
//------------------------------------------------------------------------- // readSensors: // This function will read the values from the two light sensors // mounted on the front of the robot. The values are then compared to // a predefined threshold to determine if the sensor is currently in a // dark or light region. The results from the two sensors will be // combined into a single result as follows: // Eyes Indication // ---- ----------------------------------------- // 0 both eyes see darkness // 1 left eye is dark, right eye is light // 2 right eye is dark, left eye is light // 3 both eyes see light // //------------------------------------------------------------------------- void readSensors(int &Eyes) {     int lEye; // defines a place to store the left eye sensor reading     int rEye; // defines a place to store the right eye sensor reading
    lEye = LEFT_EYE; // read the left eye sensor     rEye = RIGHT_EYE; // read the right eye sensor
// Compare left eye sensor value to determine if it is seeing     // light or dark     if (lEye > CUTOFF) {         Eyes = 2;     } else {         Eyes = 0;     }
    // Compare right eye sensor value to determine if it is     // seeing light or dark. if (rEye > CUTOFF) {         Eyes += 1;     } }
//------------------------------------------------------------------------- // goLeft: // Commands the robot to turn left //------------------------------------------------------------------------- void goLeft() { SetPower(RIGHT, SLOW_SPEED);     SetPower(LEFT, SLOW_SPEED);     Fwd(RIGHT);     Rev(LEFT); }
//------------------------------------------------------------------------- // goRight: // Commands the robot to turn right //------------------------------------------------------------------------- void goRight() { SetPower(LEFT, SLOW_SPEED);     SetPower(RIGHT, SLOW_SPEED);     Fwd(LEFT);     Rev(RIGHT); }
//------------------------------------------------------------------------- // straight: // Commands the robot to travel straight //------------------------------------------------------------------------- void straight() { SetPower(RIGHT+LEFT, NORMAL_SPEED);     Fwd(RIGHT+LEFT); }
//------------------------------------------------------------------------- // main: // The main program //------------------------------------------------------------------------- task main() {
int eye;
    // Set up sensors for light detection     SetSensor(LEFT_EYE, SENSOR_LIGHT);     SetSensor(RIGHT_EYE, SENSOR_LIGHT);
    // Turn on motor outputs     SetOutput(RIGHT+LEFT, OUT_ON);
    // start the robot moving forward     straight();
    while(true)     {         readSensors(eye);
        switch (eye) {                   case 0:             // Both eyes see a dark line, just keep going straight          straight();          break;
         case 1:             // right eye sees light while the left eye sees a dark l          // line this means that the robot is on the right side          // of the line...let's turn towards the left             goLeft();          break;
         case 2:             // left eye sees light while the right eye sees the          // dark line this means the robot is on the left side             // of the line...let's turn towards the right             goRight();             break;
         case 3: // both eyes see light. We have lost the line. Just          // keep spinning left. We may get lucky and hit the // black line          goLeft();             break;
        } // end switch     } // end while } // end main
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file
Upload is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.