Is there a simple way to control the velocity of Falcon 500 motors by using TalonFXControlMode.Velocity? I cannot seem to find any documentation on this, other than the examples for more complicated motor control using PID on the CTRE GitHub for closed loop velocity control. I have attempted to use motor.set(TalonFXControlMode.Velocity, 300), but this has not worked for moving the motor or changing indicator lights on the Falcons. Are there any simple ways to utilize this type of motor control?
There aren’t simple ways to control velocity. Here’s why: it’s all dependent on the mechanism you’re controlling. Without closed loop help, the motors are running on a voltage from -12 to 0 to 12.
Are you controlling a flywheel, elevator, or drivetrain? What units are you measuring?
Control mode.velocity runs on closed loop loop control.
What you are talking about IS the closed-loop velocity PID control mode. You have to configure the PID gains on the motor controller to use it.
At a crude level, you can find the voltage/percent-output to send to the motor controller to achieve some target velocity by finding (applied voltage
/ current velocity
) = velocity constant
. Multiply this value with your target velocity to estimate the voltage you should use. For example, you might hypothetically measure 4500 RPM when applying 12 volts, so 12 / 4500 = 0.002667. So then to reach 3000 RPM you can calculate 0.002667 * 3000 = 8 volts. This is a simplification of feedforward, specifically the kV value, and doesn’t account for static friction or the inertia of the system.
For our system we are controlling 2 flywheels for our scoring mechanism, and we are planning to measure in RPM.
Here’s the project that out team uses to tune flywheels. Everything is configurable from Shuffleboard, including CAN id, follow motor, direction, kP, kF, kI, kD, iZone, and also a ramp rate. Just follow the directions. There’s a branch that handles SparkMax as well.
CAVEAT. I just ported the Flywheel-Tuner code to 2022 WPILib, but haven’t had a chance to re-test it yet this year.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.