Go to Post A wise man told me a few nights ago, that it is important to own up to all your mistakes, so that others can see you doing that and wont deny and try to hide their own. - Josh Hambright [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 Rating: Thread Rating: 25 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 17-01-2015, 14:57
E Dawg E Dawg is offline
... is not done with FRC yet.
AKA: Ethan
FRC #0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Fort Collins, CO
Posts: 267
E Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud of
Talon SRX QuadEncoder PID Loop

Has anyone had any success with the PID functionality that comes with the SRX? At this point we've wired up a quad encoder to the analog breakout (three different ones - we're testing them to see which one we like more), and have seen many different functions that relate to PID with the encoders in the SRX documentation, and have tried several, but we're not sure where the PID loop is getting error from or how to write that to the SRX from the encoder. We've used PIDWrite, and that didn't help us, it just acted like Set().

Thanks.
  #2   Spotlight this post!  
Unread 17-01-2015, 15:12
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 537
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 QuadEncoder PID Loop

Quote:
At this point we've wired up a quad encoder to the analog breakout
How did you do that?

Are you trying to use the internal PID(F) closed-loop in the Talon SRX? In which case use ::Set() to set the set point after selecting the mode (Position or Velocity).

PIDWrite is part of the wpilib implementation that runs in the RIO, not in the Talon. For that to work you need to source the encoder position/velocity into it by providing a PIDInput to a PIDController.

If you are using the internal PIDF closed-loop in the talon firmware...
Check the signal values mentioned in section 11.2 of the Talon SRX software reference manual. "Closed-loop Error" is the main signal you care about. That's the target set pt minus the current pos/vel. The Self test is very helpful for seeing what's happening. Check that the selected sensor is what you want and that the sensor position and sensor velocity signals seem right before trying to closed-loop to a position/speed.

The actual math is in section 18 (the actual code in the talon for pidf), that might help.

I would test quadrature encoder first. There is an upcoming Talon firmware update with some fixes for analog encoder specifically.
  #3   Spotlight this post!  
Unread 17-01-2015, 15:57
E Dawg E Dawg is offline
... is not done with FRC yet.
AKA: Ethan
FRC #0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Fort Collins, CO
Posts: 267
E Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud of
Re: Talon SRX QuadEncoder PID Loop

We checked ClosedLoopError and it only gives us 0. We're using ::Set() to set the set point now, but that didn't change anything. We've selected the sensor we want and it seems to be giving us the right signals.
  #4   Spotlight this post!  
Unread 17-01-2015, 16:12
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 537
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 QuadEncoder PID Loop

Did you set the mode to position servo in your source? Does it match the selected mode in the self test? Closed Loop Error will not change unless Talon is in a closed-loop mode (position or velocity).
  #5   Spotlight this post!  
Unread 17-01-2015, 16:20
E Dawg E Dawg is offline
... is not done with FRC yet.
AKA: Ethan
FRC #0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Fort Collins, CO
Posts: 267
E Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud of
Re: Talon SRX QuadEncoder PID Loop

We set it to ControlMode::kSpeed and that gave us errors so we switched to kPercentVbus. The self-test says that we are in "throttle" mode.

Also, what do you mean by the mode "position servo"? The only enums we see available are Current, Follower, PercentVbus, Position, Speed, and Voltage.
  #6   Spotlight this post!  
Unread 17-01-2015, 16:30
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 537
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 QuadEncoder PID Loop

Position and Speed are the control modes I'm talking about. You must be in one of these modes for there to be a ClosedLoopError. How else will the Talon know whether to calculate ClosedLoopError in position or in velocity?

If you are selecting PercentVbus, then the Set() calls will simply control the output voltage of the Talon (no closed loop). And CloseLoopErr will not change since Talon won't calculate it.

What errors did it give you? Maybe rebuild the index? https://wpilib.screenstepslive.com/s...ildingTheIndex
  #7   Spotlight this post!  
Unread 17-01-2015, 16:55
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,103
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Talon SRX QuadEncoder PID Loop


Pardon me if the following questions seem obvious but it's best not to assume.

Quote:
Originally Posted by E Dawg View Post
At this point we've wired up a quad encoder to the analog breakout
It sounds like you're saying you ran the quadrature outputs of the encoder through an analog breakout... that's not what you meant is it?

Are you wiring the encoder outputs to the SRX or to the roboRIO?

What is the model number of the encoder you are using.

Quote:
we're not sure where the PID loop is getting error from
The PID in the Talon uses the speed (or position) command it receives via CAN bus from your software as the setpoint for the PID, and uses the signal from the encoder (which must be attached directly to the SRX and not to the roboRIO) as the process variable for the PID. The error is computed by the PID in the SRX by (I assume) subtracting the process variable from the setpoint.

Quote:
or how to write that to the SRX from the encoder.
As explained above, you don't write the error to the SRX. Your software (in the roboRIO) writes the desired speed (or position) via CAN bus to the SRX.



  #8   Spotlight this post!  
Unread 17-01-2015, 17:26
E Dawg E Dawg is offline
... is not done with FRC yet.
AKA: Ethan
FRC #0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Fort Collins, CO
Posts: 267
E Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud ofE Dawg has much to be proud of
Re: Talon SRX QuadEncoder PID Loop

Quote:
Position and Speed are the control modes I'm talking about. You must be in one of these modes for there to be a ClosedLoopError. How else will the Talon know whether to calculate ClosedLoopError in position or in velocity?

If you are selecting PercentVbus, then the Set() calls will simply control the output voltage of the Talon (no closed loop). And CloseLoopErr will not change since Talon won't calculate it.

What errors did it give you? Maybe rebuild the index? https://wpilib.screenstepslive.com/s...ildingTheIndex
We rebuilt the index and set it to kSpeed and it worked. Thanks for your help!
  #9   Spotlight this post!  
Unread 24-01-2015, 15:55
rcdturtle rcdturtle is offline
rcdturtle
AKA: Dick DuCharme
FRC #3534 (House of Cards)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2011
Location: Davison,MI
Posts: 10
rcdturtle is an unknown quantity at this point
Re: Talon SRX QuadEncoder PID Loop

Hello, we are using a Talon SRX controller in position mode set up to use a quadratic encoder with a motor that has a quadrature encoder connected to it. The encoder gives us correct values when we monitor it, but when we try to use it and a PID to stop the motor at a certain point, the motor continues to turn regardless of the fact that the encoder's values are past the setpoint; it doesn't even attempt to slow down.

The same goes for the soft limit function, when we set a soft limit and have to motor turn toward the limit, the motor continues to turn, even past the limit we set. The strange part is, when we try to rotate to motor back - back into the range of values between the soft limits - we can't. The functionality to turn the motor backwards exists, but it refuses to rotate backwards when the values of the encoder are outside the limit we set.
  #10   Spotlight this post!  
Unread 24-01-2015, 15:58
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 537
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 QuadEncoder PID Loop

Sounds like a direction problem. Can you at least confirm the Sensor Position as reported in the Self-Test moves in a positive direction when the motor is driven with positive throttle. See section 7.4 in the Talon SRX Software reference manual for details.
  #11   Spotlight this post!  
Unread 24-01-2015, 16:40
rcdturtle rcdturtle is offline
rcdturtle
AKA: Dick DuCharme
FRC #3534 (House of Cards)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2011
Location: Davison,MI
Posts: 10
rcdturtle is an unknown quantity at this point
Re: Talon SRX QuadEncoder PID Loop

The sensor position does move in the positive direction when we drive it in the positive direction and vice-versa.
  #12   Spotlight this post!  
Unread 24-01-2015, 16:46
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 537
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 QuadEncoder PID Loop

Next leave the motor controller in throttle mode, enable the soft limits and drive the motor to the forward and reverse soft limits. See if that works by itself. Use the Self-Test to confirm the soft limits thresholds.

Remember that the forward soft limit only takes effect when Talon SRX is throttling forward (green). And Reverse soft limit is in effect only when throttling reverse(Red).

Also obviously the forward soft limit must be greater than the reverse soft limit since positive drive => positive sensor position change.

Last edited by ozrien : 24-01-2015 at 16:50.
  #13   Spotlight this post!  
Unread 24-01-2015, 16:48
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 537
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 QuadEncoder PID Loop

Quote:
Originally Posted by rcdturtle View Post
The sensor position does move in the positive direction when we drive it in the positive direction and vice-versa.
K. just to be clear be sure to check the actual "Sensor Position" signal, not just the "Quadrature Encoder Position". They are different and soft-limit/closed-loop logic only uses the "Sensor Position" signal.
  #14   Spotlight this post!  
Unread 24-01-2015, 17:18
rcdturtle rcdturtle is offline
rcdturtle
AKA: Dick DuCharme
FRC #3534 (House of Cards)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2011
Location: Davison,MI
Posts: 10
rcdturtle is an unknown quantity at this point
Re: Talon SRX QuadEncoder PID Loop

Ah, we had the encoder's output inverted and not the sensor position's.
Inverting the sensor position fixed our problem, both the PID and soft limits work now.

Thank you for the help.
  #15   Spotlight this post!  
Unread 24-01-2015, 19:18
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 537
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 QuadEncoder PID Loop

Cool. Anything I can add to section 7.4 to help make it clear how to keep motor and sensor in phase?
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 19:34.

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