I’m having difficulties setting up the TalonSRX with the CTRE Mag Encoders. When I apply positive throttle to the talons the encoder position moves backwards when checking in the roboRIO dashboard, so I tried to change their phase using setSensorPhase() only that didn’t do anything. No matter what I set in setSensorPhase() I get the same result. I also noticed that when moving the joystick forward my left side moves backwards and my right side moves forward so I tried to invert the left side. However when I do this my left side locks up and doesn’t move at all, but all 4 talons have the same color lights. If someone could help me that would be great here is my code to setup the talons called in robotInit()
public void setSlave() {//Sets slave and master talons
rear_left.follow(front_left);
rear_right.follow(front_right);
setSlave = true;
}
public void setSensors() {
if(!setSlave)
return;
//Sets Sensors
front_left.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative,
RobotMap.SLOT_INDEX, RobotMap.TIMEOUT);
front_left.setSensorPhase(true);
front_right.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative,
RobotMap.SLOT_INDEX, RobotMap.TIMEOUT);
front_right.setSensorPhase(true);
//Sets PID loop
setPID(front_left);
setPID(front_right);
//Set Voltage Speed
setPeakSpeed(front_left, peakVoltage);
setPeakSpeed(front_right, peakVoltage);
//Resets Position
resetPosition();
setPID = true;
}
This is my drive function being called in teleopPeriodic():
public void arcadeDrive(Joystick controller) {
double leftSide = 0, rightSide = 0;
leftSide = controller.getX() > 0 ? controller.getX() : 0;//Gets the turn of the joystick
rightSide = controller.getX() < 0 ? controller.getX() : 0;
front_left.set(ControlMode.PercentOutput, controller.getY()+leftSide);
front_right.set(ControlMode.PercentOutput, controller.getY()+rightSide);
}
And here is a picture of my left talon when I move the joystick forward in the roboRIO dashboard.
https://preview.ibb.co/mFHOgw/screenshot.png](https://ibb.co/eRLLTb)