ROBOTC.net forums
http://robotc.net/forums/

Lock NXT Motor in place
http://robotc.net/forums/viewtopic.php?f=1&t=5327
Page 1 of 1

Author:  ninjaphoenix [ Sat Jan 05, 2013 12:49 pm ]
Post subject:  Lock NXT Motor in place

I am looking for a way to keep my robot's motor locked at a certain position. Right now what happens is the motor is stopped, and it falls back down to the lowest position. Is there any way I can keep this from happening? Thank you!
Arm Code Chunk:
//ROBOT ARM GRAB CODE
int buttonValues = joystick.joy1_Buttons;
int grabUp = buttonValues & 16;
int grabDown = buttonValues & 64;
int closeGrabber = buttonValues & 32;
int openGrabber = buttonValues & 128;

if ((grabUp + grabDown + closeGrabber + openGrabber) == 0)
{
// No buttons pressed, stop motors.
motor[motorWrist] = 5;
motor[motorGrab] = 0;
return;
}

if (grabUp)
{
motor(motorWrist) = 50;
}

if (grabDown)
{
motor(motorWrist) = -50;
}

if (closeGrabber)
{
motor(motorGrab) = 25;
}

if (openGrabber)
{
motor(motorGrab) = -25;
}

Author:  amcerbu [ Sat Jan 05, 2013 1:27 pm ]
Post subject:  Re: Lock NXT Motor in place

I would suggest changing the gear ratio to increase the torque on the joint. Otherwise, I can't see anything wrong with your code. Although, why do you set the wrist motor to 5% power?

Also, it helps if you post code between [code] and [/code] tags; this will preserve indentation and use a fixed-width font.

Author:  NeXT-Generation [ Sat Jan 05, 2013 2:34 pm ]
Post subject:  Re: Lock NXT Motor in place

Is PID control on?

Author:  mightor [ Sun Jan 06, 2013 3:24 am ]
Post subject:  Re: Lock NXT Motor in place

The most efficient and effective way of locking an arm in place is by the use of a worm-wheel construction, where you have a worm-wheel drive a cog, which moves the arm. The arm cannot drive the worm-wheel in reverse because it is physically impossible. That way you spare your motor and batteries as well.
Attachment:
ww.JPG
ww.JPG [ 8.36 KiB | Viewed 9451 times ]


= Xander

Author:  LP123 [ Mon Jan 07, 2013 10:17 am ]
Post subject:  Re: Lock NXT Motor in place

Code:
motor[motorWrist] = 5;
motor[motorGrab] = 0;


you should set both motors to 0 so the nxt actually brakes them I think, and in the preferences under NXT, uncheck use Float / Coast (vs Brake) for inactive motor PWM if checked!

Author:  Coder A [ Sat Jan 12, 2013 10:17 pm ]
Post subject:  Re: Lock NXT Motor in place

First, set 'bfloatwhenmotorpwminactive' to false, and then set on motor PID speed control. PID keeps motor at same speed, so when the motor starts to move, it will not be moving at zero, right? So, the motor wil correct to its previous position.

I hope this helps!

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/