Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   CAN Talon PID (http://www.chiefdelphi.com/forums/showthread.php?t=153961)

CurlyFries 20-01-2017 10:42

CAN Talon PID
 
1 Attachment(s)
I'm getting some weird results from my testing of the CAN Talon SRX built-in pid loop. Our setup has a ctre magnetic encoder plugged directly into the CAN Talon. I couldn't find a whole lot of documentation, but I did find some java examples using the links at the ctre website. We are using c++, so I did my best to "translate" some of the documentation into a c++ sample robot program. The functions are named the same and I don't expect them to be all that different between languages. My main problem is that changing the pid(f) values I give the pid loop actually changes how fast the motor's resting velocity is regardless of what I set the loop to. The speed seems to increase as I increase any of the four values. This obviously is not how pid loops are supposed to work. Any insight would be greatly appreciated!

Jared Russell 20-01-2017 15:24

Re: CAN Talon PID
 
Have you verified that your sensor and your Talon agree on which way is forward (positive throttle should result in positive velocity, and visa versa)?

I'm not sure what you mean by resting velocity; the code you attached will have the Talon attempt to spin at 100rpm whenever the robot is enabled.

Also, read this document very closely. Complexity aside, this is one of the best-documented pieces of hardware in FRC.

CurlyFries 20-01-2017 19:05

Re: CAN Talon PID
 
By resting velocity I mean that when I use the getEncVel() function, if I increase one of the pid(f) values the velocity that the function returns is higher than if I hadn't increased it. In other words I would get more than 100 rpm. As far as I know they agree on the forward direction, but I'll double check tomorrow. I have been reading the link you sent me a lot over this past week, but I haven't found anything pertaining to this problem.

Kevin Sevcik 20-01-2017 20:13

Re: CAN Talon PID
 
Important question. Are you using doing PID position control, or PID speed control?

The behavior you describe is somewhat expected for PID speed control. See this thread for some insight.

CurlyFries 20-01-2017 22:40

Re: CAN Talon PID
 
I wish I had found that thread when I was searching earlier. I'm doing a velocity closed control loop. If I understand correctly now, the FF needs to be adjusted until the encoder velocity matches the desired velocity, and then the other values (it seems mostly P and D) need to be adjusted to respond to changes in load, velocity, etc.

Kevin Sevcik 21-01-2017 00:02

Re: CAN Talon PID
 
Quote:

Originally Posted by CurlyFries (Post 1634277)
I wish I had found that thread when I was searching earlier. I'm doing a velocity closed control loop. If I understand correctly now, the FF needs to be adjusted until the encoder velocity matches the desired velocity, and then the other values (it seems mostly P and D) need to be adjusted to respond to changes in load, velocity, etc.

That's the gist. Paul Copioli suggests adding I to improve acceleration and reduce steady-state error as well. Enough I would reduce the need for FF. But for starters, FF, add P and D, add some I if you're not spinning up as fast as you want.

CurlyFries 21-01-2017 10:39

Re: CAN Talon PID
 
After doing some testing the feed-forward value is responding as I expected, but the P value also increases the velocity the motor goes to, which is confusing me a bit. Should it react this way? I thought the P value was for oscillation around the value that FF goes to.


All times are GMT -5. The time now is 21:59.

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