Go to Post Mentors can never receive enough thanks from us students, who don't know even half of what they put into our teams. - Katie_UPS [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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: 90
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
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Position Control using potentiometer? biojae CAN 13 03-02-2010 20:12
More CAN control questions Geek 2.0 Electrical 0 12-01-2010 13:40
CAN control weirdness nathanww Electrical 4 04-01-2010 21:13
can we control the amount of air to control the speed of the cylinder? Team2339 Pneumatics 22 11-02-2009 15:33
Where can I find motor control in Camera.c? sjung9442 Programming 3 31-01-2006 15:49


All times are GMT -5. The time now is 14:01.

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