Inconsistent Quadrature shaft enocders

i’m having trouble getting consistent # of revolutions with our quadrature shaft encoders. At first a value of 360 “ticks” gave us two revolutions. Then when tested again maybe 10 minutes later the gear did not revolve the same number of revolutions and a value of 270 gave the gear one full revolution. Then, once again, when i ran the program again the value gave more than a revolution. basically our shaft encoders seem to be needing different values for one revolution each time we test the program. One value may work for a few trials, but when left alone for a few minutes the value needed to get one revolution changes. So could someone show me exactly what i’m doing wrong with my code?

Without seeing your code I cannot comment on what may be wrong.
Check that the cables to the encoders are secure, open the encoder (slide the cover off) and make sure it is not dirty inside (ie. make sure all the small slots are not covered in dust).
The encoder should give 360 “ticks” per revolution.