![]() |
Good way to bring shooter to exact speed?
Hi,
We recently decided to put an encoder on our shooter so that we can stop setting the shooter to a percentage of the battery power to an actual rpm. The problem we have now is how do we exactly program it to go to a certain rpm? My best guess would be to use a PID loop and then limit the output to not include negative numbers so that the shooter doesn't suddenly change directions. We have tried just writing a linear equation like speed = distanceFromRPM * .01 +.4 but that usually didn't work well and the time it took to reach the desired RPM had a huge variation. We just want a method that takes very little time to get up to the RPM and is consistent. Any ideas are appreciated and welcomed! |
Re: Good way to bring shooter to exact speed?
Quote:
|
Re: Good way to bring shooter to exact speed?
Quote:
|
Re: Good way to bring shooter to exact speed?
Quote:
I could be wrong but with at 15000 PPR encoder and 5000 RPM, we were using a H0 somewhere in the thousands... |
Re: Good way to bring shooter to exact speed?
Quote:
Code:
#define self.last up top |
Re: Good way to bring shooter to exact speed?
I'd go for a PID. You'll need to convert the encoder count to a 0-1 range of speeds, but otherwise, if it's like it was back in the old days (2011), it's pretty easy to set up.
As for tuning said PID, there are various ways (google it, as I don't have my controls textbook handy). Whichever tuning technique you use, you'll want to get it so it has a quick response without breaking anything, blowing anything, or oscillating. I'd avoid over-tuning (getting it really, really spot on) as you're liable to become marginally stable (which puts you one bit of drift away from instability). Yeah there is probably an easier FRC-specific way to do this, but this (minus the PID code) is what they do in industry and will likely produce the best results possible with your hardware. As many of us know, controls can be temperamental to tune, but when you get it right, it will deliver. |
Re: Good way to bring shooter to exact speed?
|
Re: Good way to bring shooter to exact speed?
Use the Talon SRX in speed control mode. The update rate and onboard filtering is better than anything you'll be able to get in code running on the crio.
|
Re: Good way to bring shooter to exact speed?
Quote:
Also: Is there a way to use the roboRIO's PID class or make a custom PID class that can do speed control?* *Could you just use a generic PID controller and use the following piece of code? (As ratdude747 implied) Code:
if(Motor_Speed<0){ |
Re: Good way to bring shooter to exact speed?
Quote:
|
Re: Good way to bring shooter to exact speed?
Quote:
I brought up the idea of "limiting" the PID's output range from 0-1 (As suggested by ratdude747) in case if someone wishing to control a flywheel didn't happen to have an SRX handy. :] |
Re: Good way to bring shooter to exact speed?
Quote:
Quote:
I would expect more consistent results by calculating the initial b as 2*M'+1, where you are confident that M' is below the "proper" value for M, perhaps 75% or 90% of your "best estimate" depending on how well you know this number. * - As long as the system has continuous, monotonic response near M, and some sort of frictional losses, there should be a decay ramp of some variety or other, which is enough for my argument. If the system is linear near voltage M, and the frictional losses are viscous (proportional to speed), this will be a classic exponential decay ramp. |
Re: Good way to bring shooter to exact speed?
Quote:
Quote:
|
Re: Good way to bring shooter to exact speed?
Perhaps I missed something really basic, but this is how I read these posts:
Quote:
Quote:
Here's what I'm considering: for simplicity, let's assume a ridiculously simple system such that over the range of 0.2 to 0.8, the asymptotic/terminal speed is equal to the applied voltage multiplier (for a fresh battery). The target speed is 0.5, but M for a desired speed of 0.5 was previously mis-measured at 0.6. At initialization, b = 2 * 0.6 - 1 = 0.2. e=S-P begins positive, as the motor is not moving (Set point speed definitely faster than measured speed). The applied voltage multiplier at startup is 1.0, which causes the shooter to promptly reach a speed of 0.5. By the time speed reaches [for argument's sake] 0.51, the applied voltage is adjusted to 0.6, and e is set to a negative value (that is, running too fast). The speed then continues to increase until asymptotically reaching 0.6. d continues to return negative values, so signbit(e) == signbit(d). The if clause in your loop is never reached, and the voltage is held at 0.6 -- until the battery voltage drops so that a voltage multiplier of 0.6 cannot maintain a speed of 0.5. At that point, the algorithm would begin to work as desired, but the match would likely be long over. |
Re: Good way to bring shooter to exact speed?
Quote:
|
Re: Good way to bring shooter to exact speed?
Quote:
Quote:
Quote:
|
| All times are GMT -5. The time now is 02:07. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi