PID Tuning Two Falcons in Phoenix Tuner

Hey all,

I’ve searched the CTRE documentation and the internet for this, and can’t find an answer.

We want to tune our PID values for our flywheel shooter, which is using two Falcon 500’s into a single gearbox outputted to our flywheel. I basically know how to tune PID values (kF, kP, kI, kD) in Phoenix Tuner with a single Falcon, but I don’t see how to tune and control the two Falcons simultaneously.

In code we made them a single Speed Controller Group, or could also have one follow the other (also in code), but before I turn things on and burn things up (by back-driving a Falcon at 5000-6000 rpm), I’m looking for some guidance on what steps I need to take to safely power on, control, and tune this setup using the Phoenix Tuner.

Any assistance you can offer is greatly appreciated. Thanks!

You can check the inversion of each motor to be sure that when one follows the other, the motors don’t fight each other. Then just write the motor following in code. I do recommend running the flywheel slowly at first to be sure everything’s ok.

I don’t have experience tuning motors in Phoenix Tuner but I can give you some suggestions.

If you are tuning stuff in Phoenix Tuner, that means that you are using the onboard PID of the talons. If you use a SpeedControllerGroup, you are doing PID calculations on the roboRIO. If you wanted to use a SpeedControllerGroup, you could easily tune PID using the LiveWindow on shuffleboard. However, since you are using Phoenix Tuner, you should not use a SpeedControllerGroup.

I am unaware of doing this through Phoenix Tuner, but one option is to set up one motor to follow the other in the code, then either hard code the PID values and tune them, or create your own Sendable class to be able to tune the PID values in LiveWindow. Creating your own Sendable class is a bit of work, but if you are up for it, it will make your life easier.

We did this recently. Before setting one controller to follow the other, we used Phoenix Tuner to run just one of the controllers with + output and confirmed the direction, then did the same with the other controller, then set one to follow the other by deploying a minimal program to our test bed that set one to follow the other in robotInit, then used the tuner to run the master. Also, we had a failed attempt where the motors were opposing each other but we had set the output low (0.2) and we were able to quickly disable the tuner before the motors could be damaged; the motors or controllers also emitted a screeching alarm so there was no ignoring the problem.

When the tuner runs the master, the follower followed properly?

We definitely have controlled two falcons at once through Tuner controlling the master, after deploying code that configured the follower as an inverted follower. Green lights on both sides.

Disclaimer, there was some weird stuff going on when we started trying to tune velocity control, and then we broke the prototype for unrelated reasons so I haven’t been able to dig into it yet. Pretty sure it’s related to me feeding it bad kF/kP values though.

Yes, although we weren’t doing any PID and we did not record the individual motor outputs. We were testing range and recovery when fed multiple balls quickly as a comparison to earlier tests using just one motor; the performance was improved by the second motor so it seemed to be following properly.

Thank you!

Working so far so good with one motor following the other, but for some reason when we set current limits and/or PID constants in the Config tab and hit “save”, it keeps the values until we redeploy code or power cycle the robot, at which point they all reset.

Aren’t these values supposed to “stick” to the motor like its CAN ID does? I thought so, but that’s not the behavior I’m observing, and it’s a bit tedious to have to manually reset everything every time.

Any help/wisdom here would be appreciated.

Are you by any chance calling talon.configFactoryDefault() in your robot code? That would be my first guess, otherwise I don’t actually know if they are supposed to reset or not. I’d assume you’re correct. I don’t think they’re supposed to reset.

Calling configAllSettings() will also change your configs back to factory default before applying the specified configs. So if the configs you’ve set in Tuner aren’t part of the config object in code, they’ll be lost when configAllSettings is called.

Otherwise configs in Tuner are persistent like all other configs.

2 Likes

We were, in fact, calling talon.configFactoryDefault()! And now we aren’t, and the values are sticking. Thank you!

Glad I could help. I know in 2018 we had problems where the talons were configured with weird values from previous years, so just make sure you know the configuration of each talon when you add or switch out motor controllers.

What we usually do is test PID values using a dashboard (in your case you use Phoenix Tuner), then we hard code them into the robot code. I like the call to configFactoryDefault() because I know exactly what I’m getting and I don’t have to worry about how they’re previously configured. However, do what works best for you guys.

That’s exactly what we did–tuned them in Phoenix, then set them in robot code and reset the Falcons.

1 Like