RCX 1.0 "crashes"

This is where you talk about the RCX hardware related topics such as the brick, sensors, LEGO pieces, etc

Moderator: roger

maccast
New User
Posts: 5
Joined: Fri Nov 11, 2011 11:49 pm

RCX 1.0 "crashes"

Postby maccast » Sun Nov 27, 2011 5:34 am

I have been working on a line following program for my RCX 1.0 using the light sensor. I have some working code, but I have hit a snag where the RCX will lock up after a certain point. I can't tell if it's after a certain amount of time or if it's after a certain amount of code is executed. Does anyone happen to know if there is like an execution time limit or function call limit on the RCX 1.0? For this interested here is the line following code I currently have:

Code: Select all

import josx.platform.rcx.*;
import josx.robotics.*;

//////////////////////////////////////
/**
* Line follower
*
* @author Adam Christianson
* @url   http://www.terraform.com
* @version 1.0
*/
public class LineFollow {       

    ////////////////////////////////////////////
    // public methods
    ////////////////////////////////////////////

    ////////////////////////////////////////////
    /**
     * main method
     * @throws InterruptedException
     */
    public static void main(String[] args)
        throws InterruptedException {
      Sensor.S2.setTypeAndMode (3, 0x80);
      Sensor.S2.activate();
      Sensor.S2.addSensorListener (new SensorListener() {
        public void stateChanged (Sensor src, int oldValue, int newValue) {
          // Will be called whenever sensor value changes
          // LCD.showNumber(newValue);
         TimingNavigator robot = new TimingNavigator(Motor.C, Motor.A, 1.6f, 0.54f);
         if (newValue > 35 ) {
            robot.travel(-15);
            pause(300);
            robot.rotate(-45);
            pause(300);
         } else {
            robot.forward();
         }
          try {
            Thread.sleep(100);
          } catch (InterruptedException e) {
            // ignore
          }
        }
      });      
      // just run until RUN button is pressed again
       Button.RUN.waitForPressAndRelease();
   } //main()
   
   public static void pause(int delay)
    {
      try { Thread.sleep(delay); }
      catch (InterruptedException ie) { }
    }
}

maccast
New User
Posts: 5
Joined: Fri Nov 11, 2011 11:49 pm

Re: RCX 1.0 "crashes"

Postby maccast » Sun Nov 27, 2011 5:39 am

I should also add that when the crash occurs the LCD displays a '62' with a carrot (^) above it in the center of the display (under the #2 sensor) and the number next to the little "run" character changes from a 0 to a 5. Not sure if there is any significance to that or not.

TechnoX
Novice
Posts: 52
Joined: Tue May 03, 2011 5:57 pm
Location: Sweden

Re: RCX 1.0 "crashes"

Postby TechnoX » Mon Nov 28, 2011 8:58 pm

My guess is a "Out of memory" exception ;)

Because every time the state of the light sensor is changing you create a new TimingNavigator. This take up some of the memory in the RCX.

It's more correct to create the TimingNavigator outside of the stateChanged-method, as a field :)
Then you can reuse the same object every time you need to move the robot! ;)


Good Luck!

peteraj
New User
Posts: 4
Joined: Sat May 18, 2013 3:14 pm

Re: RCX 1.0 "crashes"

Postby peteraj » Sat May 18, 2013 4:23 pm

Did youu try updating to the latest version when this happened? I do this when I have issues and it resolves bugs and stuff like this sometimes.
Peter


Return to “RCX Hardware”

Who is online

Users browsing this forum: No registered users and 1 guest