Replacement Brick not working

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

Moderators: 99jonathan, roger, imaqine

Replacement Brick not working

Postby SeanH » Tue Nov 12, 2013 8:53 am

Hi

I have just purchased a replacement NXT brick and it won't work with my code (see below), I have deleted the nxj.cache file and nxjbrowse sees both devices and my program connects to the bricks, however when I run the code it will also run Motor A from the second NXT brick on the first brick and ignore the second brick. I am using 0.9.1.

nxtconnector.connectTo(nxtname1, address1, protocols);
nxtcommand = new NXTCommand(nxtconnector.getNXTComm());

nxtconnector2.connectTo(nxtname2, address2, protocols);
nxtcommand2 = new NXTCommand(nxtconnector2.getNXTComm());


NXTCommandConnector.setNXTCommand(new NXTCommand(nxtconnector.getNXTComm()));
Motor.B.rotate(-3200, true);
Motor.C.rotate(3200, true);

NXTCommandConnector.setNXTCommand(new NXTCommand(nxtconnector2.getNXTComm()));
Motor.B.rotateTo(7200, true);
Motor.A.rotateTo(-7400, true);
SeanH
New User
 
Posts: 11
Joined: Tue Nov 12, 2013 8:48 am

Re: Replacement Brick not working

Postby gloomyandy » Tue Nov 12, 2013 10:30 am

So has this code ever worked? Did it work before you replaced your NXT?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Replacement Brick not working

Postby SeanH » Tue Nov 12, 2013 10:41 am

yep worked fine with previous brick,
SeanH
New User
 
Posts: 11
Joined: Tue Nov 12, 2013 8:48 am

Re: Replacement Brick not working

Postby gloomyandy » Tue Nov 12, 2013 10:48 am

In which case (and you are 100% sure that nothing else has changed) you probably need to look in detail at the brick configuration. Have you changed the name of the new brick? Are you using the correct Bluetooth address for each brick. Have you tried deleting all of the host systems Bluetooth device references and repairing both bricks etc. Can't really see anything else to try.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Replacement Brick not working

Postby SeanH » Tue Nov 12, 2013 10:54 am

addresses and names are ok and deleted them from my computer and re-paired them, and re-flashed both, its most annoying!! The only thing is that both the original bricks were bought years ago so maybe something had changed although I can't imagine what!
SeanH
New User
 
Posts: 11
Joined: Tue Nov 12, 2013 8:48 am

Re: Replacement Brick not working

Postby gloomyandy » Tue Nov 12, 2013 11:22 am

I don't think anything has changed in the brick design over the years, so doubt if it is that. Are you sure the software has not been changed at all? What happens if you run your code with the second brick turned off?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Replacement Brick not working

Postby gloomyandy » Tue Nov 12, 2013 11:23 am

Oh and what happens if you reverse the order of operations (so talk to the second brick first)...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Replacement Brick not working

Postby SeanH » Tue Nov 12, 2013 11:31 am

well if you do this :-

then the first part works ok but it will now run motor C on the nxtconnector2 brick and ignores the nxtconnector brick!

NXTCommandConnector.setNXTCommand(new NXTCommand(nxtconnector2.getNXTComm()));
Motor.B.rotateTo(7200, true);
Motor.A.rotateTo(-7400, true);

NXTCommandConnector.setNXTCommand(new NXTCommand(nxtconnector.getNXTComm()));
Motor.B.rotate(-3200, true);
Motor.C.rotate(3200, true);
SeanH
New User
 
Posts: 11
Joined: Tue Nov 12, 2013 8:48 am

Re: Replacement Brick not working

Postby gloomyandy » Tue Nov 12, 2013 12:02 pm

What happens with the second command to Motor.B? Does the motor on the other brick move or do you end up moving the same motor twice?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Replacement Brick not working

Postby SeanH » Tue Nov 12, 2013 12:05 pm

moves the same motor twice
SeanH
New User
 
Posts: 11
Joined: Tue Nov 12, 2013 8:48 am

Re: Replacement Brick not working

Postby gloomyandy » Tue Nov 12, 2013 12:51 pm

So looks like the second call to setNXTCommand is not doing what you want it to do... All of this is Pc side Java code, so it should be pretty easy to debug and work out what is going on. You should just be able to step through the code. It seems strange that this should have happened if you haven't changed anything though. have you updated leJOS recently?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Replacement Brick not working

Postby SeanH » Tue Nov 12, 2013 12:54 pm

not since 0.9.1 but this code was working with this, and if I do print outs of the nxt getinfo after both of the command connector commands they show up correct.
SeanH
New User
 
Posts: 11
Joined: Tue Nov 12, 2013 8:48 am

Re: Replacement Brick not working

Postby gloomyandy » Tue Nov 12, 2013 1:22 pm

Sorry no idea but I would start by stepping through one of the motor commands that is not working and see what that is using in terms of the connector... You have everything set up so it shouldn't take too long to work out what is going on...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Replacement Brick not working

Postby SeanH » Fri Nov 15, 2013 3:20 pm

Ok I've tried my program on a clean machine that has never had the bricks associated with them and has never had lejos installed and it still doesn't work,
I debugged the program but the commandconnectors have the correct name and address in them its just ignoring it somehow!

I have even tried a different variation on the connection :-

nxtconn2 = new NXTConnector();
nxtconn2.connectTo("btspp://00:16:53:16:3d:02", NXTComm.LCP);
NXTCommandConnector.setNXTCommand(new NXTCommand(nxtconn2.getNXTComm()));

nxtconnector = new NXTConnector();
nxtconnector.connectTo("btspp://00:16:53:0c:d7:a6", NXTComm.LCP);

NXTCommandConnector.setNXTCommand(new NXTCommand(nxtconnector.getNXTComm()));
Motor.B.rotate(-3000, true);
Motor.C.rotate(3000, true);

Any ideas anyone?
SeanH
New User
 
Posts: 11
Joined: Tue Nov 12, 2013 8:48 am

Re: Replacement Brick not working

Postby skoehler » Fri Nov 15, 2013 3:43 pm

Using Motor.A an Motor.B in combination with setNXTCommand is definitely a bad idea (conceptionally).
Instead, create instances of the RemoteMotor class. You have to pass the nxtcommand and index of the motor to the constructor. Index 0 is motor port A.
skoehler
leJOS Team Member
 
Posts: 1418
Joined: Thu Oct 30, 2008 4:54 pm

Next

Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests

more stuff