Need help with converting a subsystem of another team's code from REV-based to Phoenix-based code

Hello to whoever is reading this,
I am currently stuck on how to convert this arm subsystem, which belonged to a team using NEO’s, to a subsystem that uses TalonFX (more specifically Falcon 500’s). All the rest of the motors are the same, just the arm motors and encoder are different.
The code is based off of the Unqualified Quokkas robot, which our robot is also based off of. The arm of the robot rotates back and forth, using two motors, one inverted. The main thing I need to figure out is how to fix the errors in the code with the encoder, as I believe the NEO’s (the motor they use for the arm) has a built-in absolute encoder, with the Falcon 500’s that my team is using do not. We will be putting on a CANCoder on the hex shaft that the two motors are connected to. I also need help on how to figure out the PID controls for the robot, as REV’s PIDController seems a lot different than how Phoenix 6 uses PID. Here is the code we are based our code on: 2024-Robot/src/main/java/frc/robot/subsystems/Arm.java at main · Delmar-Robotics-Engineers-At-MADE/2024-Robot · GitHub
And here is our code: FRC_6914_Swerve_Henry_20240224/src/main/java/frc/robot/subsystems/Arm.java at main · Herolife217/FRC_6914_Swerve_Henry_20240224 · GitHub

For Converting to/from Pheonix Framework

This probably won’t have everything you need but I found this to be helpful a while back.

I recommend using the CTRE Phoenix 6 library. You’ll use closed-loop control. For the encoder, the easiest thing to do is use Remote CANCoder mode.

The bulk of your code will be setting up the configuration, then I would use the PositionVoltage or MotionMagicVoltage control type. The code you’re trying to convert is generating a motion profile on the roboRIO. When you’re using SPARK Maxes, you kind of have to do that because they don’t properly implement “Smart Motion” for position control. On the Talon FX, Motion Magic works great for position control, or you can still do it on the rio (see motion profiling.)

I recommend using the arm gravity feedforward feature as well. This is another feature that SPARK Max doesn’t have, so ArmFeedforward was being used on the roboRIO with an arbitrary feedforward value. You can do this with Talon FX as well, but I’d recommend doing it on the motor controller.

1 Like

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