Skip to main content

Phoenix 6 Migration

Pheonix 5 APi is officially deprecated

Phoenix 6 PID reference in converting PID gains: https://pro.docs.ctr-electronics.com/en/latest/docs/api-reference/device-specific/talonfx/basic-pid-control.html

Everything is now in rotations/sec therefore we can remove the conversion to encoder tics per 100 ms

 

Cancoder offsets Debugging

Possible Causes:

  • Magnet Direction
    • Directionality is different so the offset might need to be inverted. Check within tuner X what the value is the Counter Clockwise Positive as the magnet direction
    • The value should be somewhere between -1 and 1. The sensor range is -0.5 to 0.5 so the offset could also be bounded between that. 
    • HardwareMap.Java
    •    public static final SwervePodHardwareID POD001 = new SwervePodHardwareID(10, 12, -172.135);
         public static final SwervePodHardwareID POD002 = new SwervePodHardwareID(20, 22, -225.186);
         public static final SwervePodHardwareID POD003 = new SwervePodHardwareID(30, 32, -40);
         public static final SwervePodHardwareID POD004 = new SwervePodHardwareID(40, 42, 140.463); // 120.5
         public static final SwervePodHardwareID POD005 = new SwervePodHardwareID(13, 14, -30.525);
         public static final SwervePodHardwareID POD006 = new SwervePodHardwareID(23, 24, 105);
         public static final SwervePodHardwareID POD007 = new SwervePodHardwareID(33, 34, 125.508);
         public static final SwervePodHardwareID POD008 = new SwervePodHardwareID(43, 44, -173);
         public static final SwervePodHardwareID POD009 = new SwervePodHardwareID(15, 16, -178);

Getting encoder offsets

(this should be its own wiki page once we get it solidified with good screen shots)

Requirements

  • USB B cable
  • Windows laptop with Tuner X
  • WPILIB VSCode

 

 

Steps

  • Place pods into the tuning configuration
    • Because the pods orientation changes depending on which slot it is in (FR, FL, BR, BL) Pods are zeroed AS IF they were installed in the FR.
    • For the FR (front right) pod the wheel is turned so that it is facing forward. Looking from behind the driving gear should be facing to the right of the bot
    • Screenshot from 2024-01-25 11-58-54.png
    • Continue by placing the pods in the following configuration
    • image.png

  • Set Magnet offset to 0 in Tuner X
  • Set Magnet direction to CounterClockwise Positive
  • Run selftest snapshot
  • Save Offsets to the HardwareMap.java the value should be between -0.5 and 0.5 for the pod number you are reading