My team is having trouble getting the speed control setting to work with our CAN Talon. We cannot get the Talon to respond to changes in the error or the set point of desired speed. We know that our encoder is working correctly because we can see changes in encoder position and velocity through both the RoboRio and our program. We have firmware version 2.0 on the CAN Talons and the Talon is connected to a Quad encoder. We cannot even get the Talon to tell the motor to spin regardless of the set point. The LEDs on the Talon stay solid orange while this program is running, regardless of the set point. If we are in vBus mode the Talon works correctly. We are using a 775 Pro motor. The encoder is an Armabot RS7.
This is the code that we are running. We used the code from the software reference guide for how to use the speed mode of control with java. We removed parts of their code that were unnecessary. Any help or suggestions would be greatly appreciated.
public class Robot extends IterativeRobot {
CANTalon _talon = new CANTalon(2);
Joystick joy = new Joystick(0);
StringBuilder sb = new StringBuilder();
int _loops = 0;
double target_Speed = 0;
public void robotInit() {
_talon.changeControlMode(TalonControlMode.Speed);
_talon.setFeedbackDevice(FeedbackDevice.QuadEncoder);
_talon.reverseSensor(false);
_talon.configEncoderCodesPerRev(12);
_talon.configNominalOutputVoltage(+0.0f, -0.0f);
_talon.configPeakOutputVoltage(+12.0f, -12.0f);
_talon.setProfile(0);
_talon.setP(0);
_talon.setI(0);
_talon.setD(0);
_talon.setF(0);
}
public void teleopPeriodic() {
double leftYStick = joy.getAxis(AxisType.kY);
double motorOutput = _talon.getOutputVoltage() / _talon.getBusVoltage();
sb.append(" out");
sb.append(motorOutput);
sb.append(" spd");
sb.append(_talon.getSpeed());
sb.append(" joy");
sb.append(leftYStick);
target_Speed = 1000;
_talon.set(target_Speed);
sb.append(" err");
sb.append(_talon.getClosedLoopError());
sb.append(" trg");
sb.append(target_Speed);
sb.append(" encV");
sb.append(_talon.getEncVelocity());
if(++_loops >= 10)
{
_loops = 0;
System.out.println(sb.toString());
}
sb.setLength(0);
}
}
```<br><br><a class='attachment' href='/uploads/default/original/3X/2/c/2cea912c5c53af67f9cc967c23aecadaa1273a88.java'>Robot.java</a> (2.16 KB)<br><br><br><a class='attachment' href='/uploads/default/original/3X/2/c/2cea912c5c53af67f9cc967c23aecadaa1273a88.java'>Robot.java</a> (2.16 KB)<br>