Cannot read IME encoder counts

Here’s the code. The problem has been simplified to one IME 339 motor. Only one I2C IME 339. IME double blinks green every 3 seconds. But cannot read the encoder counters in the sensors debug window. Any ideas?


#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1,  R_IME,          sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Motor,  port1,          R_Motor_FW2,   tmotorVex393_HBridge, openLoop, encoderPort, I2C_1)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma DebuggerWindows("debugStream")  // open debug stream window at runtime

task main()
{
	wait1Msec(2000);
	
	//resetMotorEncoder(R_Motor_FW2);
	nMotorEncoder[R_Motor_FW2] = 0;
	
	motor[R_Motor_FW2] = 50;	

	while (1) {

		clearDebugStream();
		
		writeDebugStreamLine( "Encoder Cnt    : % d   ", nMotorEncoder[R_Motor_FW2] );
		writeDebugStreamLine( "Time 1ms cnt   : % d", nSysTime);
		
		wait1Msec(50);
	}

}

Will have to try tonight, but I think this is the problem…

You need a special gear with an optical pattern on it:
http://www.vexrobotics.com/encoder-modules.html

In a pinch, you can cut these out and glue them on the 393 gear with the IME:
http://content.vexrobotics.com/images/products/accessories/276-1321-Replacement-Wheel-20150518.pdf

Try moving clearDebugStream () ahead of your while loop;)

I agree, I don’t think you will have enough time to see the debug streams results because they are erased every iteration of the loop. Try this:

#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1,  R_IME,          sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Motor,  port1,          R_Motor_FW2,   tmotorVex393_HBridge, openLoop, encoderPort, I2C_1)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
 
#pragma DebuggerWindows("debugStream")  // open debug stream window at runtime
 
task main()
{
    wait1Msec(2000);
     
    //resetMotorEncoder(R_Motor_FW2);
    nMotorEncoder[R_Motor_FW2] = 0;
     
    motor[R_Motor_FW2] = 50;
     
    // Clear the debug stream
    clearDebugStream(); 
 
    while (1) {
         
        writeDebugStreamLine( "Encoder Cnt    : % d   ", nMotorEncoder[R_Motor_FW2] );
        writeDebugStreamLine( "Time 1ms cnt   : % d", nSysTime);
         
        wait1Msec(50);
    }
 
}

The optical pattern glued to the internal motor gear fixed the encoder problem. Previous user of the motor must of have had a heck of a time getting the encoder to work :wink:

The clearDebugStream() inside the while loop is to keep the stream window from scrolling down quickly with appended new lines of text. It works well so far.