Go to Post Own your words. - Joe Johnson [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-01-2017, 10:42
CurlyFries CurlyFries is offline
Registered User
AKA: Troy Martin
FRC #2512 (Duluth East Daredevils)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2014
Location: Duluth, MN
Posts: 20
CurlyFries is an unknown quantity at this point
CAN Talon PID

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!
Attached Files
File Type: cpp Robot.cpp (2.4 KB, 31 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 20-01-2017, 15:24
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,080
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
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.
Reply With Quote
  #3   Spotlight this post!  
Unread 20-01-2017, 19:05
CurlyFries CurlyFries is offline
Registered User
AKA: Troy Martin
FRC #2512 (Duluth East Daredevils)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2014
Location: Duluth, MN
Posts: 20
CurlyFries is an unknown quantity at this point
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 20-01-2017, 20:13
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,729
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #5   Spotlight this post!  
Unread 20-01-2017, 22:40
CurlyFries CurlyFries is offline
Registered User
AKA: Troy Martin
FRC #2512 (Duluth East Daredevils)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2014
Location: Duluth, MN
Posts: 20
CurlyFries is an unknown quantity at this point
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.
Reply With Quote
  #6   Spotlight this post!  
Unread 21-01-2017, 00:02
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,729
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: CAN Talon PID

Quote:
Originally Posted by CurlyFries View Post
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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #7   Spotlight this post!  
Unread 21-01-2017, 10:39
CurlyFries CurlyFries is offline
Registered User
AKA: Troy Martin
FRC #2512 (Duluth East Daredevils)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2014
Location: Duluth, MN
Posts: 20
CurlyFries is an unknown quantity at this point
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.
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 13:42.

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