NXTMMX Daisy Chaining

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

Moderators: 99jonathan, roger, imaqine

Postby icemadsen » Fri Mar 04, 2011 9:34 am

gloomyandy wrote:Hi,
Can you explain why you need both setPower and setSpeed for the same motor? How are you using them?


We are using the setPower method to calibrate some of our motors, without using an extra sensor. For example, we are running the motor with very low power, such that it stops when there is too much resistance and at the same time we monitor the motors tachocount to see if it has moved. If the tachocount has not changed for X consecutive readings, we conclude that the motor is at a specific position and then resets the tachocount to have the same starting position for each run. We are using setSpeed when operating the motor, to operate it at different speeds dependent on how accurate we need the movement to be.

gloomyandy wrote:At a push you could probably re-create the old motor class by sub-classing NXTRegultedMotor and adding a setPower method that first disables the regulator and then sets the power on the port...


I will try that today, to see if that is possible to use. I tested the NXTMotor class yesterday as well, but I could not get the motor to move at all. My code was basically instantiating the NXTMotor, setting the power and calling the forward method, which should be the simplest way of getting a motor to run. However, it did nothing at all. :-(

gloomyandy wrote:There is no way to move the i2c code back to 0.8.5 without a lot of work, so I don't think that is going to happen, sorry...

Andy


That is understandable - thank you for considering how much effort it would require! We will try to rewrite our code to see if it can work on the snapshot version.

By the way, I simply love the new menu system with all the fancy graphics - it feels so much more intuitive and complete! Good job! :-)
User avatar
icemadsen
Novice
 
Posts: 31
Joined: Tue Dec 08, 2009 11:41 am

Postby gloomyandy » Fri Mar 04, 2011 10:29 am

Hi,
Ah yes I understand how that would work... A couple of things you can try...
1. If you have used any of the methods from NXTRegulatedMotor before you use the calls in NXTMotor you may have to call suspendRegulation, otherwise you may be fighting against the regulation code.
2. You may want to set the operating mode of the motor to brake mode with...
port.setPWMMode(TachoMotorPort.PWM_BRAKE);
before you try to set the power levels (i will probably make this default when I get chance as it brings the two motor classes into line)...

If you are still having problems and can put together a small test program I'll try and work out what is going on...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4174
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby tatranky » Fri Mar 04, 2011 1:20 pm

gloomyandy wrote:Hi,
Ah yes I understand how that would work... A couple of things you can try...
1. If you have used any of the methods from NXTRegulatedMotor before you use the calls in NXTMotor you may have to call suspendRegulation, otherwise you may be fighting against the regulation code.
2. You may want to set the operating mode of the motor to brake mode with...
port.setPWMMode(TachoMotorPort.PWM_BRAKE);
before you try to set the power levels (i will probably make this default when I get chance as it brings the two motor classes into line)...

If you are still having problems and can put together a small test program I'll try and work out what is going on...

Andy


Hi Andy,

I'm working with Kenneth (icemadsen) on this project. And first off, i wanna thank all of you for your support. I've been trying to implement a setPower funktion method for calibrating the tacho by stalling the motor.
Here is the testprogram:

Code: Select all
public class BrickItMotor extends NXTRegulatedMotor{

   public BrickItMotor(TachoMotorPort port) {
      super(port);
   }

   public void setPower(int power){
      this.suspendRegulation();
      try { this.cont.sleep(10); } catch (InterruptedException e){} //Doesn't work without this!
      this.tachoPort.setPWMMode(BasicMotorPort.STOP);
      if(power > 0){
         this.tachoPort.controlMotor(power, BasicMotorPort.FORWARD);
      } else if(power < 0){
         this.tachoPort.controlMotor(-power, BasicMotorPort.BACKWARD);
      } else {
         this.tachoPort.controlMotor(0, BasicMotorPort.STOP);
      }
   }
   
