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.
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.
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).
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.