View unanswered posts | View active topics It is currently Tue Jul 29, 2014 12:37 am






Reply to topic  [ 5 posts ] 
Teleop Motors Shaking 
Author Message
Rookie

Joined: Thu Jan 19, 2012 9:37 pm
Posts: 2
Post Teleop Motors Shaking
We are having a problem with our code/tetrix motors. some of our motors become jittery when our teleop code is run.
We have run tests in autonomous mode to check if there was a problem with the motor controllers, however the test proved that
all the motor controllers are functioning properly because all the motors moved without this jitteriness. After triple and quadruple checking the code, testing with different wires, different NXTs, adjusting the wiring of the controllers and stripping the code down to the problem areas, this issue still persists. We have tried everything and have no idea how or what is causing this, or how to fix it. Any help would be appreciated.

**motorRightLift and motorRightLift are the problem areas**

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTMotor,  HTServo)
#pragma config(Sensor, S1,     ,                    sensorI2CMuxController)
#pragma config(Motor,  motorA,          ,              tmotorNormal, openLoop, encoder)
#pragma config(Motor,  motorB,          ,              tmotorNormal, openLoop, encoder)
#pragma config(Motor,  motorC,          ,              tmotorNormal, openLoop, encoder)
#pragma config(Motor,  mtr_S1_C1_1,     motorRightLift, tmotorNormal, PIDControl, reversed, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     motorLeftLift, tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C2_1,     motorLeftDrive, tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C2_2,     motorRightDrive, tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_1,     motorCentralLift, tmotorNormal, openLoop, reversed, encoder)
#pragma config(Motor,  mtr_S1_C3_2,     motorI,        tmotorNormal, openLoop, encoder)
#pragma config(Servo,  srvo_S1_C4_1,    servobb1,             tServoStandard)
#pragma config(Servo,  srvo_S1_C4_2,    servobb2,             tServoStandard)
#pragma config(Servo,  srvo_S1_C4_3,    servo3,               tServoStandard)
#pragma config(Servo,  srvo_S1_C4_4,    servo4,               tServoStandard)
#pragma config(Servo,  srvo_S1_C4_5,    servo5,               tServoStandard)
#pragma config(Servo,  srvo_S1_C4_6,    servo6,               tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^|
//                                                     |
//                 Teleop Code                         |
//    //             (C) 2011 Team: 3983                     |
//                                                     |
//^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^|

#include "JoystickDriver.c"

