View unanswered posts | View active topics It is currently Fri Apr 20, 2018 8:31 pm

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Hovering motors
Author Message
Rookie

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

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

Thu Nov 21, 2013 10:36 pm
Rookie

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

Joined: Thu Nov 21, 2013 6:21 pm
Posts: 3
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning