Issues regarding the vex quadrature encoder

I am using the quadrature encoder to measure the distance my robot drive, so I defined a function to translate the metric distance to encoder counts. I used robotC debugger to see how the encoder sensor ticks change when I pushes the robot, and write down the corresponding encoder ticks to metric distances, and use these tuples to calculate the proportion.

But here comes the issue. I used the calculated proportion to write an autonomous program to drive my robot some distance, say 30 centimeters; the calculated proportion is 10.67, so it is about 320 encoder ticks. But when the program reaches the target encoder tick, the robot will always drive several centimeters more, about 34 cm rather than 30. I also used the debugger to check the sensor value, and when the robot stops, the reported encoder value is around 320, not more than 325, which means the metric distance error should not exceed 1 cm. So where does this error come from?

The more weired issue is when I use the same proportion to drive the robot backward, say -30 cm, which means -320 encoder ticks. In this case, when the program reaches the target encoder tick, the metric distance error will not exceed 1 cm. Why does the quadrature encoder has different performance in the different directions??

My robot’s sensor configuration is as follows, the ‘base_quad’ is the one I am using to measure distance. I plugged two quad encoders and made them one port (port 4) separated on purpose, because when I plug them in port 2, 3 and 4, 5, the first one will only return -1, 1 or 0 values. Is this a bug of robotC or the VEX cortex?


#pragma config(Sensor, dgtl1,  bumper,         sensorTouch)
#pragma config(Sensor, dgtl2,  base_quad,      sensorQuadEncoder)
#pragma config(Sensor, dgtl5,  lift_quad,      sensorQuadEncoder)
#pragma config(Sensor, dgtl7,  jump7,          sensorDigitalIn)
#pragma config(Sensor, dgtl8,  jump8,          sensorDigitalIn)
#pragma config(Sensor, dgtl9,  arm_pump,       sensorDigitalOut)
#pragma config(Sensor, dgtl10, gripper_pump,   sensorDigitalOut)
#pragma config(Sensor, dgtl11, cube_pump,      sensorDigitalOut)

For future lookup reference; this question has been crossposted and answered on the ROBOTC forums (link below). I am going to keep the conversation on this topic centered there, to avoid any confusion (from multiple threads on the same topic).

ROBOTC forum: ROBOTC