Ensuring Constant Speed on Shooter with PID & integrated encoder

Hey everyone,

I was trying to find a way to make sure that a shooter flywheel maintained a constant velocity even when a power cell is being shot using a PID loop. Has anyone done this, and how so? Considering that a command-based structure is being used, did you use the PID on the motor controllers in the falcon? Used something from the WPILib structures? Made your own PID structure? For reference, the shooter being software-d will be a hooded shooter using 2 Falcon 500 motors geared at a 1:1.333 ratio and a 4-inch flywheel and 1.5 inches of compression.

Thanks in advance,
Vinay

Right now we currently have a Falcon 500 geared 1:1 to the output. We are using the PID loop through the Talon FX with the integrated sensor.

P= 0.1
I = .00014
We also have closed loop ramp rate set to .25 seconds.

For something like this, doing your PID loop on the motor controller itself makes a lot of sense.

The falcons have a max RPM of 6380. You can convert rpm to CTRE units by doing this:

rpm * countsPerRevolution / 600. For the integrated encoder, the countsPerRevolution is 2048.

I would recommend using PID on the motor controller, with kP, kV, and kS values determined through the WPILib characterization tool. The arbitrary feed forward can be used to eliminate the need for an I or D term, so you only need P.

Is there a link to your code I could look at? It would be much appreciated, but I totally understand if you aren’t willing to share.

We use the spark max motor controllers to do this. It has a builtin pid loop. http://www.revrobotics.com/sparkmax-users-manual/

Here it is: https://github.com/frc1444/robot2020/blob/master/wpi/src/main/java/com/first1444/frc/robot2020/MotorBallShooter.java or permalink

I wanted to try to explain it because our code doesn’t use a standard structure so I didn’t want to confuse you too much.

You can use talon.config_k* to config the PID values.

Have the same problem maintaining a constant velocity when inputting a power cell

If you post more info, I may be able to help. Or you can create a new thread that describes what problems you’re having.

When you shoot a power cell, your velocity is going to go down. It’s going to be very difficult to have a PID loop that will keep the velocity perfectly at the set point when you put in a power cell. The PID loop for the velocity can be used to get back to the desired velocity quicker. The advantage of using a velocity PID loop is also that you will get consistent results no matter what the battery voltage is

2 Likes

The optimal way to take care of this is to use a Velocity Control setup.

Integrated PID within your CTRE motor controllers is the easiest way to do this is follow their instructions here. We tuned a shooter in about an hour that could shoot all five balls under a second from 25’ away without missing any of them by going step by step.

1 Like

Hi,
We have 2 x Neo+SparkMAX driving a single hex shaft with flywheels. The Neos are mounted on 2 ends of the shooter and connected to the shaft using chain/sprockets. In such setup, what is the right way to do closed loop velocity control implementation?
a) Setup a closed loop velocity controller on each SparkMAX separately with the same PIDF coefficients.
b) Make one SparkMAX leader and the other one follower, and setup closed loop velocity control only on the leader.

If the motors are mechanically coupled (even if at a distance), make one a follower. If you have separate loops they will likely fight each other at least some of the time.

2 Likes

That makes sense. Thank you for the quick response!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.