View unanswered posts | View active topics It is currently Wed Oct 22, 2014 7:54 pm






Reply to topic  [ 4 posts ] 
Hovering motors 
Author Message
Rookie

Joined: Thu Nov 21, 2013 6:21 pm
Posts: 3
Post 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


Thu Nov 21, 2013 6:28 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post 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.

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Thu Nov 21, 2013 10:36 pm
Profile
Rookie

Joined: Thu Nov 21, 2013 6:21 pm
Posts: 3
Post 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?


Thu Nov 21, 2013 10:49 pm
Profile
Rookie

Joined: Thu Nov 21, 2013 6:21 pm
Posts: 3
Post 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;
         }
      }
   }
}


Fri Nov 22, 2013 9:36 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.