Can't detect stall with a piston connected to a motor

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

Moderators: imaqine, 99jonathan, roger

timread
New User
Posts: 14
Joined: Thu Dec 25, 2008 11:48 am
Location: London

Can't detect stall with a piston connected to a motor

Postby timread » Sun Oct 29, 2017 1:39 pm

Hi,
I am using leJOS NXJ 0.9.1 on a NXT brick. I have an arm consisting of 3 motors; one (RO) rotates the arm using a turntable and gears, the other two turn pistons as linear actuators (EL) for the elbow, and (SH) for the shoulder.

I am trying to get the shoulder motor to move its piston to its maximum extension, where it should stall, and then I can use that position to calibrate the piston movement.

But where the stall should occur the piston has a ratchet which comes into play allowing the motor to continue rotating. I adjusted the setStallThreshold to its minimum, but the stall still isn't detected.

Am I coding something wrong, or is it just not possible to detect the stall with a piston. If it's the latter, then is there another way to calibrate the piston movement?
Here's the relevant code:

Code: Select all

public Arm() { //Arm constructor
      setupMotors();
      resetMotors();
   }

   public void resetMotors() {
      shoulderPistonTo(SHOULDER_START_LENGTH);
      checkStalling();
      currentShoulderExtension = SHOULDER_START_LENGTH; //once stalled set current length to max length
   }

   public void setupMotors() {
      SH.setAcceleration(300);
      SH.setSpeed(600);
            
      SH.setStallThreshold(1,1);
   }

private void checkStalling() {
      while(RO.isMoving() || SH.isMoving() || EL.isMoving()) {
         Thread.yield(); // allows other threads to run if necessary
         RConsole.println("Stalling check...");
         if (RO.isStalled()) {
            RConsole.println("Rotation stall");
            RO.stop();
         }
         if (SH.isStalled()) {
            RConsole.println("Shoulder stall");
            SH.stop();
         }
         if (EL.isStalled()) {
            RConsole.println("Elbow stall");
            EL.stop();
         }
          try {
            Thread.sleep(1000); //pause thread for 1000 milliseconds, which throws an InterruptedException that we then need to catch
         } catch (InterruptedException e) {
            // TODO Auto-generated catch block.
            e.printStackTrace();
         }
      }


Any help would be appreciated.
Tim

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

Re: Can't detect stall with a piston connected to a motor

Postby gloomyandy » Sun Oct 29, 2017 6:10 pm

Not going to work with a regulated motor. Your best bet is probably to use an unregulated motor and a low power setting, but depending on how the piston is designed there may not be a power setting that is low enough for the motor to stall but high enough to have the piston move.


But do you really need to do this? I would have thought that the number of revs needed to move the piston from end to end is relatively fixed and you should be able to measure that by trial and error. Once you have that all you need to do is to drive the piston to one end by moving the motor by at least that amount and then you know you are at that position and can then perform any other move knowing your position.
leJOS news https://lejosnews.wordpress.com/

timread
New User
Posts: 14
Joined: Thu Dec 25, 2008 11:48 am
Location: London

Re: Can't detect stall with a piston connected to a motor

Postby timread » Mon Oct 30, 2017 10:12 pm

Thanks :D ... So it won't damage the piston to have it driven over its limit and the ratchet clicking away for a while?
Tim

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

Re: Can't detect stall with a piston connected to a motor

Postby gloomyandy » Mon Oct 30, 2017 10:49 pm

Can't be 100% sure but I suspect it was designed that way for a reason! But you might want to ask on a Lego forum or two, or do a little searching on the topic, I've never used those pistons myself.
leJOS news https://lejosnews.wordpress.com/

timread
New User
Posts: 14
Joined: Thu Dec 25, 2008 11:48 am
Location: London

Re: Can't detect stall with a piston connected to a motor

Postby timread » Mon Oct 30, 2017 11:06 pm

OK. Cool. Thanks for the help!


Return to “NXJ Software”

Who is online

Users browsing this forum: No registered users and 3 guests