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

Issue with bumper to limit arm travel
http://www.robotc.net/forums/viewtopic.php?f=69&t=10487
Page 1 of 1

Author:  Josper [ Fri Feb 06, 2015 12:08 am ]
Post subject:  Issue with bumper to limit arm travel

I'm putting together a program to control the arm travel when using the RC and it's not working correctly. Two bumpers limit the upper travel of the shoulder motor. I am building the program piece by piece so not to créate other issues. When I press the L up button the robot doesn't respond right away I have to press the button two or three times to get the arm to move up. I can't figure out why, please help. Here's the code written by the graphical RobotC interface :-(


task main()
{
repeat (forever) {
armControl(ShoulderMotor, BtnLUp, BtnLDown, 75);
armControl(ElbowMotor, BtnRUp, BtnRDown, 75);
while (getJoystickValue(BtnLUp) == 1) {
if (getBumperValue(BumpShouldUp) == 1) {
stopMotor(ShoulderMotor);
}
if (getBumperValue(BumpElbowUp) == 1) {
stopMotor(ShoulderMotor);
}
}
}
}

Author:  Josper [ Mon Feb 09, 2015 1:33 am ]
Post subject:  Re: Issue with bumper to limit arm travel

:-) I found a solution so I decided to post it here for everyone's benefit. If there is a better solution out there I hope to see it posted too.

repeat (forever) {
armControl(ShoulderMotor, BtnLUp, BtnLDown, 50);
armControl(ElbowMotor, BtnRUp, BtnRDown, 50);
while (getJoystickValue(BtnLUp)== 1) {
setMotor(ShoulderMotor, 50); // need to set motor again so it works within this while loop
if (getBumperValue(BumpShouldUp) == 1 || getBumperValue (BumpElbowUp) == 1) { // two bumpers limit this motor
stopMotor(ShoulderMotor);
waitUntil (getJoystickValue(BtnLUp) == 0); // need to wait with motor stopped until user releases button up
}
}
}

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