Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   CIM driving 2x faster than others (http://www.chiefdelphi.com/forums/showthread.php?t=91656)

tomy 12-02-2011 18:34

CIM driving 2x faster than others
 
We just tested driving our bot for the first time since we switched to the new black jaguars. the problem is that one of the cims is driving twice the speed of the other three. we checked all the pwms and made sure that the power was hooked up right. Any Ideas?

demosthenes2k8 12-02-2011 18:55

Re: CIM driving 2x faster than others
 
Without seeing any code, may I suggest putting the "bad" CIM onto a jaguar that you know works, and put a "good" one on the jaguar that you think may be faulty? That will tell you if it's the CIM or the Jaguar.

If it's the jaguar, the next step is to use BDC-Comm to set voltage to two different jaguars, the good and the bad, to the same voltage, then use its output to see whether the speed is the same (roughly). If they're not, it's probably the jaguar itself. If it is, it's probably something in the code and you should check your logic carefully.

Chris is me 12-02-2011 19:09

Re: CIM driving 2x faster than others
 
Make sure the problem isn't mechanical. Try spinning the gearboxes by hand (backdrive them) and see if the slow one is much harder to spin than the others.

tomy 12-02-2011 19:15

Re: CIM driving 2x faster than others
 
here is our code is there anything wrong there?

Code:

#include "WPILib.h"
#include "Vision/AxisCameraParams.h"
#include "math.h"
#include "CustomMath/CustomMath.h"
#include "C:/WindRiver/workspace/2011_IceRobotics/Xbox360/Xbox360.h"


class RobotDemo : public SimpleRobot
{
        RobotDrive myRobot; // robot drive system
        //Joystick leftstick; // left joystick
        //Joystick rightstick; // right joystick
        Joystick armstick;
        HSLImage image; // camera
        DigitalInput *left;                        // digital inputs for line tracking sensors
        DigitalInput *middle;
        DigitalInput *right;
        Victor vicShoulder;
        Victor vicElbow;
        Victor vicWrist;
        Victor vicClaw;
        Xbox360 xbox;
        DigitalInput *sfsensor; //front sensor
        DigitalInput *sbsensor; //back sensor
        DigitalInput *efsensor; //front sensor
        DigitalInput *ebsensor; //back sensor
        DigitalInput *wfsensor; //front sensor
        DigitalInput *wbsensor; //back sensor
        Gyro gyro;
        //ADXL345_I2C acc;
        //Encoder En;

       
public:
        RobotDemo(void):
                myRobot(1, 2, 3, 4),        // these must be initialized in the same order
                //leftstick(1),                // as they are declared above.
                //rightstick(2),            // as they are declared above.
                armstick(3),
                vicShoulder(6),
                vicElbow(7),
                vicWrist(8),
                vicClaw(9),
                xbox(1),
                gyro(1,1)
               
                //acc(1),
                //En()
        {
                myRobot.SetExpiration(0.1);
                left = new DigitalInput(2);
                middle = new DigitalInput(1);
                right = new DigitalInput(3);
                sfsensor = new DigitalInput(6,1);
                sbsensor = new DigitalInput(6,2);
                efsensor = new DigitalInput(6,3);
                ebsensor = new DigitalInput(6,4);
                wfsensor = new DigitalInput(6,5);
                wbsensor = new DigitalInput(6,5);       
       
        }

       
        void Autonomous(void)
        {
                myRobot.SetSafetyEnabled(false);
               
                //gyro.Reset();
                //gyro.GetAngle();                        // current heading (0 = target)
                AxisCamera &robocam = AxisCamera::GetInstance();
                robocam.WriteResolution((AxisCamera::Resolution_t)3);
                robocam.WriteBrightness(0);
                while(IsAutonomous()){
               
                // read digital inputs       
                unsigned short leftValue = left->Get() ? 4 : 0;        // read the line tracking sensors
                unsigned short middleValue = middle->Get() ? 2 : 0;
                unsigned short rightValue = right->Get() ? 1 : 0;
               
               
                //begin Line tracking
                switch(leftValue + middleValue + rightValue){
                        //void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
                        case(0x0): // normal operation
                        case(0x5):
                        case(0x7):{
                                //This and 0x0, 0x5, are all the messages recieved if there is no line found
                               
                                break;
                        }
                        case(0x1):        // straif right
                        case(0x3):{
                                //0x1, and 0x3 for when the robot sees the line to the right
                               
                                //Checks to see what the middle value is, and runs until the middle sensor returns true or sees the line
                                while (middleValue != true){
                                        myRobot.ArcadeDrive(0.0, 0.50);
                                }
                                break;
                        }
                        case(0x2):{
                                //This is the case for the middle
                               
                                while (middleValue == true){
                                        myRobot.ArcadeDrive(0.5, 0.0);
                                }
                                break;
                        }
                        case(0x4): // straif left
                        case(0x6):{
                                //This case statment if for when it sees the line on the left sensor
                                while (middleValue != true){
                                        myRobot.ArcadeDrive(0.0, -0.5);
                                }
                                break;
                        }
                        default:{
                                break;
                        }
                }
               
                if (leftValue + middleValue + rightValue == 0x0 || 0x5 || 0x7){
                        //The line has ended and this code is for the arm
                       
                }
                }
                Wait(3.0);
        }

       
        void OperatorControl(void)
        {
                myRobot.SetSafetyEnabled(true);
                AxisCamera &robocam = AxisCamera::GetInstance();
                robocam.WriteResolution((AxisCamera::Resolution_t)3);
                robocam.WriteBrightness(0);
                gyro.Reset();
                Wait(3.0);
               
                while (IsOperatorControl())
                {
                // read digital inputs       
                unsigned short leftValue = left->Get() ? 4 : 0;        // read the line tracking sensors
                unsigned short middleValue = middle->Get() ? 2 : 0;
                unsigned short rightValue = right->Get() ? 1 : 0;
               
                //Look for line sensor inputs only when selected
                if (xbox.GetRightBumper()){
                        switch(leftValue + middleValue + rightValue){
                        case(0x0): // normal operation
                        case(0x5):
                        case(0x7):{
                                        //printf("no line found \n");
                                        //void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
                                        if (!xbox.GetLeftBumper()){
                                                myRobot.MecanumDrive_Cartesian(-xbox.GetRightX(), -xbox.GetLeftX(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
                                        }
                                        else{
                                                myRobot.MecanumDrive_Cartesian(-xbox.GetLeftX(), -xbox.GetRightX(), -xbox.GetLeftY(), 0);//Mecanumdrive at half speed
                                        }
                                        break;
                                        }
                        case(0x1):        // straif right
                        case(0x3):{
                                        // printf("right leftstickX = %f, abs = %i\n",leftstick.GetX(), abs((int)leftstick.GetX()));
                                        float leftvalue = (fabs(xbox.GetLeftX())/-2);
                                        //printf("right leftstickX = %f\n", leftvalue);
                                        myRobot.MecanumDrive_Cartesian(leftvalue, 0, -xbox.GetLeftY(), 0);
                                        break;
                                        }
                        case(0x2):{ // keep going
                                        //printf("middle \n");
                                        myRobot.MecanumDrive_Cartesian(0, 0, -xbox.GetLeftY(), 0);
                                        break;
                                        }
                        case(0x4): // straif left
                        case(0x6):{
                                        //printf("left \n");
                                        float rightvalue = (fabs(xbox.GetLeftX())/2);
                                        //printf("left leftstickX = %f\n", rightvalue);
                                        myRobot.MecanumDrive_Cartesian(rightvalue, 0, -xbox.GetLeftY(), 0);
                                        //myRobot.MecanumDrive_Cartesian(-leftstick.GetX(), -rightstick.GetX(), -leftstick.GetY(), 0);
                                        break;
                                        }
                        default:
                                        break;
                        }
                }
       
                //void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
                        if (!xbox.GetLeftBumper()){
                                myRobot.MecanumDrive_Cartesian(xbox.GetLeftX(), xbox.GetRightX(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
                        }
                        //                                                                                                                                        forward/back
                        else{
                                myRobot.MecanumDrive_Cartesian(xbox.GetLeftX()/2, xbox.GetRightY()/2, xbox.GetLeftY()/2, 0);//Mecanumdrive at half speed
                       
                }
                //Arm Code
                                //sf=shoulder front sensor
                                //sb=shoulder front sensor
                                //ef=shoulder front sensor
                                //eb=shoulder front sensor
                                //wf=shoulder front sensor
                                //wb=shoulder front sensor
                               
                                //Shoulder Control
                                if(((!sfsensor->Get())||(armstick.GetY()<0)) || ((!sbsensor->Get())||(armstick.GetY()>0))) vicShoulder.Set(armstick.GetY()/2); //Shoulder Motor               
                               
                                //Elbow Control
                                if(armstick.GetRawButton(2)){                                                               
                                        if((!efsensor->Get() && !ebsensor->Get())||                                //Not either sensor
                                                        ((efsensor->Get() && (armstick.GetY()<0))||                //on front sensor moveback only
                                                        ((ebsensor->Get() && (armstick.GetY()>0)))))        //on back sensor
                                                                vicElbow.Set(armstick.GetY()/2);
                                        }
                                //Wrist Control
                                if(armstick.GetRawButton(3)){                                                               
                                        if((!wfsensor->Get() && !wbsensor->Get())||                                //Not either sensor
                                                        ((wfsensor->Get() && (armstick.GetY()<0))||                //on front sensor moveback only
                                                        ((wbsensor->Get() && (armstick.GetY()>0)))))        //on back sensor
                                                                vicWrist.Set(armstick.GetY()/2);
                                        }
                                //Claw Control
                                if(armstick.GetTrigger()){
                                        vicClaw.Set(armstick.GetY()/2);
                                }
                                printf("gyro = %f\n", gyro.GetAngle());
                                Wait(0.005);// wait for a motor update time
                }
               
        }

};

START_ROBOT_CLASS(RobotDemo);


tomy 12-02-2011 22:01

Re: CIM driving 2x faster than others
 
anyone?????

jwakeman 12-02-2011 22:13

Re: CIM driving 2x faster than others
 
Quick glance this looks suspect. For full speed you have '-' in front of xbox.GetLeftY(). And it is positive in the half-speed version.

Code:

                if (!xbox.GetLeftBumper()){
                                myRobot.MecanumDrive_Cartesian(xbox.GetLeftX(), xbox.GetRightX(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
                        }
                        //                                                                                                                                        forward/back
                        else{
                                myRobot.MecanumDrive_Cartesian(xbox.GetLeftX()/2, xbox.GetRightY()/2, xbox.GetLeftY()/2, 0);//Mecanumdrive at half speed


tomy 12-02-2011 22:16

Re: CIM driving 2x faster than others
 
the "-" just makes it so it dose not drive backwards and i do not think that would affect the speed of one single jaguar speed controller

theprgramerdude 12-02-2011 23:59

Re: CIM driving 2x faster than others
 
Did you forget your machine keys while installing one? That could easily cause an issue while driving.

tomy 13-02-2011 10:24

Re: CIM driving 2x faster than others
 
I'll check tommaorw


All times are GMT -5. The time now is 13:55.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi