RobotC IME Won't Stop

We again are programming autonomous and are having issues. We are simply trying to get the encoders to work by having them stop at 100 ticks. Here is the code. Our two programmers have no idea what the issue is.

task autonomous()
	nMotorEncoder[backright] = 0;

	while(nMotorEncoder[backright] < 1000)
		motor[backright] = 63;
	motor[backright] = 0;

We have tried looking at the sample code for instructions, however, we have it set up the same to no avail. However, the sample program works. We are lost. Please help.

Are you sure you meant to say 100 ticks or 1000 ticks?

I’m guessing that’s not what you meant to say and that’s not the source of your problem, but I thought I would ask.

Yup, I meant 1000.

Can you watch your RobotC debugger window and see how the encoder values might be changing or if they are changing?

You might have a look at some of the comments in this following thread, too:

If it’s an optical encoder (typical sensor, 2 wires), switch the input and output wires. If it’s an IME, try using (-nMotorEncoder). The wheel/shaft may be running in the opposite direction you want, so instead of going up, the encoder value goes down. Taking the negative would fix this.
You can also test this by using writeDebugStreamLine (“encoder value: %d”, nMotorEncoder[motor]) and checking “Debug Stream” in the “Debugger Windows” tab.

The wheel/ motor is moving in the direction we want. When we watch the debug window, it shows the encoder working fine. It shows the encoders increasing… (If we let it run, the encoder readings go FAR past 1000 without the program making it stop).

We are using Integrated Motor Encoders.

Is what you posted the full extent of your code that is controlling this motion?
Are there any other motors that are being turned on and that need to be turned off other than the backright motor?

One thing to be careful of, the value for an IME that you see in the “sensor” debug window can be the opposite of the value you see in the “motors” debug window. The reason is that ROBOTC will negate the value read by nMotorEncoder if you have reversed the motor in the motors&sensors dialog. This is so that when sending positive control values to the motor the encoder count will always increase if you use nMotorEncoder to read it (and the wiring is correct, no swapped red/black wires).

Post the whole program (you can delete driver control, we don’t need that) and we can see what’s going on.