So we recently had to implement IME’s on one of our robots (we know we shouldn’t) and we can’t get the right side encoder to read positive values when the robot is moving forward. We have tried to reverse the motor in “Motor and Sensor Setup” but that does not correct the issue. What is the workaround for this?
TL;DR use nMotorEncoder not SensorValue and make sure the wiring to the motor is not reversed.
The nMotorEncoder function (used with motor port) will return values that increment when positive motor control values are sent to the motor (i.e… motor port ] = 100; ) If the reverse flag is set in motors&sensors setup then it will still return incrementing values for positive control, however, the motor will move in the other direction. For this to work correctly you must not have reversed the motor using wiring, that is, reversed the motor by connecting the red motor wire to the black MC29 wire. (for ports 1 and 10 the red wire must be on the inside towards the VEXnet key).
SensorValue does not take the reverse flag into consideration and values in the sensors debug window may show negative numbers when the value returned by nMotorEncoder (and displayed in the motors debug window) is positive.
Piggybacking off of this to ask another question similar to it, if we’re using the RobotC built-in-PID with the IMEs but are still experience one motor returning negative encoder values when we’re using setMotorTarget or moveMotorTarget, what’s the solution? Would setting a master-slave motor relationship be the thing I’m supposed to do?