Bang-Bang control onboard Talon FX?

Hello,
I’m wondering if it’s possible to use bang-bang control onboard the Talon FX. If not, we could do it RoboRIO side too, but I’m just interested in the 1kHz loop time instead of 50Hz.

This is for a single wheeled flywheel shooter driven by two falcons. I’m interested in at least trying Bang-Bang (which is where the motor goes at full throttle when it’s below the velocity setpoint and coasts when it’s above) because aside from not having to tune a PID, full throttle would get the flywheel back up to the desired speed after shooting a ball faster than an something proportional to the error, which would end up being less than full throttle.

We’re using LabVIEW, but this should apply to other C++ and Java because it’s CTRE’s libraries I’m dealing with. What I tried was setting a super high P value with the Config PIDF method so that any error would produce a full output, and then using the Config Peak Output to be between 0 and 1. Then I used the Set: Velocity method with my desired velocity.

The flywheel oscillated around my setpoint, applying full negative throttle when it exceeded the setpoint. That indicates to me that the Peak Output does not apply in closed loop modes. Is there a way of constraining the output range that works in Velocity Closed loop control? Is there another way of achieving this?

1 Like

One thing I found to work is enabling voltage compensation and configuring a saturation less than 12. I don’t know if that’s the correct way, but it should work.

And another hack could be to set the reverse limit switch to normally closed so it never attempts to drive backwards.

That’s a clever idea with the limit switch. I’ll try it next time. Thanks!

PID control with a minimum output of 0 and a maximum output of 1 and a large P is the same as bang bang control as you tried.

In some cases there are different settings for closed and open loop control, but in my quick search I didn’t see it. Have you checked with tuner to make sure the settings took?

Bang bang control works best when there’s a lot of inertia to smooth the bangs.

1 Like