Go to Post if we aren't here for some wisdom...what are we here for? - Molten [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 10-02-2013, 16:07
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
Re: Positional Motor Control using CANJaguar

*Bump*
__________________
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
  #3   Spotlight this post!  
Unread 10-02-2013, 16:20
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Positional Motor Control using CANJaguar

Quote:
Originally Posted by John_1102 View Post
*Bump*
Sorry John, usually I stay out of conversations that I don't have a reasonable answer to, and this is one of them.

The code looks good other than this typo[?] near the bottom:
TEST_Tistance = PIDTEST.getPosition();

But that should be caught at compile time.

The only suggestion I have is to print the exception in your catch blocks. You could be getting a CANTimeoutException when you start your move. Sometimes this resets the Jag, and would result in an incomplete move, and the inability to go back to position 0, since you would by default the Jag would reset into VBus mode.

The most common cause of a timeout when you start a big position move on the Jags is overdrawing current. I'd find that hard to believe with a cam setup though. Flipping the limit switch jumpers sideways to enable the ramping feature on the Jags is a quick and easy way to avoid over-drawing current in these kinds of applications.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...

Last edited by Mr. Lim : 10-02-2013 at 16:25.
Reply With Quote
  #4   Spotlight this post!  
Unread 10-02-2013, 16:51
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Positional Motor Control using CANJaguar

Does it work as expected in BDC-COMM?

Here's what we do:

Code:
                armMotor.changeControlMode(CANJaguar.ControlMode.kPosition);
                armMotor.setPositionReference(CANJaguar.PositionReference.kPotentiometer);
                armMotor.configPotentiometerTurns(10);
                armMotor.configNeutralMode(CANJaguar.NeutralMode.kBrake);
                armMotor.setPID(P, I, D);
                armMotor.setX(position);
                armMotor.enableControl();
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:51.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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