|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#6
|
|||
|
|||
|
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. Last edited by simpsonboy77 : 12-02-2010 at 22:01. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |