View Single Post
  #1   Spotlight this post!  
Unread 07-02-2013, 13:19
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
FTC, I have returned.
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,564
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Positional Motor Control using CANJaguar

Hello all!

I've returned once again to the glorious lands of CD to get some help with a puzzling problem I'm having.
This year our shooter will be mounted on a pivot point and will be attached to a CAM...(http://en.wikipedia.org/wiki/Cam)
I need to be able to rotate this CAM a specific distance/#ofdegrees from a set base position. I will need to be able to push a button and have the CAM rotate to the desired position and stay there until the button is released. Once released I would like the CAM to return to the home position. Or position 0.
I would imagine this would be simple to do....but I have been having some issues with my test-bed not functioning as expected.

Whenever the button is pushed the motor does travel the short distance expected, but when the button is released the motor does not return to 0.
Also, my getDistance(); method is not returning the distance of 5. It returns a value of about 2.35 when the motor stops. I tried using some of the other encoderDrive, PIDexample programs that use connection to the Jaguar through PWM and had zero success getting them to work at all.

At this juncture....I'm stumped by such a simple problem.

Code:
    public void robotInit() {
        TEST_Speed = 0;
        try{
           PIDTEST = new CANJaguar(3);
           PIDTEST.changeControlMode(CANJaguar.ControlMode.kPosition);
           PIDTEST.setPositionReference(CANJaguar.PositionReference.kQuadEncoder);   
           PIDTEST.configMaxOutputVoltage(100);
           PIDTEST.configEncoderCodesPerRev(80);
           PIDTEST.setPID(2.0, 0.0, 0.0);           
           PIDTEST.enableControl();
        }
        catch (Exception e){}
               

    }


Public void CAM_Control(){

       if(joy1.getRawButton(7)){
       try {
             TEST_Distance = PIDTEST.getPosition();
             PIDTEST.setX(5);

            } catch(Exception e) {}
       }
       else{
          try {
               TEST_Tistance = PIDTEST.getPosition();
                PIDTEST.setX(0);
 
               } catch(Exception e) { }
       }


}
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote