Go to Post And I'm sure I speak for most if not all of CD when I say: "How can we help you do that?" - EricH [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 02-03-2016, 13:29
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Talking Bang-bang using Talon-SRX and PID for a Shooter

Is this possible to use the Talon-SRX with a bang-bang algorithm so that the Talon checks the encoder value?
The encoder is connected to the Talon directly.
I want to do this in order to sample the encoder in a faster rate than regular code.

and another question:
What is better for getting a shooter to the target speed faster - Bang-bang or PID (using Talon SRX)?

Thank you.
__________________
2016-2017 - Programming Mentor
Curie Sub-Division Champions with 694, 379 & 1511
2015 - Team Captain & Head of Programming Crew
Carson Sub-Division Champions with 1325, 20 & 1711
First ever Israeli team on Einstein
2014 - Team Captain & Head of Programming Crew
2013 - Head of Programming Crew
2012 - Member of Programming Crew
  #2   Spotlight this post!  
Unread 02-03-2016, 13:39
ahartnet's Avatar
ahartnet ahartnet is offline
Registered User
AKA: Andrew Hartnett
FRC #5414 (Pearadox)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2005
Location: Houston, Texas
Posts: 200
ahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond reputeahartnet has a reputation beyond repute
Re: Bang-bang using Talon-SRX and PID for a Shooter

Probably depends a lot on the mechnasim it's attached to, and how precise you need it's spin to be.

For instance, we have a 5 lb wheel that we have a CIMcoder + miniCIM running off a talon. When we remove power and leave the talon in coast mode, it maintains it's speed pretty well (until it has any load obviously). It also takes a fair bit of effort to spin it up, so the bang-bang type method might actually be the preferred method. Functionally - I'd argue this is pretty much a crude PID control with a high P.

If you have a mechansim without that much inertia, under a higher load, or that you need more finely controlled - then PID is definitely a good way to go. I can say first hand that the talon has a lot of good documentation for Java. I think it does for Labview and C++ too: https://www.ctr-electronics.com/Talo...e%20Manual.pdf
__________________
Team 451 The Cat Attack, Student Alumni (2005)
Team 1646 Precision Guessworks, Mentor (2006-2008)
Team 2936 Gatorzillas, Mentor (2011-2014)
Team 5414 Pearadox, Mentor (2015-Present)
  #3   Spotlight this post!  
Unread 02-03-2016, 13:42
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Bang-bang using Talon-SRX and PID for a Shooter

It is also possible to simulate a bang-bang controller using PID, by setting the P gain very high and limiting the output so the motor can only try to move in the desired direction. This can be done using the Talon SRX API.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
  #4   Spotlight this post!  
Unread 02-03-2016, 13:46
cjl2625's Avatar
cjl2625 cjl2625 is offline
apel py
AKA: Cory Lynch
FRC #2067 (Apple Pi)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Guilford, CT
Posts: 412
cjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to beholdcjl2625 is a splendid one to behold
Re: Bang-bang using Talon-SRX and PID for a Shooter

I'd assume that bang bang would theoretically spin up faster since it spins at full speed until it hits the target speed. However, when I tried it, when it got up to speed, the motor started making nasty noises when flickering on and off.

I found the PID + Feedforward (built into the SRX) to work great on speed control. In fact, I got great results with purely P and F. It spins up fast, goes right to the target speed, and doesn't make the same disconcerting noises that I experienced with bang bang.

I guess the results of bang bang vary from system to system.
__________________
Head Programmer / Driver

Last edited by cjl2625 : 02-03-2016 at 13:48.
  #5   Spotlight this post!  
Unread 02-03-2016, 13:55
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by cjl2625 View Post
I found the PID + Feedforward (built into the SRX) to work great on speed control. In fact, I got great results with purely P and F. It spins up fast, goes right to the target speed, and doesn't make the same disconcerting noises that I experienced with bang bang.
This is what we are currently using, though I have some experimental code that uses the pseudo-bang-bang I described before. Ours sits around +-50 RPM from the target, which turned out to be good enough for our shooter.

Also, this paper and its discussion has some good information about shooter control: http://www.chiefdelphi.com/media/papers/2663
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
  #6   Spotlight this post!  
Unread 02-03-2016, 14:19
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
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: Bang-bang using Talon-SRX and PID for a Shooter


Bang-bang can be a good solution to shooter wheel speed control, but if you're using the SRX via CAN with the encoder plugged into the SRX, I'd say definitely use the SRX's built-in PIDF speed control, which updates at 1KHz (far faster than roboRIO does PID).

Quote:
Originally Posted by cjl2625 View Post
when it got up to speed, the motor started making nasty noises when flickering on and off
I've heard this happen when the motor controller was set to brake mode. Another possible reason: to much free play between motor shaft and wheel (gearbox, chains, etc). See this post.



Last edited by Ether : 02-03-2016 at 14:27.
  #7   Spotlight this post!  
Unread 02-03-2016, 14:32
JamesCH95's Avatar
JamesCH95 JamesCH95 is offline
Hardcore Dork
AKA: JCH
FRC #0095 (The Grasshoppers)
Team Role: Engineer
 
Join Date: Dec 2004
Rookie Year: 2001
Location: Enfield, NH
Posts: 1,838
JamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond repute
Re: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by Ether View Post

Bang-bang can be a good solution to shooter wheel speed control, but if you're using the SRX via CAN with the encoder plugged into the SRX, I'd say definitely use the SRX's built-in PIDF speed control, which updates at 1KHz (far faster than roboRIO does PID).
[snip]
Seconded.

Also, bang-bang control doesn't have to modulate speeds from 0-1. One could modulate from 0.8-0.9, for example.
__________________
Theory is a nice place, I'd like to go there one day, I hear everything works there.

Maturity is knowing you were an idiot, common sense is trying to not be an idiot, wisdom is knowing that you will still be an idiot.
  #8   Spotlight this post!  
Unread 02-03-2016, 14:38
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
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: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by JamesCH95 View Post
Also, bang-bang control doesn't have to modulate speeds from 0-1. One could modulate from 0.8-0.9, for example.
Yes, if you know for sure that that range is sufficient for all loads and tolerances you are likely to encounter.

And of course, setting upper and lower throttle levels removes the "no tuning required" advantage of bang-bang.

And limiting the upper number to anything less than full throttle removes "fastest spinup and recovery" argument for bang-bang.


  #9   Spotlight this post!  
Unread 02-03-2016, 14:51
JamesCH95's Avatar
JamesCH95 JamesCH95 is offline
Hardcore Dork
AKA: JCH
FRC #0095 (The Grasshoppers)
Team Role: Engineer
 
Join Date: Dec 2004
Rookie Year: 2001
Location: Enfield, NH
Posts: 1,838
JamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond reputeJamesCH95 has a reputation beyond repute
Re: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by Ether View Post
Yes, if you know for sure that that range is sufficient for all loads and tolerances you are likely to encounter.

And of course, setting upper and lower throttle levels removes the "no tuning required" advantage of bang-bang.

And limiting the upper number to anything less than full throttle removes "fastest spinup and recovery" argument for bang-bang.


All valid points, of course!

Perhaps the more useful parameter is the lower throttle limit, which would slow any oscillations in the system.
__________________
Theory is a nice place, I'd like to go there one day, I hear everything works there.

Maturity is knowing you were an idiot, common sense is trying to not be an idiot, wisdom is knowing that you will still be an idiot.
  #10   Spotlight this post!  
Unread 02-03-2016, 15:01
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
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: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by JamesCH95 View Post
Perhaps the more useful parameter is the lower throttle limit, which would slow any oscillations in the system.
Agreed. In systems that
a) have insufficient inertia or excessive friction or windage,

and

b) are already running the controller as fast as practical
I have recommended trying that.


  #11   Spotlight this post!  
Unread 02-03-2016, 15:20
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,358
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Bang-bang using Talon-SRX and PID for a Shooter

We are running a simple Bang-Bang in Java this year.
We are using separate thread to control the wheel. It measures the period of a single flag on the shooter wheel. We have two 775-Pro driving the wheel with a 60:19 reduction.

Here a a couple "gotcha's" we encountered.
A 10ms control loop is too slow with this set up. Way too much overshoot. We went with a 5ms loop and overshoot is tolerable.
Running 2 775-Pros is overkill!
We run ours with one breaker removed for one of the motors. This helps reduce overshoot and gives us a backup in case something terrible happens.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #12   Spotlight this post!  
Unread 02-03-2016, 15:30
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
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: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by billbo911 View Post
We are using separate thread to control the wheel. It measures the period of a single flag on the shooter wheel.
Please provide more detail how you are obtaining the period.

For example:
a) sensor is configured as a counter object, and the 40MHz FPGA is giving you an exact period via getPeriod() in WPILib,

or

b) you are counting wheel revs, and dividing that into your nominal thread period,

or,

c) you are counting wheel revs, and dividing that into your measured thread period,

or

d) something else?
I ask because bang-bang does not like phase lag and/or jitter on your speed signal.


  #13   Spotlight this post!  
Unread 02-03-2016, 16:11
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,358
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by Ether View Post
Please provide more detail how you are obtaining the period.

For example:
a) sensor is configured as a counter object, and the 40MHz FPGA is giving you an exact period via getPeriod() in WPILib,

or

b) you are counting wheel revs, and dividing that into your nominal thread period,

or,

c) you are counting wheel revs, and dividing that into your measured thread period,

or

d) something else?
I ask because bang-bang does not like phase lag and/or jitter on your speed signal.


DISCLAIMER: I am not a Java programmer.

We are using a Banner photo sensor, I believe the model is Q12RB6LV, and a single piece of Retro tape in one section of our shooter wheel. The tape spans approximately a 50 deg arc. You can see it in the photo below near the bottom of the image.



I had our programmer work with the WPILib to figure out how to get the period of a pulsed signal. I believe the command he is using is getPeriod(), at least that rings a bell.
getPeriod() returns a value in seconds and has a resolution of 1ms. This limits the number of steps in RPM we can achieve to only 15, but that is more than enough for this game. The value we read is very consistent.

We usually target a period of .025 for our default shot, but will vary it with distance to as low as .010 as needed (10ms is basically full power all the time).

The psuedo code we use is:

Code:
if (getPeriod() <= .025)
{
MotorDrive = 0
}
else
{
MotorDrive = 1
}
wait (5ms)
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist

Last edited by billbo911 : 02-03-2016 at 16:15.
  #14   Spotlight this post!  
Unread 02-03-2016, 16:23
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
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: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by billbo911 View Post
getPeriod() returns a value in seconds and has a resolution of 1ms
I'd like to drill into this a bit deeper if you'd be willing to bear with me. What is the source for the "1ms resolution" statement?


  #15   Spotlight this post!  
Unread 02-03-2016, 16:50
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,358
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Bang-bang using Talon-SRX and PID for a Shooter

Quote:
Originally Posted by Ether View Post
I'd like to drill into this a bit deeper if you'd be willing to bear with me. What is the source for the "1ms resolution" statement?


Fair question.
This is my interpretation of:

Quote:
getPeriod
public double getPeriod()
Get the Period of the most recent count. Returns the time interval of the most recent count. This can be used for velocity calculations to determine shaft speed.
Specified by:
getPeriod in interface CounterBase
Returns:
The period of the last two pulses in units of seconds.
That and the fact that the value getPeriod() produces only has 3 places to the right of the decimal point. ie. .020.

I have no problem being wrong in my interpretation, wouldn't be the first time. But I can tell you this, our code works, and we use 3 decimal place values to control it.
Remember my disclaimer, Java is not a programming language I use.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
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 10:49.

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