View Single Post
  #6   Spotlight this post!  
Unread 12-02-2010, 21:58
simpsonboy77 simpsonboy77 is offline
Registered User
AKA: Garrett Dicken
FRC #0041 (RoboWarriors)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: New Jersey
Posts: 88
simpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond repute
Re: CAN Position control code?

Ok, here is my best shot at answering this. We literally got it working about 4 hours ago, and even then it would stop working randomly (no change of code in between). Your mileage may vary.

We attached a 100k potentiometer (we had no 10k's which the manual calls for) to the signal pin of the jaguar.

First add this to the switch statement in InitJaguar()

case kPosition:
sendMessage(LM_API_POS_EN | m_deviceNumber,NULL,0);
break;


This sets the jaguar into position mode. Again, not sure if this is right, I'm just going through everything I changed.
Initialize the CANJaguar object.

My line looks like Kicker = new CANJaguar(6,CANJaguar::kPosition); The 6 is the CAN ID.

Then I have in my teleop init portion the following. I put it there because it didn't seem to work while in disabled. I think its because you cannot send CAN frames because that could be used to make a motor move. And if you are disabled, this is against the rules .

Kicker->SetPositionReference(CANJaguar::kPosRef_Potentiom eter);
Kicker->ConfigPotentiometerTurns(1);
Kicker->ConfigNeutralMode(CANJaguar::kNeutralMode_Brake );

Wait(.001);
Kicker->SetPID(300,.001,0);
Kicker->EnableControl();


Note mine are pointer references, so you might need to use the . operator instead. After some experimenting the first line must be first. Otherwise you get errors, but if you enable/disable the robot a few times it starts working.
My PID constants are not tuned, but it gets the motor moving at a reasonable rate. We are using a CIM with a 9:1 or a 12:1.

I put that wait(.001) in there because it seems that it fails less. I'm thinking maybe the bus needs some time to clear or something, I honestly have no idea.

Then in your teleop or autonomous use the Set method. Values are between 0 and 1 I think. I'm not sure if it includes -1 to 0. My guess is no because the Get returns a float between 0 and 1.


If you post questions I'll try my best to answer.

Once again, I just got this working so I may be wrong. I am just telling you most of my steps I took to get it working.
__________________
2017 Shenzhen, China Regional CSA
2013 - Present MAR Control System Adviser and FTAA
2009 - Present Programming an Electrical Mentor Team 41
2007 - 2008 Team 41 Lead Programmer, Electrical
2005 - 2008 Team 41 Member
2008 NYC Regional Winner

Last edited by simpsonboy77 : 12-02-2010 at 22:01.
Reply With Quote