Go to Post Exactly matching weight at two different regionals is an indicator of something fishy. :p - Alan Anderson [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-01-2016, 01:11
ram112358 ram112358 is offline
Registered User
FRC #3502
 
Join Date: Jan 2015
Location: Tallahassee
Posts: 9
ram112358 is an unknown quantity at this point
Exclamation Talon SRX Closed Loop

I'm having some troubles getting a closed loop position control loop set up running on a talon SRX. I'm using Java and after searching on delphi and else where I can't seem to find a solution for my problems.

I'm trying to use the closed loop position control function that runs on the Talon SRX. I've read any documentation I can find on it and I'm certain that I have the encoder plugged in correctly to the breaker board. The code is currently set up to run off of half of our tank drive from last year to be sure there is no damage done to our lifter. We are using the new KOP router and the RoboRIO was flashed at the beginning of build season with the latest image and all the talons have the newest firmware as well.

With my code (attached) I can run the "lifter" off a joystick and watch the encoder value change as I do so. When I press the button to run my command that should run the pid functionality and through the RoboRIO web interface I can confirm that the Talon goes into closed loop position mode and that my PID values are actually sent to the Talon. However, when I push said button the "lifter" just runs full speed forward regardless of the relation between the value of the encoder and the set value.

Is there any insight you can give me into this or what's going on or resources where I can learn more about how to address this problem?

Thanks in advance for your help.

Link to zip of project: https://drive.google.com/file/d/0B32...ew?usp=sharing
  #2   Spotlight this post!  
Unread 30-01-2016, 01:19
jkoritzinsky jkoritzinsky is offline
Registered User
AKA: Jeremy Koritzinsky
FRC #4786 (Nicolet F.E.A.R.)
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Glendale, Wisconsin
Posts: 78
jkoritzinsky will become famous soon enoughjkoritzinsky will become famous soon enough
Re: Talon SRX Closed Loop

Are you sure the encoder is wired up correctly? This sounds like a runaway system, which would happen if you have your A and B channels swapped. That would cause the motor to move faster and faster away from the setpoint because it keeps trying to get closer but it is getting farther away.
__________________
Nicolet F.E.A.R. (Team 4786) - Aerial Assist - Programming Manager
Nicolet F.E.A.R. (Team 4786) - 2015+ - Junior Mentor

SuperScouter for FRC Developer
  #3   Spotlight this post!  
Unread 30-01-2016, 02:06
ozrien's Avatar
ozrien ozrien is online now
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 549
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Talon SRX Closed Loop

Talon SRX Software Reference Manual
http://www.ctr-electronics.com/talon...ical_resources

Please read section 7.4 to make sure your sensor and motor is in-phase.
Use reverseSensor() if sensor and motor is not in-phase.
  #4   Spotlight this post!  
Unread 30-01-2016, 15:00
ram112358 ram112358 is offline
Registered User
FRC #3502
 
Join Date: Jan 2015
Location: Tallahassee
Posts: 9
ram112358 is an unknown quantity at this point
Re: Talon SRX Closed Loop

I double checked and the encoder is wired in correctly and the are in-phase. I noticed that the pid button did the same thing regardless of whether or not the encoder is plugged in (but when it is plugged in I am able to access the value of the encoder through both the web interface and the smartdashboard)
  #5   Spotlight this post!  
Unread 30-01-2016, 15:07
ozrien's Avatar
ozrien ozrien is online now
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 549
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Talon SRX Closed Loop

Grab a screenshot of the roboRIO-web-based config Self Test when the closed-loop is misbehaving. That will indicate what the Talon is doing and why.

Do a P-gain only closed loop to make debugging simpler (if you haven't already).
  #6   Spotlight this post!  
Unread 30-01-2016, 17:13
ram112358 ram112358 is offline
Registered User
FRC #3502
 
Join Date: Jan 2015
Location: Tallahassee
Posts: 9
ram112358 is an unknown quantity at this point
Re: Talon SRX Closed Loop

Here's the screen shot you asked for. Would a P-gain only loop be setting a value (such as 0.1) to P and 0 for the rest of them? That is how it is set up currently.
Attached Thumbnails
Click image for larger version

Name:	roborio PID screenshot.png
Views:	82
Size:	118.7 KB
ID:	19924  
  #7   Spotlight this post!  
Unread 30-01-2016, 17:28
ram112358 ram112358 is offline
Registered User
FRC #3502
 
Join Date: Jan 2015
Location: Tallahassee
Posts: 9
ram112358 is an unknown quantity at this point
Re: Talon SRX Closed Loop

I also notice that the closed loop error value only seems to increase when I trigger the pid command, any thing else only seems to have no effect on that number.
  #8   Spotlight this post!  
Unread 30-01-2016, 17:36
ozrien's Avatar
ozrien ozrien is online now
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 549
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Talon SRX Closed Loop

The selected Sensor Velocity (-439.57) is negative while the appliedThrottle is positive (100%).

This means the sensor and motor is NOT in-phase.

As a result, the ClosedLoopErr is moving away from zero the more the motor-drives.

Please look at Section 7.4 more closely, and use the reverseSensor() function to adjust the sensor direction so that positive drive moves the position in a positive direction. (Section 7.3).
  #9   Spotlight this post!  
Unread 30-01-2016, 18:42
ram112358 ram112358 is offline
Registered User
FRC #3502
 
Join Date: Jan 2015
Location: Tallahassee
Posts: 9
ram112358 is an unknown quantity at this point
Re: Talon SRX Closed Loop

Ok turns out I accidentally posted that screenshot whike running code that had the reverseSensor() implemented, I knew that they were in-phase but I wanted to see what that function did on a whim and forgot I was running that version of the code. Another thing I realized was that I was setting the desired pid value to 1000 (a mentor and I didn't know that the encoder values are scaled) and so the whole time I was trying to run my code the robot was trying to reach an insanely high encoder value.

Thanks for all your help, we just need to figure out how the scaling works now.

Also, this is the code I was running, what I linked earlier was an archive of my projects (which you might have realized included this project)
https://drive.google.com/file/d/0B32...ew?usp=sharing
  #10   Spotlight this post!  
Unread 01-02-2016, 02:51
ozrien's Avatar
ozrien ozrien is online now
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 549
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Talon SRX Closed Loop

Looking at the screenshot, you must have called ConfigEncoderCodesPerRev(360) because the CPR is updated in your self-test results. That means you are meeting the requirements in Section 17.2.1.

So that means setting soft limits, getting sensor velocity, getting/setting sensor position, and setting target position/velocity are all done in rotations/RPM and not native units. It's better explained in Section 17.2.2

If you don't call ConfigEncoderCodesPerRev() than everything goes back to native units (like last year - see Section 17.2 for details).
Closed Thread


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 01:30.

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