   public static void main(String[] args) throws InterruptedException {
      BrickItMotor A = new BrickItMotor(MotorPort.A);
      A.rotate(360);
      
      A.setPower(20);
      int tacho = 0;
      int lastTacho = -1;
      int cnt = 0;
      boolean calibrate = true;
      while(!Button.ESCAPE.isPressed()){
         if(calibrate){
            tacho = A.getTachoCount();
            if(tacho == lastTacho) cnt++;
            else {
               lastTacho = tacho;
               cnt = 0;
            }
            if(cnt > 20){
               A.stop();
               A.resetTachoCount();
               Sound.beep();
               calibrate = false;
               
            }
            Thread.sleep(10);
         }else{
            if(Button.RIGHT.isPressed()){
               A.setSpeed(200);
               A.forward();
            }
            if(Button.LEFT.isPressed()) A.stop();
         }
      }
   }
}


I had to make the motor controller thread sleep, or i wouldn't let me control the motor. But this is working... We also have problem determining if the motor is done with rotateTo(x,true), cause isMoving keeps returning true even if the Motor is in position (seems like it switches between true and false wherry fast... What is the best way to indicate this?

/Lasse
User avatar
tatranky
New User
 
Posts: 6
Joined: Mon Aug 17, 2009 6:56 pm
Location: DK - Aalborg

Postby gloomyandy » Fri Mar 04, 2011 3:08 pm

Hi,
Your call to setPWMMode should probably be...
this.tachoPort.setPWMMode(TachoMotorPort.PWM_BRAKE);

But I'm not sure this would have caused any problems. I think I understand why you have to call sllep (I will fix that when I get chance). But I'm not sure why you are having problems with isMoving, do you have a test case for this?

Thanks

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4174
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby tatranky » Fri Mar 04, 2011 4:17 pm

I haven't had the time to study the new NXTRegulatedMotor enough yet, but i think the problem is is that the regulator doesn't become stable... so it keeps trying to reach the exact position, bu overshoots... cause we can hear the motor humming when its holding position (unstable regulator). I'm not that good with regulators yet, so correct me if I'm wrong. Also, I like that you've made the regulator hold the position, but it would be nice to have a function where it just goes into PWM_BRAKE mode instead...

I don't have a case at this point, but i will try to make you one...
User avatar
tatranky
New User
 
Posts: 6
Joined: Mon Aug 17, 2009 6:56 pm
Location: DK - Aalborg

Postby gloomyandy » Fri Mar 04, 2011 4:30 pm

Once the regulator reaches the hold point it should no longer be returning true to isMoving, so even though it is working isMoving should return false. It will only return false when the end point is reached, so given that you see false returned at some point then I think it must have got to the end point... Of course if you are trying to check for movement by looking at the tacho counts then that is a different matter. I've not seen any problem with this so if you have a test case that would be good...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4174
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: NXTMMX Daisy Chaining

Postby ebony56 » Thu Oct 13, 2011 8:55 am

Interesting. So if I understand correctly, each NXT motor port could control Bestbuy Mousepads 3 motors, for a total of 9, without daisy chaining? I wonder how much latency these MUXs are introducing?
Last edited by ebony56 on Thu Jul 04, 2013 12:10 pm, edited 2 times in total.
ebony56
New User
 
Posts: 1
Joined: Thu Oct 13, 2011 8:52 am

Re: NXTMMX Daisy Chaining

Postby kirkpthompson » Thu Oct 13, 2011 12:39 pm

Actually, you would have 12 because the NXTMMX uses sensor ports, not motor ports. And, this is 3 NXTMMXs daisy-chained per port.

Re: latency
What do you mean?

Best,
-K
Leg Godt!
User avatar
kirkpthompson
leJOS Team Member
 
Posts: 304
Joined: Wed Dec 05, 2007 1:27 am
Location: New Mexico, USA

Previous

Return to NXJ Software

Who is online

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

more stuff