Falcon500 Position Control Loop Help

We are trying to get our team’s swerve drive working. We are using the FalconSwerveCode found here —> GitHub - dirtbikerxz/BaseTalonFXSwerve modiffed for navx, and SRX Mag Encoders.

Everything works for speed motors but not our position motors.

We have gone backward to just try and get a wheel to spin where we tell it. Our code is below. What we have found is that an unloaded motor with the same code does exactly what we want. Velocity starts large and decreases until it gets so low that the motor can’t move anymore which is within 0.005 rotation of our position. When we use the same code with a loaded motor the voltage starts small which isn’t enough to move the motor and never changes.

We have no idea why or what to do to fix this. Any ideas?

// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot;

import com.ctre.phoenix6.configs.Slot0Configs;
import com.ctre.phoenix6.controls.DutyCycleOut;
import com.ctre.phoenix6.controls.PositionVoltage;
import com.ctre.phoenix6.hardware.TalonFX;

import edu.wpi.first.wpilibj.DutyCycle;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class Robot extends TimedRobot {

private TalonFX wheel_motor, hand_motor ;
DutyCycleOut m_wheel_motor;
private PositionVoltage anglePosition;

public void robotInit() {

var slot0Configs = new Slot0Configs();
slot0Configs.kP = 24; // An error of 0.5 rotations results in 12 V output
slot0Configs.kI = 0; // no output for integrated error
slot0Configs.kD = 0.1; // A velocity of 1 rps results in 0.1 V output

wheel_motor = new TalonFX(6);
hand_motor = new TalonFX(9);

anglePosition = new PositionVoltage(0).withSlot(0);

public void robotPeriodic() {
System.out.println("\nWheel Motor Position: " + wheel_motor.getPosition());
System.out.println("Wheel Motor Voltage: " + wheel_motor.getMotorVoltage());
//System.out.println("Hand Motor Position: " + hand_motor.getPosition());
//System.out.println("Hand Motor Voltage: " + hand_motor.getMotorVoltage());


public void teleopInit() {}

/** This function is called periodically during operator control. */
public void teleopPeriodic() {

/** This function is called once when the robot is disabled. */
public void disabledInit() {}

/** This function is called periodically when disabled. */
public void disabledPeriodic() {}

/** This function is called once when test mode is enabled. */
public void testInit() {}

/** This function is called periodically during test mode. */
public void testPeriodic() {}

/** This function is called once when the robot is first started up. */
public void simulationInit() {}

/** This function is called periodically whilst in simulation. */
public void simulationPeriodic() {}

public void autonomousInit() {


public void autonomousPeriodic() {


Since you’re only applying a Slot0Configs object and not a full TalonFXConfiguration (which contains a Slot0Configs), it’s likely that some configs are not factory defaulted.

Your PID gains will not be the same between loaded and unloaded. The voltage output will remain the same, but a fixed voltage will create a weaker acceleration with a loaded system than with an unloaded one. As a result, when there is a load on the motor, you will likely need stronger gains to be able to get the system moving. Additionally, for a larger SensorToMechanismRatio config, you will need to scale up your PID gains with it.

I apologize for the delay but this was 100% it. Thank you so much for your help.