wiki:Position Mode

Position Mode

Things needed to initialize position mode.

You need to set these doubles:

P = 100.0,
I = 0.0,
D = 0.0;

Change as necessary. These are *not* recommended values.

Read up on PID loops as necessary.

In the constructor of your subsystem, you need:

talon.setFeedbackDevice(FeedbackDevice.EncoderType);

talon.configEncoderCodesPerRev(X);

Note that on QuadEncoders? this is the nominal value, not the actual value

talon.setEncPosition(0);

This will save you a lot of future headache

You need these methods:

public void enable() {
	talon.enableControl();
}
public void positionMode() {
	talon.changeControlMode(TalonControlMode.Position);
	talon.setPID(P, I, D);
}

Finally, here's some example code.

To initialize it, you need to run this:

Robot.SubSystem.positionMode();
Robot.SubSystem.enable();

Finally, once you've initialized the code:

Robot.SubSystem.<SetCommand>(1F);

This will make it move one rotation.

Last modified 5 years ago Last modified on Feb 14, 2016, 9:54:16 AM