NXT rebooting in middle of program.

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

NXT rebooting in middle of program.

Postby Gof » Fri Aug 24, 2007 3:51 pm

Hi,

I just got to play with this LeJOS and its great!

I love java, and being able to combine it with my NXT is so cool.

But i have a problem, i have been trying to implement a SegWay model, much as NXTWay and some of the other examples, but my program seems to randomly reboot the nxt while running.

Code: Select all
import lejos.nxt.*;

public class JSegway {

    private int value, delta, old, center, offset;
    private LightSensor light;

    public JSegway() {
        //Create light sensor attached to port S3
        light = new LightSensor(SensorPort.S3, true);

        value = 0;
        old = 0;
        delta = 0;

        //Wait 0.5 sec then read off center position
        try {
            Thread.sleep(500);
            center = light.readNormalizedValue();
            LCD.clear();
            LCD.drawInt(center,0,0);
            LCD.refresh();
            Thread.sleep(500);
        }
        catch(InterruptedException e) {
            System.exit(-1);
        }

        //Disable smooth acceleration on the motors
        Motor.A.smoothAcceleration(false);
        Motor.C.smoothAcceleration(false);
        Motor.A.regulateSpeed(false);
        Motor.C.regulateSpeed(false);
    }

    public void loop() throws InterruptedException {
        while(!Button.ENTER.isPressed()) {
            value = light.readNormalizedValue();

            delta = old-value;

            offset = center - value;

            int speed = Math.abs(offset) * 10;

            if(speed > 100) {
                speed = 100;
            }
            if(speed < 0) {
                speed = 0;
            }

            if( offset < 0 ) {
                Motor.A.setPower(speed);
                Motor.C.setPower(speed);
                Motor.A.backward();
                Motor.C.backward();
            }
            else if( offset > 0 ) {
                Motor.A.setPower(speed);
                Motor.C.setPower(speed);
                Motor.A.forward();
                Motor.C.forward();
            }
            else {
                Motor.A.flt();
                Motor.C.flt();
            }

            old = value;

            Thread.sleep(5);
        }

        System.exit(0);
    }

    public static void main(String args[]) throws InterruptedException {
        new JSegway().loop();
    }
}


I know this probabely is a very bad attempt at a segway program, but i cant really tune it until i can actually make the thing run all the time instead of rebooting.

Btw, the main lejos menu seems to indicate that my nxt has between 6.8-7.2v while this is going on. (The batteries were new 30min ago)

Any ideas / help would be greatly appriciated.

/Gof
Gof
New User
 
Posts: 6
Joined: Fri Aug 24, 2007 3:43 pm

Postby bbagnall » Sun Aug 26, 2007 5:39 pm

6.8 means your batteries are dead. That's why it is rebooting. Likely only one of your 6 batteries is the cause. Use a battery tester to find the culprit (it will stick out like a sore thumb).
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm


Return to NXJ Software

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest

more stuff