First let me make sure about some things I am assuming but which you have not explicitly stated.
You are using TalonSRX motor controller, yes?
Your encoder is wired to the TalonSRX (not the roboRIO), yes?
You are using CAN (not PWM) to command the TalonSRX, yes?
If so, refer to paragraph 3.2 in the Software Reference Manual