Version 1 (modified by 9 years ago) (diff) | ,
---|
Position Mode
Things needed to initialize position mode.
You need to set these variables:
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:
armMotor.setFeedbackDevice(FeedbackDevice.EncoderType);
armMotor.configEncoderCodesPerRev(X);
Note that on QuadEncoders? this is the nominal value, not the actual value
armMotor.setEncPosition(0);
This will save you a lot of future headache
You need these methods:
public void enable() { armMotor.enableControl(); }
public void positionMode() { armMotor.changeControlMode(TalonControlMode.Position); armMotor.setPID(P, I, D); }
Finally, here's some example code.
To initialize it, you need to run this:
Robot.armSys.positionMode(); Robot.armSys.enable();
Finally, once you've initialized the code:
Robot.armSys.setArmTalon(1F);
This will make it move one rotation.