task main()
{

int elevator = 0;
int elevatorspeed = 50;
int servod = 100;
int servou = 255;
int eactive = 0;
int sactive = 0;
int qactive = 0;
int servoq = 225;
int servoqd = 130;
float dtx = 0;
int dtactive = 0;
float dtmin = 0.5;
float dtmax = 1;
int aactive = 0;
int as = 0;
int amax = 100;
int amin = 60;
int flips = 40;

waitForStart();

while (true)
  {
  getJoystickSettings(joystick);

//*********FINISHED*********--------Drive Train--------------------------------------------------------------------

    if(joystick.joy1_TopHat == 6)
    {
      if(dtactive == 0)
      {
        if(dtx == dtmin)
        {
          dtx = dtmax;
        }
        else
        {
          dtx = dtmin;
        }
        dtactive = 1;
      }
    }
    else
    {
      if(dtx == 0)
      {
        dtx = dtmin;
      }
      dtactive = 0;
    }

    float sleft = joystick.joy1_y2 * dtx;
    float sright = joystick.joy1_y1 * dtx;

    if (abs (joystick.joy1_y2) > 10)
    {
      motor[motorLeftDrive] = (sleft);
    }
    else
    {
      motor[motorLeftDrive]  = 0;
    }

    if (abs (joystick.joy1_y1) > 10)
    {
      motor[motorRightDrive] = (sright);
    }
    else
    {
      motor[motorRightDrive]  = 0;
    }
//  This controls the drivetrain. When the analog sticks are pushed forward or backwards, the robot will move forward or backwards.

//*********FINISHED*********--------Elevator-----button pressed sets direction, same button off, opposite switch
      if(joy1Btn(05) == 1 | joy1Btn(07) == 1)
      {
        if(eactive == 0)
        {
          if(joy1Btn(05) == 1)
          {
           if(elevator == elevatorspeed)
           {
             elevator = 0;
           }
           else
           {
            elevator = elevatorspeed;
           }
          }
          else
          {
           if(elevator == elevatorspeed * -1)
           {
             elevator = 0;
           }
           else
           {
            elevator = elevatorspeed * -1;
           }
          }
          eactive = 1;
        }
      }
      if(joy1Btn(05) == 0 & joy1Btn(07) == 0)
      {
        eactive = 0;
      }
      motor[motorCentralLift] = (elevator);

//  This sets the central lift on and off. It allows us to control the direction too.
//  By pressing the button once (Btn(05)), the motor will turn on. Pressing it a second time will turn the lift off.
//  The other button (Btn(07)) will flip the direction of the motor so that it will got backwards. Pressing that button again will turn it off.

//FINISHED--------Bowling Ball Catch------------------------------------------------------------------------

     if(joy1Btn(02) == 1)
     {
       if(sactive == 0)
       {
        if(ServoValue[servobb1] == servod)
        {
         servo[servobb1] = servou;
        }
        else
        {
         servo[servobb1] = servod;
        }
        sactive = 1;
       }
      }
      else
      {
        sactive = 0;
      }

//

// *********FINISHED*********--------Main Arm--------------------------------------------------------------------

    if(joystick.joy1_TopHat == 4)
    {
      if(aactive == 0)
      {
        if(as == amin)
        {
          as = amax;
        }
        else
        {
          as = amin;
        }
        aactive = 1;
      }
    }
    else
    {
      if(as == 0)
      {
        as = amin;
      }
      aactive = 0;
    }

    if(joy1Btn(04) == 1)
    {
      motor[motorRightLift] = as;
    }
    else
    {
      motor[motorRightLift] = 0;
    }
    if(joy1Btn(01) == 1)
    {
      motor[motorRightLift] = -as;
    }
    else
    {
      motor[motorRightLift] = 0;
    }

// *********FINISHED*********--------Flipper--------------------------------------------------------------------

    if(joy1Btn(06) == 1)
    {
      motor[motorLeftLift] = flips;
    }
    else
    {
      motor[motorLeftLift] = 0;
    }
    if(joy1Btn(08) == 1)
    {
      motor[motorLeftLift] = -flips;
    }
    else
    {
      motor[motorLeftLift] = 0;
    }

// *********FINISHED*********--------Servo Lock--------------------------------------------------------------------
    //  This raises and lowers the ball hopper. There are 2 modes so that it can be raised at different speeds.

     if(joy1Btn(03) == 1)
     {
       if(qactive == 0)
       {
        if(ServoValue[servobb2] == servoq)
        {
         servo[servobb2] = servoqd;
        }
        else
        {
         servo[servobb2] = servoq;
        }
        qactive = 1;
       }
      }
      else
      {
        qactive = 0;
      }
 }
}


Thu Jan 19, 2012 9:47 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: Teleop Motors Shaking
Now I didn't examine your code in full detail, but I did see some potential culprits like this:
Code:
if(joy1Btn(04) == 1)
    {
      motor[motorRightLift] = as;
    }
    else
    {
      motor[motorRightLift] = 0;
    }
    if(joy1Btn(01) == 1)
    {
      motor[motorRightLift] = -as;
    }
    else
    {
      motor[motorRightLift] = 0;
    }


If you are pressing joy1Btn(01), and not pressing Joy1Btn(04), the motor in question will oscillate between motor power 0 and motor power "-as". This may be the cause of the stuttering that you see.

_________________
sudo rm -rf /


Fri Jan 20, 2012 12:36 am
Profile
Rookie

Joined: Thu Dec 29, 2011 8:34 pm
Posts: 14
Post Re: Teleop Motors Shaking
Yes, we had jittery teleop behavior two nights ago, and it was because the motors were being set first to one speed then to zero. I think the three cases for your control need to be mutually exclusive:
Code:
    if ( joy1Btn(04) == 1 )
    {
      motor[motorRightLift] = as;
    }
    else if ( joy1Btn(01) == 1 )
    {
      motor[motorRightLift] = -as;
    }
    else  // only when *neither* button is pressed:
    {
      motor[motorRightLift] = 0;
    }


Fri Jan 20, 2012 7:10 am
Profile
Rookie

Joined: Thu Jan 19, 2012 9:37 pm
Posts: 2
Post Re: Teleop Motors Shaking
THANK YOU THANK YOU THANK YOU!!

We've been driving ourselves crazy over this for the past 2 days.
None of us noticed the conflicting if statement, so we just assumed it was something other than the code


Fri Jan 20, 2012 2:19 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3164
Location: Rotterdam, The Netherlands
Post Re: Teleop Motors Shaking
Quote:
None of us noticed the conflicting if statement, so we just assumed it was something other than the code

You'll make a great software engineer! They always blame the hardware. The reverse is true of hardware engineers, of course.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Jan 20, 2012 2:30 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.