Integrated Motor Encoder does not work sometimes

I’m programming my robot with easyC V4 with the latest master code. There is something wrong with my IME. Sometimes the encoder returns a value as 0 but if i run the autonomous program once again it works well. When the encoder is not working well, it gives out a solid red light. I’ve read the passage about the IME in vex wiki but i just don’t know how to solve the problem that data is being written to EEprom (1sec). and actually my program work pretty well when the code is really short. However usually my program need many sensors to cooperate. does the number of sensors that using at the same time actually cause the problem?
here is how i usually program with IME


InitIntegratedMotorEncoder();
PresetIntegratedMotorEncoder(1,0);
while(GetIntegratedMotorEncoder(1) < 1000)
{
   SetMotor(1,127);
}
SetMotor(1,0);

I sent this question to one of our electrical engineers yesterday and he’s currently working through it. He’ll post here as soon as he has an answer.

Sorry for the delay!

Check the black / white encoder gear. If you overtightened the case, the paint was scraped off and the encoder will not know the gear is turning.

If the Robot light is blinking a slow red, there may be a code issue, such as an infinite loop. You might try changing the while loop from “while(GetIntegratedMotorEncoder(1) < 1000)” to “while (x < 1000)”. Move the “GetIntegratedMotorEncoder(1) < 1000” instruction inside the while loop and change it to “x = GetIntegratedMotorEncoder(1)”. Try adding a short delay inside the while loop.

I am unable to replicate your issue with your code snippet, so don’t have any other ideas.

Oh the red light is on the encoders
And I’ve tried to change another encoder but it still replicate sometimes and also I’ve tried to add a short wait about 50ms to the loop but nothing changes

From my original testing, it is best to have only one 4-wire cable between the Cortex and the first Integrated Encoder Module. I suggest having just one 4-wire cable between each Integrated Encoder Module, though I did not have issues with two cables. Otherwise, our Software guru will have to tap into your Robot’s I2C bus to see what is going on.

I don’t think there is anything to do with the cortex or the I2C because I’ve already changed a brand new Cortex
And I didn’t understand what you mean about one 4-wire cable between the cortex and the first encoder and between each IME. You cannot use more than one, can you? You mean the Y-cable?