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

Hovering motors
http://robotc.net/forums/viewtopic.php?f=11&t=7343
Page 1 of 1

Author:  Vex team 6581s [ Thu Nov 21, 2013 6:28 pm ]
Post subject:  Hovering motors

We currently have an arm controlled by two motors (motorA and motorB). Both motors are controlled by channel 3 on the joy stick. This works flawlessly. However, we wish to take it to the next step and keep the arm at it's current position when we stop pushing up or down on the joystick. Currently we have not been able to figure out an answer to our problem. We would be grateful for any help you can provide.

Current code:
Code:
while (true) {
    motor[motorA] = vexRT[Ch3]/2;
    motor[motorB] = vexRT[Ch3]/2;
}


~6581s

Author:  Ernest3.14 [ Thu Nov 21, 2013 10:36 pm ]
Post subject:  Re: Hovering motors

Do you have encoders connected to the motors? If you don't, you'll need those. You can write a simple PID loop to make the motors attempt to maintain a (n encoder) position.

Author:  Vex team 6581s [ Thu Nov 21, 2013 10:49 pm ]
Post subject:  Re: Hovering motors

Yes we do. Would it work if when the joystick was released it reset the sensor so that the position was 0 and have a loop that makes adjustments based on that?

Author:  Vex team 6581s [ Fri Nov 22, 2013 9:36 am ]
Post subject:  Re: Hovering motors

Here is our current code. The logic is failing somewhere but I cannot seem to find it.

Code:
task armControl() {
   //Main task loop
   while (true) {
      //Make the arm go up
      while (vexRT[Btn6U] == 1 && vexRT[Btn6D] != 1) {
         motor[lifterA] = -127;
         motor[lifterB] = -127;
         SensorValue[dgtl11] = 0;
         if (vexRT[Btn6U] != 1 || vexRT[Btn6D] == 1) {
            motor[lifterA] = 0;
            motor[lifterB] = 0;
            SensorValue[dgtl11] = 0;
            break;
         }
      }
      //Make the arm go down
      while (vexRT[Btn6U] != 1 && vexRT[Btn6D] == 1) {
         SensorValue[dgtl11] = 0;
         motor[lifterA] = 127;
         motor[lifterB] = 127;
         SensorValue[dgtl11] = 0;
         if (vexRT[Btn6U] == 1 || vexRT[Btn6D] != 1) {
            motor[lifterA] = 0;
            motor[lifterB] = 0;
            SensorValue[dgtl11] = 0;
            break;
         }
      }
      //Hover
      while (vexRT[Btn6U] != 1 && vexRT[Btn6D] != 1) {
         while (SensorValue[dgtl11] > 0) {
            motor[lifterA] = -127;
            motor[lifterB] = -127;
            if (vexRT[Btn6U] == 1 || vexRT[Btn6D] == 1 || SensorValue[dgtl11] < 0) {
               motor[lifterA] = 0;
               motor[lifterB] = 0;
               break;
            }
         }
         //Hover
         while (SensorValue[dgtl11] < 0) {
            motor[lifterA] = 127;
            motor[lifterB] = 127;
            if (vexRT[Btn6U] == 1 || vexRT[Btn6D] == 1 || SensorValue[dgtl11] > 0) {
               motor[lifterA] = 0;
               motor[lifterB] = 0;
               break;
            }
         }
         if (vexRT[Btn6U] == 1 || vexRT[Btn6D] == 1) {
            break;
         }
      }
   }
}

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